summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2023-06-19 11:15:49 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2023-06-19 11:18:30 -0700
commit725ec09a104d8ad486989f32a4c55d9d731629ea (patch)
tree50396bdf1a3bc11e898b9bffe2d0b494005768d8 /src
parent3a20ea3aca5891d9c2b6d9d0a301cff286602ae6 (diff)
Make `implicit_figures` work again in commonmark reader.
Support for this (introduced in #6350) disappeared when we made an architectural change.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Readers/CommonMark.hs10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/Text/Pandoc/Readers/CommonMark.hs b/src/Text/Pandoc/Readers/CommonMark.hs
index 6f1e270ba..647791bf5 100644
--- a/src/Text/Pandoc/Readers/CommonMark.hs
+++ b/src/Text/Pandoc/Readers/CommonMark.hs
@@ -71,6 +71,13 @@ readCommonMark opts s
let toks = concatMap sourceToToks (unSources sources)
readCommonMarkBody opts sources toks
+makeFigures :: Block -> Block
+makeFigures (Para [Image (ident,classes,kvs) alt (src,tit)]) =
+ Figure (ident,[],[])
+ (Caption Nothing [Plain alt])
+ [Plain [Image ("",classes,kvs) alt (src,tit)]]
+makeFigures b = b
+
sourceToToks :: (SourcePos, Text) -> [Tok]
sourceToToks (pos, s) = map adjust $ tokenize (sourceName pos) s
where
@@ -91,6 +98,9 @@ metaValueParser opts = do
readCommonMarkBody :: PandocMonad m => ReaderOptions -> Sources -> [Tok] -> m Pandoc
readCommonMarkBody opts s toks =
+ (if isEnabled Ext_implicit_figures opts
+ then walk makeFigures
+ else id) .
(if readerStripComments opts
then walk stripBlockComments . walk stripInlineComments
else id) <$>