Skip to content

Commit

Permalink
Implement implicit_figures extension for commonmark reader.
Browse files Browse the repository at this point in the history
Closes jgm#6350.
  • Loading branch information
jgm committed May 8, 2020
1 parent e7ac57d commit 8fc5766
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/Text/Pandoc/Extensions.hs
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@ getAllExtensions f = universalExtensions <> getAll f
extensionsFromList
[ Ext_raw_html
, Ext_raw_tex -- only supported in writer (for math)
, Ext_implicit_figures
, Ext_hard_line_breaks
, Ext_smart
]
Expand Down
7 changes: 6 additions & 1 deletion src/Text/Pandoc/Readers/CommonMark.hs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,12 @@ addBlocks opts = foldr (addBlock opts) []

addBlock :: ReaderOptions -> Node -> [Block] -> [Block]
addBlock opts (Node _ PARAGRAPH nodes) =
(Para (addInlines opts nodes) :)
case addInlines opts nodes of
[Image attr alt (src,tit)]
| isEnabled Ext_implicit_figures opts
-- the "fig:" prefix indicates an implicit figure
-> (Para [Image attr alt (src, "fig:" <> tit)] :)
ils -> (Para ils :)
addBlock _ (Node _ THEMATIC_BREAK _) =
(HorizontalRule :)
addBlock opts (Node _ BLOCK_QUOTE nodes) =
Expand Down

0 comments on commit 8fc5766

Please sign in to comment.