git.iko.soy/typeable/pandoc
on master help sign in
LaTeX reader: allow hspace and vspace to count as raw block or inline.
7d0082aJohn MacFarlane
src/Text/Pandoc/Readers/LaTeX.hs+5−3
@@ -445,7 +445,6 @@ inlineCommand :: PandocMonad m => LP m Inlines
445inlineCommand = try $ do
445inlineCommand = try $ do
446 (name, raw') <- withRaw anyControlSeq
446 (name, raw') <- withRaw anyControlSeq
447 guard $ name /= "begin" && name /= "end"
447 guard $ name /= "begin" && name /= "end"
448− guard $ not $ isBlockCommand name
449 exts <- getOption readerExtensions
448 exts <- getOption readerExtensions
450 star <- option "" (string "*")
449 star <- option "" (string "*")
451 let name' = name ++ star
450 let name' = name ++ star
@@ -461,7 +460,7 @@ inlineCommand = try $ do
461 else ignore rawcommand
460 else ignore rawcommand
462 (lookupListDefault mzero [name',name] inlineCommands <*
461 (lookupListDefault mzero [name',name] inlineCommands <*
463 optional (try (string "{}")))
462 optional (try (string "{}")))
464− <|> raw
463+ <|> (guard (not (isBlockCommand name)) >> raw)
465
464
466unlessParseRaw :: PandocMonad m => LP m ()
465unlessParseRaw :: PandocMonad m => LP m ()
467unlessParseRaw = getOption readerExtensions >>=
466unlessParseRaw = getOption readerExtensions >>=
@@ -648,7 +647,10 @@ inlineCommands = M.fromList $
648 ] ++ map ignoreInlines
647 ] ++ map ignoreInlines
649 -- these commands will be ignored unless --parse-raw is specified,
648 -- these commands will be ignored unless --parse-raw is specified,
650 -- in which case they will appear as raw latex blocks:
649 -- in which case they will appear as raw latex blocks:
651− [ "index" ]
650+ [ "index"
651+ , "hspace"
652+ , "vspace"
653+ ]
652
654
653mkImage :: PandocMonad m => [(String, String)] -> String -> LP m Inlines
655mkImage :: PandocMonad m => [(String, String)] -> String -> LP m Inlines
654mkImage options src = do
656mkImage options src = do
test/command/hspace.mdnew file+56
@@ -0,0 +1,56 @@
1+`\hspace` and `\vspace` should count as both block and inline.
2+
3+Here they need to be inline:
4+```
5+% pandoc -f markdown+raw_tex -t native
6+\begin{figure}
7+\includegraphics{lalune.jpg}
8+\caption{lalune \hspace{2em} \vspace{1em} bloo}
9+\end{figure}
10+^D
11+[RawBlock (Format "latex") "\\begin{figure}\n\\includegraphics{lalune.jpg}\n\\caption{lalune \\hspace{2em} \\vspace{1em} bloo}\n\\end{figure}"]
12+```
13+
14+Here block:
15+```
16+% pandoc -f markdown+raw_tex -t native
17+\begin{tabular}[t]{cc|c}
18+\(P\) & \(Q\) & \(P\wedge Q\)\\
19+\hline
20+T & T &\\
21+T & F &\\
22+F & T &\\
23+F & F &\\
24+\end{tabular}
25+\hspace{1em}
26+\begin{tabular}[t]{cc|c}
27+\(P\) & \(Q\) & \(P\vee Q\)\\
28+\hline
29+T & T &\\
30+T & F &\\
31+F & T &\\
32+F & F &\\
33+\end{tabular}
34+^D
35+[RawBlock (Format "latex") "\\begin{tabular}[t]{cc|c}\n\\(P\\) & \\(Q\\) & \\(P\\wedge Q\\)\\\\\n\\hline\nT & T &\\\\\nT & F &\\\\\nF & T &\\\\\nF & F &\\\\\n\\end{tabular}\\hspace{1em}\\begin{tabular}[t]{cc|c}\n\\(P\\) & \\(Q\\) & \\(P\\vee Q\\)\\\\\n\\hline\nT & T &\\\\\nT & F &\\\\\nF & T &\\\\\nF & F &\\\\\n\\end{tabular}"]
36+```
37+
38+```
39+% pandoc -f markdown+raw_tex -t native
40+hi\hspace{1em}there
41+^D
42+[Para [Str "hi",RawInline (Format "tex") "\\hspace{1em}",Str "there"]]
43+```
44+
45+```
46+% pandoc -f markdown+raw_tex -t native
47+hi
48+
49+\hspace{1em}
50+
51+there
52+^D
53+[Para [Str "hi"]
54+,RawBlock (Format "latex") "\\hspace{1em}"
55+,Para [Str "there"]]
56+```