diff options
author | Jan Tojnar <jtojnar@gmail.com> | 2021-06-05 15:53:24 +0200 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2021-06-05 13:51:18 -0600 |
commit | 7a3ee9d3d83b73cb53de80e01a9968ebf8f7cf12 (patch) | |
tree | bb7dcd3f6f9c24545bed5f5ae40b17bf74c77013 /src/Text/Pandoc/Writers/Markdown.hs | |
parent | c6f8c38c49e9579bf0bc0c91131bb206f0617e6b (diff) | |
download | pandoc-7a3ee9d3d83b73cb53de80e01a9968ebf8f7cf12.tar.gz |
CommonMark writer: do not throw away attributes when Ext_attributes is enabled
Ext_attributes covers at least the following:
- Ext_fenced_code_attributes
- Ext_header_attributes
- Ext_inline_code_attributes
- Ext_link_attributes
Diffstat (limited to 'src/Text/Pandoc/Writers/Markdown.hs')
-rw-r--r-- | src/Text/Pandoc/Writers/Markdown.hs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs index 38227dfa8..6316d9419 100644 --- a/src/Text/Pandoc/Writers/Markdown.hs +++ b/src/Text/Pandoc/Writers/Markdown.hs @@ -366,7 +366,7 @@ blockToMarkdown' opts (Plain inlines) = do -- title beginning with fig: indicates figure blockToMarkdown' opts (Para [Image attr alt (src,tgt@(T.stripPrefix "fig:" -> Just tit))]) | isEnabled Ext_raw_html opts && - not (isEnabled Ext_link_attributes opts) && + not (isEnabled Ext_link_attributes opts || isEnabled Ext_attributes opts) && attr /= nullAttr = -- use raw HTML (<> blankline) . literal . T.strip <$> writeHtml5String opts{ writerTemplate = Nothing } @@ -431,7 +431,8 @@ blockToMarkdown' opts (Header level attr inlines) = do && id' == autoId -> empty (id',_,_) | isEnabled Ext_mmd_header_identifiers opts -> space <> brackets (literal id') - _ | isEnabled Ext_header_attributes opts -> + _ | isEnabled Ext_header_attributes opts || + isEnabled Ext_attributes opts -> space <> attrsToMarkdown attr | otherwise -> empty contents <- inlineListToMarkdown opts $ @@ -490,7 +491,8 @@ blockToMarkdown' opts (CodeBlock attribs str) = do endline c = literal $ T.replicate (endlineLen c) $ T.singleton c backticks = endline '`' tildes = endline '~' - attrs = if isEnabled Ext_fenced_code_attributes opts + attrs = if isEnabled Ext_fenced_code_attributes opts || + isEnabled Ext_attributes opts then nowrap $ " " <> classOrAttrsToMarkdown attribs else case attribs of (_,cls:_,_) -> " " <> literal cls |