git.iko.soy/typeable/pandoc
on master help sign in
Markdown reader: Use "tex" instead of "latex" for raw tex-ish content.

We can't always tell if it's LaTeX, ConTeXt, or plain TeX. Better just to use "tex" always. Also changed: ConTeXt writer: now outputs raw "tex" blocks as well as "context". (Closes #969). RST writer: uses ".. raw:: latex" for "tex" content. (RST doesn't support raw context anyway.) Note that if "context" or "latex" specifically is desired, you can still force that in a markdown document by using the raw attribute (see MANUAL.txt): ```{=latex} \foo ``` Note that this change may affect some filters, if they assume that raw tex parsed by the Markdown reader will be RawBlock (Format "latex"). In most cases it should be trivial to modify the filters to accept "tex" as well.

commit13dea94a9128a4caf3fb820bb21cd8176465c82e authorJohn MacFarlane <jgm@berkeley.edu> dateWed 15 Aug 2018, 10:25 (8 years ago) parent2ae8272
17 files changed+37−36
src/Text/Pandoc/Readers/Markdown.hs+3−7 src/Text/Pandoc/Writers/ConTeXt.hs+6−9 src/Text/Pandoc/Writers/RST.hs+1 test/command/3558.md+2−2 test/command/3804.md+1−1 test/command/3947.md+1−1 test/command/4056.md+1−1 test/command/4159.md+1−1 test/command/4781.md+1−1 test/command/adjacent_latex_blocks.md+2−2 test/command/hspace.md+3−3 test/command/write18.md+1−1 test/markdown-reader-more.native+5−4 test/testsuite.native+1−1 test/writer.context+6 test/writer.muse+1−1 test/writer.native+1−1
src/Text/Pandoc/Readers/Markdown.hs+3−7
@@ -1143,10 +1143,9 @@ rawTeXBlock :: PandocMonad m => MarkdownParser m (F Blocks)
11431143rawTeXBlock = do
11441144 guardEnabled Ext_raw_tex
11451145 lookAhead $ try $ char '\\' >> letter
1146− result <- (B.rawBlock "context" . trim . concat <$>
1147− many1 ((++) <$> (rawConTeXtEnvironment <|> conTeXtCommand)
1148− <*> spnl'))
1149− <|> (B.rawBlock "latex" . trim . concat <$>
1146+ result <- (B.rawBlock "tex" . trim . concat <$>
1147+ many1 ((++) <$> rawConTeXtEnvironment <*> spnl'))
1148+ <|> (B.rawBlock "tex" . trim . concat <$>
11501149 many1 ((++) <$> rawLaTeXBlock <*> spnl'))
11511150 return $ case B.toList result of
11521151 [RawBlock _ cs]
@@ -1154,9 +1153,6 @@ rawTeXBlock = do
11541153 -- don't create a raw block for suppressed macro defs
11551154 _ -> return result
11561155
1157−conTeXtCommand :: PandocMonad m => MarkdownParser m String
1158−conTeXtCommand = oneOfStrings ["\\placeformula"]
1159−
11601156rawHtmlBlocks :: PandocMonad m => MarkdownParser m (F Blocks)
11611157rawHtmlBlocks = do
11621158 (TagOpen tagtype _, raw) <- htmlTag isBlockTag
src/Text/Pandoc/Writers/ConTeXt.hs+6−9
@@ -190,10 +190,9 @@ blockToConTeXt (BlockQuote lst) = do
190190blockToConTeXt (CodeBlock _ str) =
191191 return $ flush ("\\starttyping" <> cr <> text str <> cr <> "\\stoptyping") $$ blankline
192192 -- blankline because \stoptyping can't have anything after it, inc. '}'
193−blockToConTeXt (RawBlock "context" str) = return $ text str <> blankline
194−blockToConTeXt b@(RawBlock _ _ ) = do
195− report $ BlockNotRendered b
196− return empty
193+blockToConTeXt b@(RawBlock f str)
194+ | f == Format "context" || f == Format "tex" = return $ text str <> blankline
195+ | otherwise = empty <$ report (BlockNotRendered b)
197196blockToConTeXt (Div (ident,_,kvs) bs) = do
198197 let align dir txt = "\\startalignment[" <> dir <> "]" $$ txt $$ "\\stopalignment"
199198 mblang <- fromBCP47 (lookup "lang" kvs)
@@ -401,11 +400,9 @@ inlineToConTeXt (Math InlineMath str) =
401400 return $ char '$' <> text str <> char '$'
402401inlineToConTeXt (Math DisplayMath str) =
403402 return $ text "\\startformula " <> text str <> text " \\stopformula" <> space
404−inlineToConTeXt (RawInline "context" str) = return $ text str
405−inlineToConTeXt (RawInline "tex" str) = return $ text str
406−inlineToConTeXt il@(RawInline _ _) = do
407− report $ InlineNotRendered il
408− return empty
403+inlineToConTeXt il@(RawInline f str)
404+ | f == Format "tex" || f == Format "context" = return $ text str
405+ | otherwise = empty <$ report (InlineNotRendered il)
409406inlineToConTeXt LineBreak = return $ text "\\crlf" <> cr
410407inlineToConTeXt SoftBreak = do
411408 wrapText <- gets (writerWrapText . stOptions)
src/Text/Pandoc/Writers/RST.hs+1
@@ -253,6 +253,7 @@ blockToRST (LineBlock lns) =
253253 linesToLineBlock lns
254254blockToRST (RawBlock f@(Format f') str)
255255 | f == "rst" = return $ text str
256+ | f == "tex" = blockToRST (RawBlock (Format "latex") str)
256257 | otherwise = return $ blankline <> ".. raw:: " <>
257258 text (map toLower f') $+$
258259 nest 3 (text str) $$ blankline
test/command/3558.md+2−2
@@ -6,7 +6,7 @@ hello
66
77\endmulti
88^D
9−[RawBlock (Format "latex") "\\multi"
9+[RawBlock (Format "tex") "\\multi"
1010,Para [Str "hello"]
11−,RawBlock (Format "latex") "\\endmulti"]
11+,RawBlock (Format "tex") "\\endmulti"]
1212```
test/command/3804.md+1−1
@@ -2,5 +2,5 @@
22% pandoc -t native
33\titleformat{\chapter}[display]{\normalfont\large\bfseries}{第\thechapter{}章}{20pt}{\Huge}
44^D
5−[RawBlock (Format "latex") "\\titleformat{\\chapter}[display]{\\normalfont\\large\\bfseries}{\31532\\thechapter{}\31456}{20pt}{\\Huge}"]
5+[RawBlock (Format "tex") "\\titleformat{\\chapter}[display]{\\normalfont\\large\\bfseries}{\31532\\thechapter{}\31456}{20pt}{\\Huge}"]
66```
test/command/3947.md+1−1
@@ -6,6 +6,6 @@
66
77 Another Code block
88^D
9−[RawBlock (Format "latex") "\\newpage"
9+[RawBlock (Format "tex") "\\newpage"
1010,CodeBlock ("",[],[]) "Code block\n\nAnother Code block"]
1111```
test/command/4056.md+1−1
@@ -5,7 +5,7 @@
55\end{shaded}
66}
77^D
8−[RawBlock (Format "latex") "\\parbox[t]{0.4\\textwidth}{\n\\begin{shaded}\n\\end{shaded}\n}"]
8+[RawBlock (Format "tex") "\\parbox[t]{0.4\\textwidth}{\n\\begin{shaded}\n\\end{shaded}\n}"]
99```
1010
1111```
test/command/4159.md+1−1
@@ -3,6 +3,6 @@
33\newcommand{\gen}{a\ Gen\ b}
44abc
55^D
6−[RawBlock (Format "latex") "\\newcommand{\\gen}{a\\ Gen\\ b}"
6+[RawBlock (Format "tex") "\\newcommand{\\gen}{a\\ Gen\\ b}"
77,Para [Str "abc"]]
88```
test/command/4781.md+1−1
@@ -7,7 +7,7 @@ Markdown parsed *here*
77*But not here*
88^D
99[Para [Str "Markdown",Space,Str "parsed",Space,Emph [Str "here"]]
10−,RawBlock (Format "latex") "\\include{command/bar}"
10+,RawBlock (Format "tex") "\\include{command/bar}"
1111,Para [Emph [Str "But",Space,Str "not",Space,Str "here"]]]
1212```
1313
test/command/adjacent_latex_blocks.md+2−2
@@ -4,6 +4,6 @@
44
55\listoftables
66^D
7−[RawBlock (Format "latex") "\\listoffigures"
8−,RawBlock (Format "latex") "\\listoftables"]
7+[RawBlock (Format "tex") "\\listoffigures"
8+,RawBlock (Format "tex") "\\listoftables"]
99```
test/command/hspace.md+3−3
@@ -8,7 +8,7 @@ Here they need to be inline:
88\caption{lalune \hspace{2em} \vspace{1em} bloo}
99\end{figure}
1010^D
11−[RawBlock (Format "latex") "\\begin{figure}\n\\includegraphics{lalune.jpg}\n\\caption{lalune \\hspace{2em} \\vspace{1em} bloo}\n\\end{figure}"]
11+[RawBlock (Format "tex") "\\begin{figure}\n\\includegraphics{lalune.jpg}\n\\caption{lalune \\hspace{2em} \\vspace{1em} bloo}\n\\end{figure}"]
1212```
1313
1414Here block:
@@ -32,7 +32,7 @@ F & T &\\
3232F & F &\\
3333\end{tabular}
3434^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}\n\\hspace{1em}\n\\begin{tabular}[t]{cc|c}\n\\(P\\) & \\(Q\\) & \\(P\\vee Q\\)\\\\\n\\hline\nT & T &\\\\\nT & F &\\\\\nF & T &\\\\\nF & F &\\\\\n\\end{tabular}"]
35+[RawBlock (Format "tex") "\\begin{tabular}[t]{cc|c}\n\\(P\\) & \\(Q\\) & \\(P\\wedge Q\\)\\\\\n\\hline\nT & T &\\\\\nT & F &\\\\\nF & T &\\\\\nF & F &\\\\\n\\end{tabular}\n\\hspace{1em}\n\\begin{tabular}[t]{cc|c}\n\\(P\\) & \\(Q\\) & \\(P\\vee Q\\)\\\\\n\\hline\nT & T &\\\\\nT & F &\\\\\nF & T &\\\\\nF & F &\\\\\n\\end{tabular}"]
3636```
3737
3838```
@@ -51,6 +51,6 @@ hi
5151there
5252^D
5353[Para [Str "hi"]
54−,RawBlock (Format "latex") "\\hspace{1em}"
54+,RawBlock (Format "tex") "\\hspace{1em}"
5555,Para [Str "there"]]
5656```
test/command/write18.md+1−1
@@ -3,7 +3,7 @@ Handle \write18{..} as raw tex:
33% pandoc -t native
44\write18{git --version}
55^D
6−[RawBlock (Format "latex") "\\write18{git --version}"]
6+[RawBlock (Format "tex") "\\write18{git --version}"]
77```
88
99```
test/markdown-reader-more.native+5−4
@@ -3,10 +3,11 @@ Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "Author",S
33,Header 2 ("blank-line-before-url-in-link-reference",[],[]) [Str "Blank",Space,Str "line",Space,Str "before",Space,Str "URL",Space,Str "in",Space,Str "link",Space,Str "reference"]
44,Para [Link ("",[],[]) [Str "foo"] ("/url",""),Space,Str "and",Space,Link ("",[],[]) [Str "bar"] ("/url","title")]
55,Header 2 ("raw-context-environments",[],[]) [Str "Raw",Space,Str "ConTeXt",Space,Str "environments"]
6−,RawBlock (Format "context") "\\placeformula \\startformula\n L_{1} = L_{2}\n \\stopformula"
7−,RawBlock (Format "context") "\\start[a2]\n\\start[a2]\n\\stop[a2]\n\\stop[a2]"
6+,RawBlock (Format "tex") "\\placeformula \\startformula"
7+,Para [Str "L_{1}",Space,Str "=",Space,Str "L_{2}",SoftBreak,RawInline (Format "tex") "\\stopformula"]
8+,RawBlock (Format "tex") "\\start[a2]\n\\start[a2]\n\\stop[a2]\n\\stop[a2]"
89,Header 2 ("raw-latex-environments",[],[]) [Str "Raw",Space,Str "LaTeX",Space,Str "environments"]
9−,RawBlock (Format "latex") "\\begin{center}\n\\begin{tikzpicture}[baseline={([yshift=+-.5ex]current bounding box.center)}, level distance=24pt]\n\\Tree [.{S} [.NP John\\index{i} ] [.VP [.V likes ] [.NP himself\\index{i,*j} ]]]\n\\end{tikzpicture}\n\\end{center}"
10+,RawBlock (Format "tex") "\\begin{center}\n\\begin{tikzpicture}[baseline={([yshift=+-.5ex]current bounding box.center)}, level distance=24pt]\n\\Tree [.{S} [.NP John\\index{i} ] [.VP [.V likes ] [.NP himself\\index{i,*j} ]]]\n\\end{tikzpicture}\n\\end{center}"
1011,Header 2 ("urls-with-spaces-and-punctuation",[],[]) [Str "URLs",Space,Str "with",Space,Str "spaces",Space,Str "and",Space,Str "punctuation"]
1112,Para [Link ("",[],[]) [Str "foo"] ("/bar%20and%20baz",""),SoftBreak,Link ("",[],[]) [Str "foo"] ("/bar%20and%20baz",""),SoftBreak,Link ("",[],[]) [Str "foo"] ("/bar%20and%20baz",""),SoftBreak,Link ("",[],[]) [Str "foo"] ("bar%20baz","title")]
1213,Para [Link ("",[],[]) [Str "baz"] ("/foo%20foo",""),Space,Link ("",[],[]) [Str "bam"] ("/foo%20fee",""),Space,Link ("",[],[]) [Str "bork"] ("/foo/zee%20zob","title")]
@@ -55,7 +56,7 @@ Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "Author",S
5556,OrderedList (3,Example,TwoParens)
5657 [[Plain [Str "Third",Space,Str "example."]]]
5758,Header 2 ("macros",[],[]) [Str "Macros"]
58−,RawBlock (Format "latex") "\\newcommand{\\tuple}[1]{\\langle #1 \\rangle}"
59+,RawBlock (Format "tex") "\\newcommand{\\tuple}[1]{\\langle #1 \\rangle}"
5960,Para [Math InlineMath "\\langle x,y \\rangle"]
6061,Header 2 ("case-insensitive-references",[],[]) [Str "Case-insensitive",Space,Str "references"]
6162,Para [Link ("",[],[]) [Str "Fum"] ("/fum","")]
test/testsuite.native+1−1
@@ -324,7 +324,7 @@ Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "John",Spa
324324 ,[Plain [Str "Shoes",Space,Str "($20)",Space,Str "and",Space,Str "socks",Space,Str "($5)."]]
325325 ,[Plain [Str "Escaped",Space,Code ("",[],[]) "$",Str ":",Space,Str "$73",Space,Emph [Str "this",Space,Str "should",Space,Str "be",Space,Str "emphasized"],Space,Str "23$."]]]
326326,Para [Str "Here\8217s",Space,Str "a",Space,Str "LaTeX",Space,Str "table:"]
327−,RawBlock (Format "latex") "\\begin{tabular}{|l|l|}\\hline\nAnimal & Number \\\\ \\hline\nDog & 2 \\\\\nCat & 1 \\\\ \\hline\n\\end{tabular}"
327+,RawBlock (Format "tex") "\\begin{tabular}{|l|l|}\\hline\nAnimal & Number \\\\ \\hline\nDog & 2 \\\\\nCat & 1 \\\\ \\hline\n\\end{tabular}"
328328,HorizontalRule
329329,Header 1 ("special-characters",[],[]) [Str "Special",Space,Str "Characters"]
330330,Para [Str "Here",Space,Str "is",Space,Str "some",Space,Str "unicode:"]
test/writer.context+6
@@ -706,6 +706,12 @@ These shouldn't be math:
706706
707707Here's a LaTeX table:
708708
709+\begin{tabular}{|l|l|}\hline
710+Animal & Number \\ \hline
711+Dog & 2 \\
712+Cat & 1 \\ \hline
713+\end{tabular}
714+
709715\thinrule
710716
711717\section[title={Special Characters},reference={special-characters}]
test/writer.muse+1−1
@@ -534,7 +534,7 @@ These shouldn’t be math:
534534
535535Here’s a LaTeX table:
536536
537−<literal style="latex">
537+<literal style="tex">
538538\begin{tabular}{|l|l|}\hline
539539Animal & Number \\ \hline
540540Dog & 2 \\
test/writer.native+1−1
@@ -324,7 +324,7 @@ Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "John",Spa
324324 ,[Plain [Str "Shoes",Space,Str "($20)",Space,Str "and",Space,Str "socks",Space,Str "($5)."]]
325325 ,[Plain [Str "Escaped",Space,Code ("",[],[]) "$",Str ":",Space,Str "$73",Space,Emph [Str "this",Space,Str "should",Space,Str "be",Space,Str "emphasized"],Space,Str "23$."]]]
326326,Para [Str "Here\8217s",Space,Str "a",Space,Str "LaTeX",Space,Str "table:"]
327−,RawBlock (Format "latex") "\\begin{tabular}{|l|l|}\\hline\nAnimal & Number \\\\ \\hline\nDog & 2 \\\\\nCat & 1 \\\\ \\hline\n\\end{tabular}"
327+,RawBlock (Format "tex") "\\begin{tabular}{|l|l|}\\hline\nAnimal & Number \\\\ \\hline\nDog & 2 \\\\\nCat & 1 \\\\ \\hline\n\\end{tabular}"
328328,HorizontalRule
329329,Header 1 ("special-characters",[],[]) [Str "Special",Space,Str "Characters"]
330330,Para [Str "Here",Space,Str "is",Space,Str "some",Space,Str "unicode:"]