aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2018-05-30 09:24:52 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2018-05-30 09:24:52 -0700
commit252ab9b77323230fa58e3b877101b061d77f673c (patch)
tree25615912841442661ffaf0318080b7d23a4f60b8 /src/Text
parent1100bfc0e67954760c0c1767018404bf0129dd01 (diff)
downloadpandoc-252ab9b77323230fa58e3b877101b061d77f673c.tar.gz
Markdown writer: preserve `implicit_figures` with attributes...
...even if `implicit_attributes` is not set, by rendering in raw HTML. Fixes #4677.
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Writers/Markdown.hs16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs
index 075858e5e..fe8f452d3 100644
--- a/src/Text/Pandoc/Writers/Markdown.hs
+++ b/src/Text/Pandoc/Writers/Markdown.hs
@@ -452,8 +452,14 @@ blockToMarkdown' opts (Plain inlines) = do
| otherwise -> contents
return $ contents' <> cr
-- title beginning with fig: indicates figure
-blockToMarkdown' opts (Para [Image attr alt (src,'f':'i':'g':':':tit)]) =
- blockToMarkdown opts (Para [Image attr alt (src,tit)])
+blockToMarkdown' opts (Para [Image attr alt (src,'f':'i':'g':':':tit)])
+ | isEnabled Ext_raw_html opts &&
+ not (isEnabled Ext_link_attributes opts) &&
+ attr /= nullAttr = -- use raw HTML
+ (text . T.unpack . T.strip) <$>
+ writeHtml5String opts{ writerTemplate = Nothing }
+ (Pandoc nullMeta [Para [Image attr alt (src,"fig:" ++ tit)]])
+ | otherwise = blockToMarkdown opts (Para [Image attr alt (src,tit)])
blockToMarkdown' opts (Para inlines) =
(<> blankline) `fmap` blockToMarkdown opts (Plain inlines)
blockToMarkdown' opts (LineBlock lns) =
@@ -619,7 +625,7 @@ blockToMarkdown' opts t@(Table caption aligns widths headers rows) = do
(all null headers) aligns' widths' headers rows
| isEnabled Ext_raw_html opts -> fmap (id,) $
(text . T.unpack) <$>
- (writeHtml5String def $ Pandoc nullMeta [t])
+ (writeHtml5String opts{ writerTemplate = Nothing } $ Pandoc nullMeta [t])
| hasSimpleCells &&
isEnabled Ext_pipe_tables opts -> do
rawHeaders <- padRow <$> mapM (blockListToMarkdown opts) headers
@@ -1172,7 +1178,7 @@ inlineToMarkdown opts lnk@(Link attr txt (src, tit))
not (isEnabled Ext_link_attributes opts) &&
attr /= nullAttr = -- use raw HTML
(text . T.unpack . T.strip) <$>
- writeHtml5String def (Pandoc nullMeta [Plain [lnk]])
+ writeHtml5String opts{ writerTemplate = Nothing } (Pandoc nullMeta [Plain [lnk]])
| otherwise = do
plain <- asks envPlain
linktext <- inlineListToMarkdown opts txt
@@ -1212,7 +1218,7 @@ inlineToMarkdown opts img@(Image attr alternate (source, tit))
not (isEnabled Ext_link_attributes opts) &&
attr /= nullAttr = -- use raw HTML
(text . T.unpack . T.strip) <$>
- writeHtml5String def (Pandoc nullMeta [Plain [img]])
+ writeHtml5String opts{ writerTemplate = Nothing } (Pandoc nullMeta [Plain [img]])
| otherwise = do
plain <- asks envPlain
let txt = if null alternate || alternate == [Str source]