Plain writer: don't use symbols for super/subscript.
Simplified code by using plainExtensions from Options. Closes #2237.
This commit is contained in:
parent
177533d3f8
commit
fce3ebb8e0
3 changed files with 14 additions and 18 deletions
|
@ -316,7 +316,7 @@ getDefaultExtensions "markdown_phpextra" = phpMarkdownExtraExtensions
|
|||
getDefaultExtensions "markdown_mmd" = multimarkdownExtensions
|
||||
getDefaultExtensions "markdown_github" = githubMarkdownExtensions
|
||||
getDefaultExtensions "markdown" = pandocExtensions
|
||||
getDefaultExtensions "plain" = pandocExtensions
|
||||
getDefaultExtensions "plain" = plainExtensions
|
||||
getDefaultExtensions "org" = Set.fromList [Ext_citations]
|
||||
getDefaultExtensions "textile" = Set.fromList [Ext_auto_identifiers]
|
||||
getDefaultExtensions "html" = Set.fromList [Ext_auto_identifiers,
|
||||
|
|
|
@ -79,17 +79,7 @@ writeMarkdown opts document =
|
|||
-- pictures, or inline formatting).
|
||||
writePlain :: WriterOptions -> Pandoc -> String
|
||||
writePlain opts document =
|
||||
evalState (pandocToMarkdown opts{
|
||||
writerExtensions = Set.delete Ext_escaped_line_breaks $
|
||||
Set.delete Ext_pipe_tables $
|
||||
Set.delete Ext_raw_html $
|
||||
Set.delete Ext_markdown_in_html_blocks $
|
||||
Set.delete Ext_raw_tex $
|
||||
Set.delete Ext_footnotes $
|
||||
Set.delete Ext_tex_math_dollars $
|
||||
Set.delete Ext_citations $
|
||||
writerExtensions opts }
|
||||
document) def{ stPlain = True }
|
||||
evalState (pandocToMarkdown opts document) def{ stPlain = True }
|
||||
|
||||
pandocTitleBlock :: Doc -> [Doc] -> Doc -> Doc
|
||||
pandocTitleBlock tit auths dat =
|
||||
|
@ -774,17 +764,23 @@ inlineToMarkdown opts (Strikeout lst) = do
|
|||
contents <- inlineListToMarkdown opts lst
|
||||
return $ if isEnabled Ext_strikeout opts
|
||||
then "~~" <> contents <> "~~"
|
||||
else "<s>" <> contents <> "</s>"
|
||||
else if isEnabled Ext_raw_html opts
|
||||
then "<s>" <> contents <> "</s>"
|
||||
else contents
|
||||
inlineToMarkdown opts (Superscript lst) = do
|
||||
contents <- inlineListToMarkdown opts $ walk escapeSpaces lst
|
||||
return $ if isEnabled Ext_superscript opts
|
||||
then "^" <> contents <> "^"
|
||||
else "<sup>" <> contents <> "</sup>"
|
||||
else if isEnabled Ext_raw_html opts
|
||||
then "<sup>" <> contents <> "</sup>"
|
||||
else contents
|
||||
inlineToMarkdown opts (Subscript lst) = do
|
||||
contents <- inlineListToMarkdown opts $ walk escapeSpaces lst
|
||||
return $ if isEnabled Ext_subscript opts
|
||||
then "~" <> contents <> "~"
|
||||
else "<sub>" <> contents <> "</sub>"
|
||||
else if isEnabled Ext_raw_html opts
|
||||
then "<sub>" <> contents <> "</sub>"
|
||||
else contents
|
||||
inlineToMarkdown opts (SmallCaps lst) = do
|
||||
plain <- gets stPlain
|
||||
if not plain &&
|
||||
|
|
|
@ -449,9 +449,9 @@ This is code: >, $, \, \$, <html>.
|
|||
|
||||
~~This is _strikeout_.~~
|
||||
|
||||
Superscripts: a^bc^d a^_hello_^ a^hello there^.
|
||||
Superscripts: abcd a_hello_ ahello there.
|
||||
|
||||
Subscripts: H~2~O, H~23~O, H~many of them~O.
|
||||
Subscripts: H2O, H23O, Hmany of themO.
|
||||
|
||||
These should not be superscripts or subscripts, because of the unescaped
|
||||
spaces: a^b c^d, a~b c~d.
|
||||
|
@ -494,7 +494,7 @@ LATEX
|
|||
- p-Tree
|
||||
- Here’s some display math:
|
||||
$$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$$
|
||||
- Here’s one that has a line break in it: α + ω × x^2^.
|
||||
- Here’s one that has a line break in it: α + ω × x2.
|
||||
|
||||
These shouldn’t be math:
|
||||
|
||||
|
|
Loading…
Reference in a new issue