diff options
| author | Carlos Scheidegger <[email protected]> | 2025-07-27 14:27:41 -0400 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-07-27 11:27:41 -0700 |
| commit | 6893b38a6e9e634c51d6dc789db03824feedb616 (patch) | |
| tree | e9aa228b3e362ff2b1282c34cc93acc9a48c31a7 | |
| parent | bfbf67ca5daad4d0f04315e5233c748e65082fae (diff) | |
Markdown writer: use fenced divs even with empty attributes.
Previously fenced divs were not used in this case, causing the writer to fall back to raw HTML.
Closes #10955.
| -rw-r--r-- | src/Text/Pandoc/Writers/Markdown.hs | 3 | ||||
| -rw-r--r-- | test/command/4164.md | 6 | ||||
| -rw-r--r-- | test/writer.markdown | 54 | ||||
| -rw-r--r-- | test/writer.opml | 2 |
4 files changed, 22 insertions, 43 deletions
diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs index cd3e4ab91..476b54286 100644 --- a/src/Text/Pandoc/Writers/Markdown.hs +++ b/src/Text/Pandoc/Writers/Markdown.hs @@ -400,8 +400,7 @@ blockToMarkdown' opts (Div attrs@(_,classes,_) bs) | (take 3 (T.unpack id')) == "ref" -> contents <> blankline | otherwise -> contents <> blankline - | isEnabled Ext_fenced_divs opts && - attrs /= nullAttr -> + | isEnabled Ext_fenced_divs opts -> let attrsToMd = if variant == Commonmark then attrsToMarkdown opts else classOrAttrsToMarkdown opts diff --git a/test/command/4164.md b/test/command/4164.md index 4e7b7e285..e5cf5d98e 100644 --- a/test/command/4164.md +++ b/test/command/4164.md @@ -8,11 +8,9 @@ Here is inline html: -<div> - +::: {} `<balise>`{=html} bla bla - -</div> +::: ``` diff --git a/test/writer.markdown b/test/writer.markdown index 1ecb10679..0345da7a1 100644 --- a/test/writer.markdown +++ b/test/writer.markdown @@ -353,33 +353,23 @@ orange Simple block on one line: -<div> - +::: {} foo - -</div> +::: And nested without indentation: -<div> - -<div> - -<div> - +:::::: {} +:::: {} +::: {} foo +::: +:::: -</div> - -</div> - -<div> - +::: {} bar - -</div> - -</div> +::: +:::::: Interpreted markdown in a table: @@ -397,11 +387,9 @@ And this is **strong** Here's a simple block: -<div> - +::: {} foo - -</div> +::: This should be a code block, though: @@ -415,19 +403,13 @@ As should this: Now, nested: -<div> - -<div> - -<div> - +::::: {} +:::: {} +::: {} foo - -</div> - -</div> - -</div> +::: +:::: +::::: This should just be an HTML comment: diff --git a/test/writer.opml b/test/writer.opml index 89f4b6fee..b2fef8fc8 100644 --- a/test/writer.opml +++ b/test/writer.opml @@ -44,7 +44,7 @@ </outline> <outline text="Definition Lists" _note="Tight using spaces: apple : red fruit orange : orange fruit banana : yellow fruit Tight using tabs: apple : red fruit orange : orange fruit banana : yellow fruit Loose: apple : red fruit orange : orange fruit banana : yellow fruit Multiple blocks with italics: *apple* : red fruit contains seeds, crisp, pleasant to taste *orange* : orange fruit { orange code block } > orange block quote Multiple definitions, tight: apple : red fruit : computer orange : orange fruit : bank Multiple definitions, loose: apple : red fruit : computer orange : orange fruit : bank Blank line after term, indented marker, alternate markers: apple : red fruit : computer orange : orange fruit 1. sublist 2. sublist"> </outline> -<outline text="HTML Blocks" _note="Simple block on one line: <div> foo </div> And nested without indentation: <div> <div> <div> foo </div> </div> <div> bar </div> </div> Interpreted markdown in a table: <table> <tr> <td> This is *emphasized* </td> <td> And this is **strong** </td> </tr> </table> <script type="text/javascript">document.write('This *should not* be interpreted as markdown');</script> Here's a simple block: <div> foo </div> This should be a code block, though: <div> foo </div> As should this: <div>foo</div> Now, nested: <div> <div> <div> foo </div> </div> </div> This should just be an HTML comment: <!-- Comment --> Multiline: <!-- Blah Blah --> <!-- This is another comment. --> Code block: <!-- Comment --> Just plain comment, with trailing spaces on the line: <!-- foo --> Code: <hr /> Hr's: <hr> <hr /> <hr /> <hr> <hr /> <hr /> <hr class="foo" id="bar" /> <hr class="foo" id="bar" /> <hr class="foo" id="bar"> --------------------------------------------------------------------------------"> +<outline text="HTML Blocks" _note="Simple block on one line: ::: {} foo ::: And nested without indentation: :::::: {} :::: {} ::: {} foo ::: :::: ::: {} bar ::: :::::: Interpreted markdown in a table: <table> <tr> <td> This is *emphasized* </td> <td> And this is **strong** </td> </tr> </table> <script type="text/javascript">document.write('This *should not* be interpreted as markdown');</script> Here's a simple block: ::: {} foo ::: This should be a code block, though: <div> foo </div> As should this: <div>foo</div> Now, nested: ::::: {} :::: {} ::: {} foo ::: :::: ::::: This should just be an HTML comment: <!-- Comment --> Multiline: <!-- Blah Blah --> <!-- This is another comment. --> Code block: <!-- Comment --> Just plain comment, with trailing spaces on the line: <!-- foo --> Code: <hr /> Hr's: <hr> <hr /> <hr /> <hr> <hr /> <hr /> <hr class="foo" id="bar" /> <hr class="foo" id="bar" /> <hr class="foo" id="bar"> --------------------------------------------------------------------------------"> </outline> <outline text="Inline Markup" _note="This is *emphasized*, and so *is this*. This is **strong**, and so **is this**. An *[emphasized link](/url)*. ***This is strong and em.*** So is ***this*** word. ***This is strong and em.*** So is ***this*** word. This is code: `>`, `$`, `\`, `\$`, `<html>`. ~~This is *strikeout*.~~ Superscripts: a^bc^d a^*hello*^ a^hello there^. Subscripts: H~2~O, H~23~O, H~many of them~O. These should not be superscripts or subscripts, because of the unescaped spaces: a\^b c\^d, a\~b c\~d. --------------------------------------------------------------------------------"> </outline> |
