Currently \verb is used to render inline code. However, that has some downsides as it does not work in moving arguments or within macros like \multicolumn, and it doesn't break long inline code lines. This PR changes the implementation to use \texttt, which fixes those issues.
The PR provides three patches which can be integration tested with the following script to create test cases as described below:
#!/bin/env python3
import mistletoe
from mistletoe.latex_renderer import LaTeXRenderer
def render(f):
with open(f, 'r') as fp:
return mistletoe.markdown(fp, LaTeXRenderer)
# test case that fails for main but is fixed by 866bc2f35a95f18536a1626ec3f4d42b1209b939
test_0 = """
~~strikethrough~~
"""
# test case that fails for main but is fixed by 1fba4806a682d3edd0eb0dbe9e103784ac7e94f4
test_1 = """
this is the set of LaTeX escape chars: $ # { } & _ % \\ ~ ^
"""
# test case to check whether 4a97c287f0192f968c107d3cf428e78d4804e1d7 still renders inline code as expected
test_2 = """
line `inline code` line
line `inline code with two spaces` line
line `inline\tcode with tab` line
line `inline\t\tcode with two tabs` line
line `inline code with\nnewline` line
line without inline code which would require a linebreak because it is simply way too long to fit.
line `inline code which would require a linebreak because it is simply way too long to fit`.
this is the set of LaTeX escape chars in inline code: `$ # { } & _ % \\ ~ ^`
"""
for test, name in zip([test_0, test_1, test_2], ['test_0', 'test_1', 'test_2']):
open('%s.md'%name, 'w').write(test)
open('%s.tex'%name, 'w').write(render('%s.md'%name))
for main pdflatex test_0.tex results in the following error: ! LaTeX Error: Unknown option 'normalem' for package 'ulem'. With 866bc2f it works as expected
for main pdflatex test_1.tex results in another error:
coverage: 94.201% (-0.006%) from 94.207%
when pulling 4a97c287f0192f968c107d3cf428e78d4804e1d7 on boschresearch:fix-render-inline-code
into a40cd2fceb4c4f8193aa9b227e4906b01891439a on miyuchina:master.
Currently
\verb
is used to render inline code. However, that has some downsides as it does not work in moving arguments or within macros like\multicolumn
, and it doesn't break long inline code lines. This PR changes the implementation to use\texttt
, which fixes those issues.The PR provides three patches which can be integration tested with the following script to create test cases as described below:
pdflatex test_0.tex
results in the following error:! LaTeX Error: Unknown option 'normalem' for package 'ulem'.
With 866bc2f it works as expectedpdflatex test_1.tex
results in another error:With 1fba480 it works as expected
For 1fba480
pdflatex test_2.tex
shows the behavior of the original implementation of inline code rendering:Finally, this PR's main contribution is the changed implementation of inline code rendering in 4a97c28 the result of which can be seen here: