diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index c4e8a6524..a81942a9e 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -1143,10 +1143,9 @@ rawTeXBlock :: PandocMonad m => MarkdownParser m (F Blocks) rawTeXBlock = do guardEnabled Ext_raw_tex lookAhead $ try $ char '\\' >> letter - result <- (B.rawBlock "context" . trim . concat <$> - many1 ((++) <$> (rawConTeXtEnvironment <|> conTeXtCommand) - <*> spnl')) - <|> (B.rawBlock "latex" . trim . concat <$> + result <- (B.rawBlock "tex" . trim . concat <$> + many1 ((++) <$> rawConTeXtEnvironment <*> spnl')) + <|> (B.rawBlock "tex" . trim . concat <$> many1 ((++) <$> rawLaTeXBlock <*> spnl')) return $ case B.toList result of [RawBlock _ cs] @@ -1154,9 +1153,6 @@ rawTeXBlock = do -- don't create a raw block for suppressed macro defs _ -> return result -conTeXtCommand :: PandocMonad m => MarkdownParser m String -conTeXtCommand = oneOfStrings ["\\placeformula"] - rawHtmlBlocks :: PandocMonad m => MarkdownParser m (F Blocks) rawHtmlBlocks = do (TagOpen tagtype _, raw) <- htmlTag isBlockTag diff --git a/src/Text/Pandoc/Writers/ConTeXt.hs b/src/Text/Pandoc/Writers/ConTeXt.hs index 10e996bdb..594812294 100644 --- a/src/Text/Pandoc/Writers/ConTeXt.hs +++ b/src/Text/Pandoc/Writers/ConTeXt.hs @@ -190,10 +190,9 @@ blockToConTeXt (BlockQuote lst) = do blockToConTeXt (CodeBlock _ str) = return $ flush ("\\starttyping" <> cr <> text str <> cr <> "\\stoptyping") $$ blankline -- blankline because \stoptyping can't have anything after it, inc. '}' -blockToConTeXt (RawBlock "context" str) = return $ text str <> blankline -blockToConTeXt b@(RawBlock _ _ ) = do - report $ BlockNotRendered b - return empty +blockToConTeXt b@(RawBlock f str) + | f == Format "context" || f == Format "tex" = return $ text str <> blankline + | otherwise = empty <$ report (BlockNotRendered b) blockToConTeXt (Div (ident,_,kvs) bs) = do let align dir txt = "\\startalignment[" <> dir <> "]" $$ txt $$ "\\stopalignment" mblang <- fromBCP47 (lookup "lang" kvs) @@ -401,11 +400,9 @@ inlineToConTeXt (Math InlineMath str) = return $ char '$' <> text str <> char '$' inlineToConTeXt (Math DisplayMath str) = return $ text "\\startformula " <> text str <> text " \\stopformula" <> space -inlineToConTeXt (RawInline "context" str) = return $ text str -inlineToConTeXt (RawInline "tex" str) = return $ text str -inlineToConTeXt il@(RawInline _ _) = do - report $ InlineNotRendered il - return empty +inlineToConTeXt il@(RawInline f str) + | f == Format "tex" || f == Format "context" = return $ text str + | otherwise = empty <$ report (InlineNotRendered il) inlineToConTeXt LineBreak = return $ text "\\crlf" <> cr inlineToConTeXt SoftBreak = do wrapText <- gets (writerWrapText . stOptions) diff --git a/src/Text/Pandoc/Writers/RST.hs b/src/Text/Pandoc/Writers/RST.hs index 005db5e77..b416eca59 100644 --- a/src/Text/Pandoc/Writers/RST.hs +++ b/src/Text/Pandoc/Writers/RST.hs @@ -253,6 +253,7 @@ blockToRST (LineBlock lns) = linesToLineBlock lns blockToRST (RawBlock f@(Format f') str) | f == "rst" = return $ text str + | f == "tex" = blockToRST (RawBlock (Format "latex") str) | otherwise = return $ blankline <> ".. raw:: " <> text (map toLower f') $+$ nest 3 (text str) $$ blankline diff --git a/test/command/3558.md b/test/command/3558.md index 795858b78..956b09e57 100644 --- a/test/command/3558.md +++ b/test/command/3558.md @@ -6,7 +6,7 @@ hello \endmulti ^D -[RawBlock (Format "latex") "\\multi" +[RawBlock (Format "tex") "\\multi" ,Para [Str "hello"] -,RawBlock (Format "latex") "\\endmulti"] +,RawBlock (Format "tex") "\\endmulti"] ``` diff --git a/test/command/3804.md b/test/command/3804.md index c13c2ef42..520d408df 100644 --- a/test/command/3804.md +++ b/test/command/3804.md @@ -2,5 +2,5 @@ % pandoc -t native \titleformat{\chapter}[display]{\normalfont\large\bfseries}{第\thechapter{}章}{20pt}{\Huge} ^D -[RawBlock (Format "latex") "\\titleformat{\\chapter}[display]{\\normalfont\\large\\bfseries}{\31532\\thechapter{}\31456}{20pt}{\\Huge}"] +[RawBlock (Format "tex") "\\titleformat{\\chapter}[display]{\\normalfont\\large\\bfseries}{\31532\\thechapter{}\31456}{20pt}{\\Huge}"] ``` diff --git a/test/command/3947.md b/test/command/3947.md index 7ce0be171..b1d695fbd 100644 --- a/test/command/3947.md +++ b/test/command/3947.md @@ -6,6 +6,6 @@ Another Code block ^D -[RawBlock (Format "latex") "\\newpage" +[RawBlock (Format "tex") "\\newpage" ,CodeBlock ("",[],[]) "Code block\n\nAnother Code block"] ``` diff --git a/test/command/4056.md b/test/command/4056.md index eed4f6d6a..e972931dd 100644 --- a/test/command/4056.md +++ b/test/command/4056.md @@ -5,7 +5,7 @@ \end{shaded} } ^D -[RawBlock (Format "latex") "\\parbox[t]{0.4\\textwidth}{\n\\begin{shaded}\n\\end{shaded}\n}"] +[RawBlock (Format "tex") "\\parbox[t]{0.4\\textwidth}{\n\\begin{shaded}\n\\end{shaded}\n}"] ``` ``` diff --git a/test/command/4159.md b/test/command/4159.md index 4881edcc5..d61959950 100644 --- a/test/command/4159.md +++ b/test/command/4159.md @@ -3,6 +3,6 @@ \newcommand{\gen}{a\ Gen\ b} abc ^D -[RawBlock (Format "latex") "\\newcommand{\\gen}{a\\ Gen\\ b}" +[RawBlock (Format "tex") "\\newcommand{\\gen}{a\\ Gen\\ b}" ,Para [Str "abc"]] ``` diff --git a/test/command/4781.md b/test/command/4781.md index 7dc973c7c..8a75e09a0 100644 --- a/test/command/4781.md +++ b/test/command/4781.md @@ -7,7 +7,7 @@ Markdown parsed *here* *But not here* ^D [Para [Str "Markdown",Space,Str "parsed",Space,Emph [Str "here"]] -,RawBlock (Format "latex") "\\include{command/bar}" +,RawBlock (Format "tex") "\\include{command/bar}" ,Para [Emph [Str "But",Space,Str "not",Space,Str "here"]]] ``` diff --git a/test/command/adjacent_latex_blocks.md b/test/command/adjacent_latex_blocks.md index 3e72f1d4f..e7dc6d895 100644 --- a/test/command/adjacent_latex_blocks.md +++ b/test/command/adjacent_latex_blocks.md @@ -4,6 +4,6 @@ \listoftables ^D -[RawBlock (Format "latex") "\\listoffigures" -,RawBlock (Format "latex") "\\listoftables"] +[RawBlock (Format "tex") "\\listoffigures" +,RawBlock (Format "tex") "\\listoftables"] ``` diff --git a/test/command/hspace.md b/test/command/hspace.md index ec1669ca5..a8b97b8bc 100644 --- a/test/command/hspace.md +++ b/test/command/hspace.md @@ -8,7 +8,7 @@ Here they need to be inline: \caption{lalune \hspace{2em} \vspace{1em} bloo} \end{figure} ^D -[RawBlock (Format "latex") "\\begin{figure}\n\\includegraphics{lalune.jpg}\n\\caption{lalune \\hspace{2em} \\vspace{1em} bloo}\n\\end{figure}"] +[RawBlock (Format "tex") "\\begin{figure}\n\\includegraphics{lalune.jpg}\n\\caption{lalune \\hspace{2em} \\vspace{1em} bloo}\n\\end{figure}"] ``` Here block: @@ -32,7 +32,7 @@ F & T &\\ F & F &\\ \end{tabular} ^D -[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}"] +[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}"] ``` ``` @@ -51,6 +51,6 @@ hi there ^D [Para [Str "hi"] -,RawBlock (Format "latex") "\\hspace{1em}" +,RawBlock (Format "tex") "\\hspace{1em}" ,Para [Str "there"]] ``` diff --git a/test/command/write18.md b/test/command/write18.md index 344dfc8cf..5000c298b 100644 --- a/test/command/write18.md +++ b/test/command/write18.md @@ -3,7 +3,7 @@ Handle \write18{..} as raw tex: % pandoc -t native \write18{git --version} ^D -[RawBlock (Format "latex") "\\write18{git --version}"] +[RawBlock (Format "tex") "\\write18{git --version}"] ``` ``` diff --git a/test/markdown-reader-more.native b/test/markdown-reader-more.native index 17e91bb89..799f4ffa7 100644 --- a/test/markdown-reader-more.native +++ b/test/markdown-reader-more.native @@ -3,10 +3,11 @@ Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "Author",S ,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"] ,Para [Link ("",[],[]) [Str "foo"] ("/url",""),Space,Str "and",Space,Link ("",[],[]) [Str "bar"] ("/url","title")] ,Header 2 ("raw-context-environments",[],[]) [Str "Raw",Space,Str "ConTeXt",Space,Str "environments"] -,RawBlock (Format "context") "\\placeformula \\startformula\n L_{1} = L_{2}\n \\stopformula" -,RawBlock (Format "context") "\\start[a2]\n\\start[a2]\n\\stop[a2]\n\\stop[a2]" +,RawBlock (Format "tex") "\\placeformula \\startformula" +,Para [Str "L_{1}",Space,Str "=",Space,Str "L_{2}",SoftBreak,RawInline (Format "tex") "\\stopformula"] +,RawBlock (Format "tex") "\\start[a2]\n\\start[a2]\n\\stop[a2]\n\\stop[a2]" ,Header 2 ("raw-latex-environments",[],[]) [Str "Raw",Space,Str "LaTeX",Space,Str "environments"] -,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}" +,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}" ,Header 2 ("urls-with-spaces-and-punctuation",[],[]) [Str "URLs",Space,Str "with",Space,Str "spaces",Space,Str "and",Space,Str "punctuation"] ,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")] ,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 ,OrderedList (3,Example,TwoParens) [[Plain [Str "Third",Space,Str "example."]]] ,Header 2 ("macros",[],[]) [Str "Macros"] -,RawBlock (Format "latex") "\\newcommand{\\tuple}[1]{\\langle #1 \\rangle}" +,RawBlock (Format "tex") "\\newcommand{\\tuple}[1]{\\langle #1 \\rangle}" ,Para [Math InlineMath "\\langle x,y \\rangle"] ,Header 2 ("case-insensitive-references",[],[]) [Str "Case-insensitive",Space,Str "references"] ,Para [Link ("",[],[]) [Str "Fum"] ("/fum","")] diff --git a/test/testsuite.native b/test/testsuite.native index 0587bddb8..fcd189eb0 100644 --- a/test/testsuite.native +++ b/test/testsuite.native @@ -324,7 +324,7 @@ Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "John",Spa ,[Plain [Str "Shoes",Space,Str "($20)",Space,Str "and",Space,Str "socks",Space,Str "($5)."]] ,[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$."]]] ,Para [Str "Here\8217s",Space,Str "a",Space,Str "LaTeX",Space,Str "table:"] -,RawBlock (Format "latex") "\\begin{tabular}{|l|l|}\\hline\nAnimal & Number \\\\ \\hline\nDog & 2 \\\\\nCat & 1 \\\\ \\hline\n\\end{tabular}" +,RawBlock (Format "tex") "\\begin{tabular}{|l|l|}\\hline\nAnimal & Number \\\\ \\hline\nDog & 2 \\\\\nCat & 1 \\\\ \\hline\n\\end{tabular}" ,HorizontalRule ,Header 1 ("special-characters",[],[]) [Str "Special",Space,Str "Characters"] ,Para [Str "Here",Space,Str "is",Space,Str "some",Space,Str "unicode:"] diff --git a/test/writer.context b/test/writer.context index bb69f4e43..d6a36f0dd 100644 --- a/test/writer.context +++ b/test/writer.context @@ -706,6 +706,12 @@ These shouldn't be math: Here's a LaTeX table: +\begin{tabular}{|l|l|}\hline +Animal & Number \\ \hline +Dog & 2 \\ +Cat & 1 \\ \hline +\end{tabular} + \thinrule \section[title={Special Characters},reference={special-characters}] diff --git a/test/writer.muse b/test/writer.muse index 9492a5517..5993ec357 100644 --- a/test/writer.muse +++ b/test/writer.muse @@ -534,7 +534,7 @@ These shouldn’t be math: Here’s a LaTeX table: - + \begin{tabular}{|l|l|}\hline Animal & Number \\ \hline Dog & 2 \\ diff --git a/test/writer.native b/test/writer.native index 0587bddb8..fcd189eb0 100644 --- a/test/writer.native +++ b/test/writer.native @@ -324,7 +324,7 @@ Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "John",Spa ,[Plain [Str "Shoes",Space,Str "($20)",Space,Str "and",Space,Str "socks",Space,Str "($5)."]] ,[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$."]]] ,Para [Str "Here\8217s",Space,Str "a",Space,Str "LaTeX",Space,Str "table:"] -,RawBlock (Format "latex") "\\begin{tabular}{|l|l|}\\hline\nAnimal & Number \\\\ \\hline\nDog & 2 \\\\\nCat & 1 \\\\ \\hline\n\\end{tabular}" +,RawBlock (Format "tex") "\\begin{tabular}{|l|l|}\\hline\nAnimal & Number \\\\ \\hline\nDog & 2 \\\\\nCat & 1 \\\\ \\hline\n\\end{tabular}" ,HorizontalRule ,Header 1 ("special-characters",[],[]) [Str "Special",Space,Str "Characters"] ,Para [Str "Here",Space,Str "is",Space,Str "some",Space,Str "unicode:"]