git.iko.soy/typeable/pandoc
on master help sign in
Commonmark reader: add pipe_table extension after defaults.

Otherwise we get bad results for non-table, non-paragraph lines containing pipe characters. Closes #6739. See also jgm/commonmark-hs#52.

commit12ff835a8a8eeb374fb2992315c932809991fa63 authorJohn MacFarlane <jgm@berkeley.edu> dateMon 12 Oct 2020, 21:24 (6 years ago) parent2007cff
2 files changed+43−21
src/Text/Pandoc/Readers/CommonMark.hs+22−21 test/command/6739.md+21
src/Text/Pandoc/Readers/CommonMark.hs+22−21
@@ -32,34 +32,35 @@ import Data.Functor.Identity (runIdentity)
3232readCommonMark :: PandocMonad m => ReaderOptions -> Text -> m Pandoc
3333readCommonMark opts s = do
3434 let res = runIdentity $
35− commonmarkWith (foldr (<>) defaultSyntaxSpec exts) "input" s
35+ commonmarkWith (foldr ($) defaultSyntaxSpec exts) "input" s
3636 case res of
3737 Left err -> throwError $ PandocParsecError s err
3838 Right (Cm bls :: Cm () Blocks) -> return $ B.doc bls
3939 where
40− exts = [ hardLineBreaksSpec | isEnabled Ext_hard_line_breaks opts ] ++
41− [ smartPunctuationSpec | isEnabled Ext_smart opts ] ++
42− [ strikethroughSpec | isEnabled Ext_strikeout opts ] ++
43− [ superscriptSpec | isEnabled Ext_superscript opts ] ++
44− [ subscriptSpec | isEnabled Ext_subscript opts ] ++
45− [ mathSpec | isEnabled Ext_tex_math_dollars opts ] ++
46− [ fancyListSpec | isEnabled Ext_fancy_lists opts ] ++
47− [ fencedDivSpec | isEnabled Ext_fenced_divs opts ] ++
48− [ bracketedSpanSpec | isEnabled Ext_bracketed_spans opts ] ++
49− [ rawAttributeSpec | isEnabled Ext_raw_attribute opts ] ++
50− [ attributesSpec | isEnabled Ext_attributes opts ] ++
51− [ pipeTableSpec | isEnabled Ext_pipe_tables opts ] ++
52− [ autolinkSpec | isEnabled Ext_autolink_bare_uris opts ] ++
53− [ emojiSpec | isEnabled Ext_emoji opts ] ++
54− [ autoIdentifiersSpec
40+ exts = [ (hardLineBreaksSpec <>) | isEnabled Ext_hard_line_breaks opts ] ++
41+ [ (smartPunctuationSpec <>) | isEnabled Ext_smart opts ] ++
42+ [ (strikethroughSpec <>) | isEnabled Ext_strikeout opts ] ++
43+ [ (superscriptSpec <>) | isEnabled Ext_superscript opts ] ++
44+ [ (subscriptSpec <>) | isEnabled Ext_subscript opts ] ++
45+ [ (mathSpec <>) | isEnabled Ext_tex_math_dollars opts ] ++
46+ [ (fancyListSpec <>) | isEnabled Ext_fancy_lists opts ] ++
47+ [ (fencedDivSpec <>) | isEnabled Ext_fenced_divs opts ] ++
48+ [ (bracketedSpanSpec <>) | isEnabled Ext_bracketed_spans opts ] ++
49+ [ (rawAttributeSpec <>) | isEnabled Ext_raw_attribute opts ] ++
50+ [ (attributesSpec <>) | isEnabled Ext_attributes opts ] ++
51+ [ (<> pipeTableSpec) | isEnabled Ext_pipe_tables opts ] ++
52+ -- see #6739
53+ [ (autolinkSpec <>) | isEnabled Ext_autolink_bare_uris opts ] ++
54+ [ (emojiSpec <>) | isEnabled Ext_emoji opts ] ++
55+ [ (autoIdentifiersSpec <>)
5556 | isEnabled Ext_gfm_auto_identifiers opts
5657 , not (isEnabled Ext_ascii_identifiers opts) ] ++
57− [ autoIdentifiersAsciiSpec
58+ [ (autoIdentifiersAsciiSpec <>)
5859 | isEnabled Ext_gfm_auto_identifiers opts
5960 , isEnabled Ext_ascii_identifiers opts ] ++
60− [ implicitHeadingReferencesSpec
61+ [ (implicitHeadingReferencesSpec <>)
6162 | isEnabled Ext_implicit_header_references opts ] ++
62− [ footnoteSpec | isEnabled Ext_footnotes opts ] ++
63− [ definitionListSpec | isEnabled Ext_definition_lists opts ] ++
64− [ taskListSpec | isEnabled Ext_task_lists opts ]
63+ [ (footnoteSpec <>) | isEnabled Ext_footnotes opts ] ++
64+ [ (definitionListSpec <>) | isEnabled Ext_definition_lists opts ] ++
65+ [ (taskListSpec <>) | isEnabled Ext_task_lists opts ]
6566
test/command/6739.mdnew file+21
@@ -0,0 +1,21 @@
1+```
2+% pandoc -f gfm
3+* `--argument` This item does not have a pipe character
4+* `--argA | --argB` This item has a pipe character
5+^D
6+<ul>
7+<li><code>--argument</code> This item does not have a pipe character</li>
8+<li><code>--argA | --argB</code> This item has a pipe character</li>
9+</ul>
10+```
11+
12+```
13+% pandoc --mathjax -f gfm+tex_math_dollars
14+* $|x|$
15+* $|y|$
16+^D
17+<ul>
18+<li><span class="math inline">\(|x|\)</span></li>
19+<li><span class="math inline">\(|y|\)</span></li>
20+</ul>
21+```