git.iko.soy/typeable/pandoc
on master help sign in
Implement implicit_figures extension for commonmark reader.

Closes #6350.

commit8fc57664f88c2f8cc006d19f662b1f40927b83ec authorJohn MacFarlane <jgm@berkeley.edu> dateFri 8 May 2020, 07:56 (6 years ago) parente7ac57d
2 files changed+7−1
src/Text/Pandoc/Extensions.hs+1 src/Text/Pandoc/Readers/CommonMark.hs+6−1
src/Text/Pandoc/Extensions.hs+1
@@ -435,6 +435,7 @@ getAllExtensions f = universalExtensions <> getAll f
435435 extensionsFromList
436436 [ Ext_raw_html
437437 , Ext_raw_tex -- only supported in writer (for math)
438+ , Ext_implicit_figures
438439 , Ext_hard_line_breaks
439440 , Ext_smart
440441 ]
src/Text/Pandoc/Readers/CommonMark.hs+6−1
@@ -76,7 +76,12 @@ addBlocks opts = foldr (addBlock opts) []
7676
7777addBlock :: ReaderOptions -> Node -> [Block] -> [Block]
7878addBlock opts (Node _ PARAGRAPH nodes) =
79− (Para (addInlines opts nodes) :)
79+ case addInlines opts nodes of
80+ [Image attr alt (src,tit)]
81+ | isEnabled Ext_implicit_figures opts
82+ -- the "fig:" prefix indicates an implicit figure
83+ -> (Para [Image attr alt (src, "fig:" <> tit)] :)
84+ ils -> (Para ils :)
8085addBlock _ (Node _ THEMATIC_BREAK _) =
8186 (HorizontalRule :)
8287addBlock opts (Node _ BLOCK_QUOTE nodes) =