From ebcae86cf47e3037ccc3c7146cf610e5a7af3b03 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Tue, 19 Mar 2024 08:09:54 -0700 Subject: DocBook reader: add empty title to admonition div if not present. This allows admonition elements (e.g. ``) to work with gfm admonitions even if the `` is not present. Closes #9569. --- src/Text/Pandoc/Readers/DocBook.hs | 5 +++-- test/command/9569.md | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 test/command/9569.md diff --git a/src/Text/Pandoc/Readers/DocBook.hs b/src/Text/Pandoc/Readers/DocBook.hs index 7b4d1cb1b..68f55c219 100644 --- a/src/Text/Pandoc/Readers/DocBook.hs +++ b/src/Text/Pandoc/Readers/DocBook.hs @@ -1108,8 +1108,9 @@ parseBlock (Elem e) = -- the title: docbook references are ambiguous on that, and some implementations of admonitions -- (e.g. asciidoctor) just use an icon in all cases. To be conservative, we don't -- include the label and leave it to styling. - title <- case filterChild (named "title") e of - Just t -> divWith ("", ["title"], []) . plain <$> getInlines t + title <- divWith ("", ["title"], []) . plain <$> + case filterChild (named "title") e of + Just t -> getInlines t Nothing -> return mempty -- this will ignore the title element if it is present b <- getBlocks e diff --git a/test/command/9569.md b/test/command/9569.md new file mode 100644 index 000000000..edbe2e33d --- /dev/null +++ b/test/command/9569.md @@ -0,0 +1,19 @@ +``` +% pandoc -f docbook -t gfm +<note> + <para>Some content</para> +</note> +<para>Spacer.</para> +<note> + <title>A note with a title. Works, but the title is discarded. + Some content + +^D +> [!NOTE] +> Some content + +Spacer. + +> [!NOTE] +> Some content +``` -- cgit v1.2.3