diff options
author | John MacFarlane <fiddlosopher@gmail.com> | 2013-03-17 09:57:27 -0700 |
---|---|---|
committer | John MacFarlane <fiddlosopher@gmail.com> | 2013-03-17 09:57:27 -0700 |
commit | 99f9126d7215b1e962dc8a10f8379fa028c47d35 (patch) | |
tree | 05376a0652133b2c6ecfbc0e683044ba6991acc9 /src/Text/Pandoc/Writers | |
parent | cae52ecc315a0635f81cb2547b4f268ec8a8befa (diff) | |
download | pandoc-99f9126d7215b1e962dc8a10f8379fa028c47d35.tar.gz |
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.
Diffstat (limited to 'src/Text/Pandoc/Writers')
-rw-r--r-- | src/Text/Pandoc/Writers/Markdown.hs | 14 |
1 files changed, 12 insertions, 2 deletions
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 |