diff options
| author | John MacFarlane <jgm@berkeley.edu> | 2023-06-19 11:15:49 -0700 |
|---|---|---|
| committer | John MacFarlane <jgm@berkeley.edu> | 2023-06-19 11:18:30 -0700 |
| commit | 725ec09a104d8ad486989f32a4c55d9d731629ea (patch) | |
| tree | 50396bdf1a3bc11e898b9bffe2d0b494005768d8 /src/Text | |
| parent | 3a20ea3aca5891d9c2b6d9d0a301cff286602ae6 (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/Text')
| -rw-r--r-- | src/Text/Pandoc/Readers/CommonMark.hs | 10 |
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) <$> |
