From 99f9126d7215b1e962dc8a10f8379fa028c47d35 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 17 Mar 2013 09:57:27 -0700 Subject: Markdown writer: Omit bibliography when `citations` enabled. In 1.11, citations would be rendered as pandoc markdown citations, but the bibliography would still be printed. We avoid that by adding a `RawBlock "pandoc" "references"` before the references. This allows the markdown writer to find the references and strip them off when `citations` is enabled. --- src/Text/Pandoc/Writers/Markdown.hs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs index b496c8011..bfd4c0898 100644 --- a/src/Text/Pandoc/Writers/Markdown.hs +++ b/src/Text/Pandoc/Writers/Markdown.hs @@ -61,7 +61,8 @@ writeMarkdown opts document = evalState (pandocToMarkdown opts{ writerWrapText = writerWrapText opts && not (isEnabled Ext_hard_line_breaks opts) } - document) def + document') def + where document' = maybeRemoveBiblio opts document -- | Convert Pandoc to plain text (like markdown, but without links, -- pictures, or inline formatting). @@ -71,7 +72,16 @@ writePlain opts document = writerExtensions = Set.delete Ext_escaped_line_breaks $ writerExtensions opts } document') def{ stPlain = True } - where document' = plainify document + where document' = plainify $ maybeRemoveBiblio opts document + +-- If we're rendering citations as pandoc markdown citations, +-- then we don't want to include a bibliography. +maybeRemoveBiblio :: WriterOptions -> Pandoc -> Pandoc +maybeRemoveBiblio opts (Pandoc meta bs) = Pandoc meta bs' + where bs' = if isEnabled Ext_citations opts + then takeWhile + (/= RawBlock "pandoc" "references") bs + else bs plainify :: Pandoc -> Pandoc plainify = bottomUp go -- cgit v1.2.3