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

Escape meta characters of LaTeX in "judgeOffset" to avoid the compilation failure #4

Closed
CLRafaelR opened this issue Feb 24, 2021 · 4 comments

Comments

@CLRafaelR
Copy link
Contributor

I found that PDF compilation via LaTeX halts when judgeMax, the character/word used for the grammaticality/acceptability judgement whose number of characters are the largest in the ex environment, contains one of the LaTeX's meta-characters such as #, % or &. So, the following two markdown examples are not properly processed in the compilation procedure and throw an error: ! Illegal parameter number in definition of \@jwidth.

::: {.ex #grammaticality-judgement}
^# I'm not sure this is grammatical.
:::

or

::: {.ex #grammaticality-judgement}
a. ^# I'm not sure this is grammatical.
a. This is grammatical.
:::

I suspect that the line in texMakeGb4e function and the line in texMakeLangsci function render the characters like #, % or & to LaTeX as they are (i.e. without escaping them) and that this causes the above-mentioned error.

Those lines can be replaced with the following lua command (I verified this works in my environment):

local judgeOffset = "\\judgewidth{"..string.gsub(pandoc.utils.stringify(judgeMax), "([#$%&_{}~^])", "\\%1").."}"

Would you mind considering and verifying this patch?

Environment

pandoc-ling: the latest version as of 2021/02/24
pandoc: v2.11.4
OS: Windows 10 x64 (build 19042)

@cysouw
Copy link
Owner

cysouw commented Feb 25, 2021

Good catch! The error does not occur with linguex, so that might help until I have managed to fix this.

@cysouw
Copy link
Owner

cysouw commented Feb 25, 2021

I fixed it using your proposal, thx @CLRafaelR!

@cysouw cysouw closed this as completed in f49f012 Feb 25, 2021
@CLRafaelR
Copy link
Contributor Author

Yes, the problem occurred with (langsci-)gb4e and I had to mentioned that more implicitly... Thank you for the adaptation of the patch!

@cysouw
Copy link
Owner

cysouw commented Feb 25, 2021

I also added a new "lazy" example-coding possibility, in which you can make subentries (with letters) by just typing dashed (markdown lists). It will insert the letters anyway :-)

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

No branches or pull requests

2 participants