From cbcb9776351c973c2541f8bef909eb2f4fa1b659 Mon Sep 17 00:00:00 2001
From: "Fletcher T. Penney"
Date: Sat, 4 Mar 2017 14:16:18 -0500
Subject: [PATCH] FIXED: Fix underscores in raw latex
---
Sources/libMultiMarkdown/latex.c | 8 ++++++++
tests/MMD6Tests/Emph and Strong UL.tex | 2 +-
tests/MMD6Tests/Fenced Code Blocks.html | 2 +-
tests/MMD6Tests/Fenced Code Blocks.htmlc | 2 +-
tests/MMD6Tests/Fenced Code Blocks.tex | 2 +-
tests/MMD6Tests/Fenced Code Blocks.text | 2 +-
6 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/Sources/libMultiMarkdown/latex.c b/Sources/libMultiMarkdown/latex.c
index 5d6bdac..32996f9 100644
--- a/Sources/libMultiMarkdown/latex.c
+++ b/Sources/libMultiMarkdown/latex.c
@@ -1540,6 +1540,14 @@ void mmd_export_token_latex_tt(DString * out, const char * source, token * t, sc
case DASH_M:
print_const("-{}-{}-");
break;
+ case EMPH_START:
+ case EMPH_STOP:
+ if (source[t->start] == '_') {
+ print_const("\\_");
+ } else {
+ print_const("*");
+ }
+ break;
case ESCAPED_CHARACTER:
print_const("\\textbackslash{}");
mmd_print_char_latex(out, source[t->start + 1]);
diff --git a/tests/MMD6Tests/Emph and Strong UL.tex b/tests/MMD6Tests/Emph and Strong UL.tex
index b530a24..0940964 100644
--- a/tests/MMD6Tests/Emph and Strong UL.tex
+++ b/tests/MMD6Tests/Emph and Strong UL.tex
@@ -86,7 +86,7 @@ foo\_bar\_foo
35
-foo\_\_\texttt{_bar_}\_\_
+foo\_\_\texttt{\_bar\_}\_\_
\_(\emph{foo})
diff --git a/tests/MMD6Tests/Fenced Code Blocks.html b/tests/MMD6Tests/Fenced Code Blocks.html
index 68429e4..e950abe 100644
--- a/tests/MMD6Tests/Fenced Code Blocks.html
+++ b/tests/MMD6Tests/Fenced Code Blocks.html
@@ -30,7 +30,7 @@ bar
\begin{equation}\nabla \times \mathbf{E} = - \frac{\partial \mathbf{B}}{\partial t}\end{equation}
-\begin{equation}\nabla \times \mathbf{E} = - \frac{\partial \mathbf{B}}{\partial t}\end{equation}
+\begin{equation}\nabla \times \mathbf{E} = - \frac{\partial \mathbf{B}}{\partial t}\end{equation}
5
diff --git a/tests/MMD6Tests/Fenced Code Blocks.htmlc b/tests/MMD6Tests/Fenced Code Blocks.htmlc
index cdc210f..80da4af 100644
--- a/tests/MMD6Tests/Fenced Code Blocks.htmlc
+++ b/tests/MMD6Tests/Fenced Code Blocks.htmlc
@@ -24,7 +24,7 @@ latex config: article
\begin{equation}\nabla \times \mathbf{E} = - \frac{\partial \mathbf{B}}{\partial t}\end{equation}
-latex
+tex
\begin{equation}\nabla \times \mathbf{E} = - \frac{\partial \mathbf{B}}{\partial t}\end{equation}
5
diff --git a/tests/MMD6Tests/Fenced Code Blocks.tex b/tests/MMD6Tests/Fenced Code Blocks.tex
index d6f9222..d439f95 100644
--- a/tests/MMD6Tests/Fenced Code Blocks.tex
+++ b/tests/MMD6Tests/Fenced Code Blocks.tex
@@ -33,7 +33,7 @@ bar
\begin{equation}\nabla \times \mathbf{E} = - \frac{\partial \mathbf{B}}{\partial t}\end{equation}
\end{verbatim}
-\begin{lstlisting}[language=latex]
+\begin{lstlisting}[language=tex]
\begin{equation}\nabla \times \mathbf{E} = - \frac{\partial \mathbf{B}}{\partial t}\end{equation}
\end{lstlisting}
diff --git a/tests/MMD6Tests/Fenced Code Blocks.text b/tests/MMD6Tests/Fenced Code Blocks.text
index b584980..1a3651d 100644
--- a/tests/MMD6Tests/Fenced Code Blocks.text
+++ b/tests/MMD6Tests/Fenced Code Blocks.text
@@ -29,7 +29,7 @@ bar
\begin{equation}\nabla \times \mathbf{E} = - \frac{\partial \mathbf{B}}{\partial t}\end{equation}
```
-```latex
+```tex
\begin{equation}\nabla \times \mathbf{E} = - \frac{\partial \mathbf{B}}{\partial t}\end{equation}
```
--
2.40.0