Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Add latex formatter (for songs package) #107

Closed
wants to merge 1 commit into from

Conversation

ftes
Copy link

@ftes ftes commented Sep 3, 2019

  • Only supports a very limited subset of tags so far (artist, title, subtitle, comment, capo)
  • Other tags are simply rendered as \textcomment
  • The result has additional newlines, because some tags are filtered out to construct the first \beginsong line. If they were the sole item on their previous line, that line remains as an empty line.

src/formatter/latex_formatter.js Show resolved Hide resolved
src/formatter/latex_formatter.js Outdated Show resolved Hide resolved
src/formatter/latex_formatter.js Outdated Show resolved Hide resolved
src/formatter/latex_formatter.js Outdated Show resolved Hide resolved
src/formatter/latex_formatter.js Outdated Show resolved Hide resolved
test/formatter/latex_formatter.js Outdated Show resolved Hide resolved
test/formatter/latex_formatter.js Outdated Show resolved Hide resolved
test/formatter/latex_formatter.js Outdated Show resolved Hide resolved
test/formatter/latex_formatter.js Outdated Show resolved Hide resolved
test/formatter/latex_formatter.js Outdated Show resolved Hide resolved
@ftes ftes force-pushed the feature/latex-formatter branch from 95dc6e5 to dc81920 Compare September 3, 2019 19:51
src/formatter/latex_formatter.js Outdated Show resolved Hide resolved
src/formatter/latex_formatter.js Outdated Show resolved Hide resolved
@ftes ftes force-pushed the feature/latex-formatter branch 2 times, most recently from f105c4f to d722f7d Compare September 3, 2019 19:53
@ftes ftes force-pushed the feature/latex-formatter branch from d722f7d to c26a156 Compare September 3, 2019 19:54
@ftes ftes force-pushed the feature/latex-formatter branch 3 times, most recently from 17c3ac8 to 980df5f Compare September 3, 2019 20:07
@martijnversluis
Copy link
Owner

Hey @ftes,

sorry to reply this late. Your PR looks nice! Just out of curiosity, do you have an example how this would be rendered by LaTex?

There are two issues preventing this from being mergeble: Code Climate is complaining and the branch got out-of-date. Could you perhaps try to rebase the branch? Then I will try to find out what Code Climate is complaining about (it keeps saying it doesn't have an analysis 🤔)

@ftes
Copy link
Author

ftes commented Oct 4, 2019

Here's an example of what it might look like.

image

You cannot use the output standalone though, but have to embed it in a proper Latex wrapper document which also has `\usepackage[chorded]{songs}.

- Only supports a very limited subset of tags so far (artist, title, subtitle, comment, capo)
- Other tags are simply rendered as `\textcomment`
- The result has additional newlines, because some tags are filtered out to construct the first `\beginsong` line. If they were the sole item on their previous line, that line remains as an empty line.
@ftes ftes force-pushed the feature/latex-formatter branch from 980df5f to 95301aa Compare October 4, 2019 09:11
@codeclimate
Copy link

codeclimate bot commented Oct 4, 2019

Code Climate has analyzed commit 95301aa and detected 2 issues on this pull request.

Here's the issue category breakdown:

Category Count
Duplication 2

View more on Code Climate.

@ftes
Copy link
Author

ftes commented Oct 4, 2019

Code duplication found. Personally I would keep it duplicated rather than extracting 4 lines of code.

I can't see how to mark this as won't fix for code climate though.

@martijnversluis
Copy link
Owner

@ftes Should we try and rebase this PR? CodeClimate does not have the PR analysis available...

@martijnversluis
Copy link
Owner

Hey @ftes. Would you like to get your branch merged? If not, I'll plan to use your implementation on a fresh branch (and credit you of course 😉 )

@ftes
Copy link
Author

ftes commented Oct 11, 2020 via email

formatTag(tag) {
switch (tag.name) {
case COMMENT:
return `\\textcomment{${tag.value}}`;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be \\textnote{${tag.value}}; per the docs. \textcomment gives an error for me. However, the songs package does not support Intros, outros, breaks etc. A ''workaround'' for this is to use the \nolyrics option. For example:

\beginverse
	{\nolyrics Outro:
	\[G]  \[D]  \[A]  \[F\#m]  \[Em]  \[D]  \[A]  \[Em]}
\endverse

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how to implement that though...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants