aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2017-03-07 14:57:11 +0100
committerJohn MacFarlane <jgm@berkeley.edu>2017-03-07 15:00:32 +0100
commit8c55b7b5640e41feaae658e95e659bdd2101a340 (patch)
treedd6b64f99e413bec7823a88d4131ed835fed7e16
parent69e1b959e001f1ce23b7dbfda4401c82a70922ac (diff)
downloadpandoc-8c55b7b5640e41feaae658e95e659bdd2101a340.tar.gz
Markdown reader: Treat certain environments as inline
when they occur without space surrounding them. E.g. equation, math. This avoids incorrect vertical space around equations. Closes #3309. Closes #2171. See also rstudio/bookdown#358.
-rw-r--r--src/Text/Pandoc/Readers/LaTeX.hs4
-rw-r--r--test/command/3309.md52
2 files changed, 55 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs
index c5f5df6dc..60113173d 100644
--- a/src/Text/Pandoc/Readers/LaTeX.hs
+++ b/src/Text/Pandoc/Readers/LaTeX.hs
@@ -1063,7 +1063,9 @@ rawLaTeXBlock = snd <$> try (withRaw (environment <|> blockCommand))
rawLaTeXInline :: PandocMonad m => LP m Inline
rawLaTeXInline = do
- raw <- (snd <$> withRaw inlineCommand) <|> (snd <$> withRaw blockCommand)
+ raw <- (snd <$> withRaw inlineCommand)
+ <|> (snd <$> withRaw inlineEnvironment)
+ <|> (snd <$> withRaw blockCommand)
RawInline "latex" <$> applyMacros' raw
addImageCaption :: PandocMonad m => Blocks -> LP m Blocks
diff --git a/test/command/3309.md b/test/command/3309.md
new file mode 100644
index 000000000..083ac53c9
--- /dev/null
+++ b/test/command/3309.md
@@ -0,0 +1,52 @@
+Certain environments should be treated as inline unless they
+are surrounded by blank lines:
+
+```
+% pandoc -t latex --wrap=preserve
+Lorem ipsum dolor sit amet,
+
+\begin{equation}
+E = mc^2,
+\end{equation}
+
+consectetur adipiscing elit.
+^D
+Lorem ipsum dolor sit amet,
+
+\begin{equation}
+E = mc^2,
+\end{equation}
+
+consectetur adipiscing elit.
+```
+
+```
+% pandoc -t latex --wrap=preserve
+Lorem ipsum dolor sit amet,
+\begin{equation}
+E = mc^2,
+\end{equation}
+consectetur adipiscing elit.
+^D
+Lorem ipsum dolor sit amet,
+\begin{equation}
+E = mc^2,
+\end{equation}
+consectetur adipiscing elit.
+```
+
+```
+% pandoc -t latex --wrap=preserve
+The formula
+\begin{math}
+x = y
+\end{math}
+should be inline.
+^D
+The formula
+\begin{math}
+x = y
+\end{math}
+should be inline.
+```
+