Skip to content

Commit

Permalink
Fix encoding of some markup inside LaTeX texttt environment (fixes #110
Browse files Browse the repository at this point in the history
… and #108)
  • Loading branch information
fletcher committed Feb 4, 2018
1 parent adcbea5 commit 8dc8ee9
Show file tree
Hide file tree
Showing 11 changed files with 69 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Sources/libMultiMarkdown/latex.c
Original file line number Diff line number Diff line change
Expand Up @@ -2140,6 +2140,17 @@ void mmd_export_token_latex_tt(DString * out, const char * source, token * t, sc
mmd_print_char_latex(out, source[t->start + 1]);
break;

case HASH1:
case HASH2:
case HASH3:
case HASH4:
case HASH5:
case HASH6:
case TEXT_HASH:
print_const("\\");
print_token(t);
break;

case HTML_ENTITY:
if (source[t->start + 1] == '#') {
print_const("\\&\\#");
Expand All @@ -2156,6 +2167,14 @@ void mmd_export_token_latex_tt(DString * out, const char * source, token * t, sc
t->next->type = TEXT_EMPTY;
}

case MATH_DOLLAR_SINGLE:
print_const("\\$");
break;

case MATH_DOLLAR_DOUBLE:
print_const("\\$\\$");
break;

case MATH_BRACKET_OPEN:
case MATH_BRACKET_CLOSE:
case MATH_PAREN_OPEN:
Expand Down
4 changes: 4 additions & 0 deletions tests/MMD6Tests/Amps and Angles.fodt
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,10 @@ office:mimetype="application/vnd.oasis.opendocument.text">
<text:p text:style-name="Standard">&amp;#169; <text:span text:style-name="Source_20_Text">&amp;#169;</text:span></text:p>

<text:p text:style-name="Standard">&amp;#xA9; <text:span text:style-name="Source_20_Text">&amp;#xA9;</text:span></text:p>

<text:p text:style-name="Standard">15</text:p>

<text:p text:style-name="Standard"><text:span text:style-name="Source_20_Text">&amp; and &amp;amp; and &lt; and &gt; in code span.</text:span></text:p>
</office:text>
</office:body>
</office:document>
4 changes: 4 additions & 0 deletions tests/MMD6Tests/Amps and Angles.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@

<p>&#xA9; <code>&amp;#xA9;</code></p>

<p>15</p>

<p><code>&amp; and &amp;amp; and &lt; and &gt; in code span.</code></p>

</body>
</html>

4 changes: 4 additions & 0 deletions tests/MMD6Tests/Amps and Angles.htmlc
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,7 @@ latex config: article</p>
<p>&#169; <code>&amp;#169;</code></p>

<p>&#xA9; <code>&amp;#xA9;</code></p>

<p>15</p>

<p><code>&amp; and &amp;amp; and &lt; and &gt; in code span.</code></p>
4 changes: 4 additions & 0 deletions tests/MMD6Tests/Amps and Angles.tex
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,9 @@

\&\#xA9; \texttt{\&\#xA9;}

15

\texttt{\& and \& and < and > in code span.}

\input{mmd6-article-footer}
\end{document}
4 changes: 4 additions & 0 deletions tests/MMD6Tests/Amps and Angles.text
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,7 @@ Here is an inline [link](</script?foo=1&bar=2>).
&#169; `&#169;`

&#xA9; `&#xA9;`

15

`& and &amp; and < and > in code span.`
6 changes: 6 additions & 0 deletions tests/MMD6Tests/Code Spans.fodt
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,12 @@ office:mimetype="application/vnd.oasis.opendocument.text">
<text:p text:style-name="Standard"><text:span text:style-name="Source_20_Text">-&lt;&gt;--&amp;\&amp;---...</text:span></text:p>

<text:p text:style-name="Standard"><text:span text:style-name="Source_20_Text">`foo`</text:span></text:p>

<text:p text:style-name="Standard">15</text:p>

<text:p text:style-name="Standard"><text:span text:style-name="Source_20_Text">$foo &lt;&lt; $bar</text:span></text:p>

<text:p text:style-name="Standard"><text:span text:style-name="Source_20_Text">#foo</text:span></text:p>
</office:text>
</office:body>
</office:document>
6 changes: 6 additions & 0 deletions tests/MMD6Tests/Code Spans.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@

<p><code>`foo`</code></p>

<p>15</p>

<p><code>$foo &lt;&lt; $bar</code></p>

<p><code>#foo</code></p>

</body>
</html>

6 changes: 6 additions & 0 deletions tests/MMD6Tests/Code Spans.htmlc
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,9 @@ baz</code></p>
<p><code>-&lt;&gt;--&amp;\&amp;---...</code></p>

<p><code>`foo`</code></p>

<p>15</p>

<p><code>$foo &lt;&lt; $bar</code></p>

<p><code>#foo</code></p>
6 changes: 6 additions & 0 deletions tests/MMD6Tests/Code Spans.tex
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,11 @@
\texttt{`foo`}
15
\texttt{\$foo << \$bar}
\texttt{\#foo}
\input{mmd6-article-footer}
\end{document}
6 changes: 6 additions & 0 deletions tests/MMD6Tests/Code Spans.text
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,9 @@ foo
`-<>--&\&---...`

`` `foo` ``

15

`$foo << $bar`

`#foo`

0 comments on commit 8dc8ee9

Please sign in to comment.