aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2020-05-08 07:56:39 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2020-05-08 07:56:54 -0700
commit8fc57664f88c2f8cc006d19f662b1f40927b83ec (patch)
tree2a36e46bec13a422ea73d2448522986945dbe772 /src
parente7ac57d04cfddb58f3f9cf243f5e0e75eeb05747 (diff)
downloadpandoc-8fc57664f88c2f8cc006d19f662b1f40927b83ec.tar.gz
Implement implicit_figures extension for commonmark reader.
Closes #6350.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Extensions.hs1
-rw-r--r--src/Text/Pandoc/Readers/CommonMark.hs7
2 files changed, 7 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Extensions.hs b/src/Text/Pandoc/Extensions.hs
index 1db1a6545..e33a59e37 100644
--- a/src/Text/Pandoc/Extensions.hs
+++ b/src/Text/Pandoc/Extensions.hs
@@ -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
]
diff --git a/src/Text/Pandoc/Readers/CommonMark.hs b/src/Text/Pandoc/Readers/CommonMark.hs
index d1f732bf1..c63ea6392 100644
--- a/src/Text/Pandoc/Readers/CommonMark.hs
+++ b/src/Text/Pandoc/Readers/CommonMark.hs
@@ -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) =