Markdown reader: improved raw tex parsing.
+ Preserve original whitespace between blocks. + Recognize `\placeformula` as context.
This commit is contained in:
parent
3679d8d0bd
commit
4a07977715
3 changed files with 11 additions and 10 deletions
|
@ -1120,14 +1120,17 @@ rawVerbatimBlock = htmlInBalanced isVerbTag
|
|||
rawTeXBlock :: PandocMonad m => MarkdownParser m (F Blocks)
|
||||
rawTeXBlock = do
|
||||
guardEnabled Ext_raw_tex
|
||||
result <- (B.rawBlock "context" . concat <$>
|
||||
rawConTeXtEnvironment `sepEndBy1` blankline)
|
||||
<|> (B.rawBlock "latex" . concat <$>
|
||||
rawLaTeXBlock `sepEndBy1` blankline)
|
||||
|
||||
optional blanklines
|
||||
result <- (B.rawBlock "context" . trimr . concat <$>
|
||||
many1 ((++) <$> (rawConTeXtEnvironment <|> conTeXtCommand)
|
||||
<*> (blanklines <|> many spaceChar)))
|
||||
<|> (B.rawBlock "latex" . trimr . concat <$>
|
||||
many1 ((++) <$> rawLaTeXBlock
|
||||
<*> (blanklines <|> many spaceChar)))
|
||||
return $ 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
|
||||
|
|
|
@ -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}\\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}"]
|
||||
[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}"]
|
||||
```
|
||||
|
||||
```
|
||||
|
|
|
@ -3,9 +3,7 @@ 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 "latex") "\\placeformula "
|
||||
,RawBlock (Format "context") "\\startformula\n L_{1} = L_{2}\n \\stopformula"
|
||||
,RawBlock (Format "context") "\\start[a2]\n\\start[a2]\n\\stop[a2]\n\\stop[a2]"
|
||||
,RawBlock (Format "context") "\\placeformula \\startformula\n L_{1} = L_{2}\n \\stopformula\n\n\\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}"
|
||||
,Header 2 ("urls-with-spaces-and-punctuation",[],[]) [Str "URLs",Space,Str "with",Space,Str "spaces",Space,Str "and",Space,Str "punctuation"]
|
||||
|
|
Loading…
Reference in a new issue