git.iko.soy/typeable/pandoc
on master help sign in
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.

commit8c55b7b5640e41feaae658e95e659bdd2101a340 authorJohn MacFarlane <jgm@berkeley.edu> dateTue 7 Mar 2017, 14:57 (10 years ago) parent69e1b95
2 files changed+55−1
src/Text/Pandoc/Readers/LaTeX.hs+3−1 test/command/3309.md+52
src/Text/Pandoc/Readers/LaTeX.hs+3−1
@@ -1063,7 +1063,9 @@ rawLaTeXBlock = snd <$> try (withRaw (environment <|> blockCommand))
10631063
10641064rawLaTeXInline :: PandocMonad m => LP m Inline
10651065rawLaTeXInline = do
1066− raw <- (snd <$> withRaw inlineCommand) <|> (snd <$> withRaw blockCommand)
1066+ raw <- (snd <$> withRaw inlineCommand)
1067+ <|> (snd <$> withRaw inlineEnvironment)
1068+ <|> (snd <$> withRaw blockCommand)
10671069 RawInline "latex" <$> applyMacros' raw
10681070
10691071addImageCaption :: PandocMonad m => Blocks -> LP m Blocks
test/command/3309.mdnew file+52
@@ -0,0 +1,52 @@
1+Certain environments should be treated as inline unless they
2+are surrounded by blank lines:
3+
4+```
5+% pandoc -t latex --wrap=preserve
6+Lorem ipsum dolor sit amet,
7+
8+\begin{equation}
9+E = mc^2,
10+\end{equation}
11+
12+consectetur adipiscing elit.
13+^D
14+Lorem ipsum dolor sit amet,
15+
16+\begin{equation}
17+E = mc^2,
18+\end{equation}
19+
20+consectetur adipiscing elit.
21+```
22+
23+```
24+% pandoc -t latex --wrap=preserve
25+Lorem ipsum dolor sit amet,
26+\begin{equation}
27+E = mc^2,
28+\end{equation}
29+consectetur adipiscing elit.
30+^D
31+Lorem ipsum dolor sit amet,
32+\begin{equation}
33+E = mc^2,
34+\end{equation}
35+consectetur adipiscing elit.
36+```
37+
38+```
39+% pandoc -t latex --wrap=preserve
40+The formula
41+\begin{math}
42+x = y
43+\end{math}
44+should be inline.
45+^D
46+The formula
47+\begin{math}
48+x = y
49+\end{math}
50+should be inline.
51+```
52+