git.iko.soy/typeable/pandoc
on master help sign in
Plain writer: don't use symbols for super/subscript.

Simplified code by using plainExtensions from Options. Closes #2237.

commitfce3ebb8e023d0f9fd5756503e9264b05571b75a authorJohn MacFarlane <jgm@berkeley.edu> dateSat 27 Jun 2015, 20:18 (11 years ago) parent177533d
3 files changed+14−18
src/Text/Pandoc.hs+1−1 src/Text/Pandoc/Writers/Markdown.hs+10−14 tests/writer.plain+3−3
src/Text/Pandoc.hs+1−1
@@ -316,7 +316,7 @@ getDefaultExtensions "markdown_phpextra" = phpMarkdownExtraExtensions
316316getDefaultExtensions "markdown_mmd" = multimarkdownExtensions
317317getDefaultExtensions "markdown_github" = githubMarkdownExtensions
318318getDefaultExtensions "markdown" = pandocExtensions
319−getDefaultExtensions "plain" = pandocExtensions
319+getDefaultExtensions "plain" = plainExtensions
320320getDefaultExtensions "org" = Set.fromList [Ext_citations]
321321getDefaultExtensions "textile" = Set.fromList [Ext_auto_identifiers]
322322getDefaultExtensions "html" = Set.fromList [Ext_auto_identifiers,
src/Text/Pandoc/Writers/Markdown.hs+10−14
@@ -79,17 +79,7 @@ writeMarkdown opts document =
7979-- pictures, or inline formatting).
8080writePlain :: WriterOptions -> Pandoc -> String
8181writePlain opts document =
82− evalState (pandocToMarkdown opts{
83− writerExtensions = Set.delete Ext_escaped_line_breaks $
84− Set.delete Ext_pipe_tables $
85− Set.delete Ext_raw_html $
86− Set.delete Ext_markdown_in_html_blocks $
87− Set.delete Ext_raw_tex $
88− Set.delete Ext_footnotes $
89− Set.delete Ext_tex_math_dollars $
90− Set.delete Ext_citations $
91− writerExtensions opts }
92− document) def{ stPlain = True }
82+ evalState (pandocToMarkdown opts document) def{ stPlain = True }
9383
9484pandocTitleBlock :: Doc -> [Doc] -> Doc -> Doc
9585pandocTitleBlock tit auths dat =
@@ -774,17 +764,23 @@ inlineToMarkdown opts (Strikeout lst) = do
774764 contents <- inlineListToMarkdown opts lst
775765 return $ if isEnabled Ext_strikeout opts
776766 then "~~" <> contents <> "~~"
777− else "<s>" <> contents <> "</s>"
767+ else if isEnabled Ext_raw_html opts
768+ then "<s>" <> contents <> "</s>"
769+ else contents
778770inlineToMarkdown opts (Superscript lst) = do
779771 contents <- inlineListToMarkdown opts $ walk escapeSpaces lst
780772 return $ if isEnabled Ext_superscript opts
781773 then "^" <> contents <> "^"
782− else "<sup>" <> contents <> "</sup>"
774+ else if isEnabled Ext_raw_html opts
775+ then "<sup>" <> contents <> "</sup>"
776+ else contents
783777inlineToMarkdown opts (Subscript lst) = do
784778 contents <- inlineListToMarkdown opts $ walk escapeSpaces lst
785779 return $ if isEnabled Ext_subscript opts
786780 then "~" <> contents <> "~"
787− else "<sub>" <> contents <> "</sub>"
781+ else if isEnabled Ext_raw_html opts
782+ then "<sub>" <> contents <> "</sub>"
783+ else contents
788784inlineToMarkdown opts (SmallCaps lst) = do
789785 plain <- gets stPlain
790786 if not plain &&
tests/writer.plain+3−3
@@ -449,9 +449,9 @@ This is code: >, $, \, \$, <html>.
449449
450450~~This is _strikeout_.~~
451451
452−Superscripts: a^bc^d a^_hello_^ a^hello there^.
452+Superscripts: abcd a_hello_ ahello there.
453453
454−Subscripts: H~2~O, H~23~O, H~many of them~O.
454+Subscripts: H2O, H23O, Hmany of themO.
455455
456456These should not be superscripts or subscripts, because of the unescaped
457457spaces: a^b c^d, a~b c~d.
@@ -494,7 +494,7 @@ LATEX
494494- p-Tree
495495- Here’s some display math:
496496 $$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$$
497−- Here’s one that has a line break in it: α + ω × x^2^.
497+- Here’s one that has a line break in it: α + ω × x2.
498498
499499These shouldn’t be math:
500500