diff options
author | John MacFarlane <fiddlosopher@gmail.com> | 2013-03-17 10:33:54 -0700 |
---|---|---|
committer | John MacFarlane <fiddlosopher@gmail.com> | 2013-03-17 10:33:54 -0700 |
commit | 835deee58bf4d8d7249735016063e9a988937015 (patch) | |
tree | 7d976a59b6e78dfb40aa2b84f528620dab33e3a9 /src/Text/Pandoc/Writers | |
parent | 8ca5198b8eedf7f4510e3db056f4c9709352c59b (diff) | |
download | pandoc-835deee58bf4d8d7249735016063e9a988937015.tar.gz |
Markdown writer: New approach for citations.
* Reverts 1.11 change that caused citations to be rendered as
markdown citations, even if `--biblio` was specified, unless
`citation` extension is disabled. Now, formatted citations
are always printed if `--biblio` was specified. If you want to
reformat markdown keeping pandoc markdown citations intact,
just don't specify `--biblio`.
* Reverted now unnecessary changes to Text.Pandoc.Biblio adding the raw
block to mark the bibliography, and to Text.Pandoc.Writers.Markdown
to remove the bibliography if `citations` not specified.
* If the content of a `Cite` inline is a `RawInline "latex"`, which
means that a LaTeX citation command was parsed and `--biblio` wasn't
specified, then render it as a pandoc markdown citation. This means
that `pandoc -f latex -t markdown`, without `--biblio`, will convert
LaTeX citation commands to pandoc markdown citations.
Diffstat (limited to 'src/Text/Pandoc/Writers')
-rw-r--r-- | src/Text/Pandoc/Writers/Markdown.hs | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs index bfd4c0898..f09cb3eec 100644 --- a/src/Text/Pandoc/Writers/Markdown.hs +++ b/src/Text/Pandoc/Writers/Markdown.hs @@ -61,8 +61,7 @@ writeMarkdown opts document = evalState (pandocToMarkdown opts{ writerWrapText = writerWrapText opts && not (isEnabled Ext_hard_line_breaks opts) } - document') def - where document' = maybeRemoveBiblio opts document + document) def -- | Convert Pandoc to plain text (like markdown, but without links, -- pictures, or inline formatting). @@ -72,16 +71,7 @@ writePlain opts document = writerExtensions = Set.delete Ext_escaped_line_breaks $ writerExtensions opts } document') def{ stPlain = True } - 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 + where document' = plainify document plainify :: Pandoc -> Pandoc plainify = bottomUp go @@ -653,7 +643,7 @@ inlineToMarkdown opts (LineBreak) | isEnabled Ext_escaped_line_breaks opts = return $ "\\" <> cr | otherwise = return $ " " <> cr inlineToMarkdown _ Space = return space -inlineToMarkdown opts (Cite (c:cs) lst) +inlineToMarkdown opts (Cite (c:cs) lst@[RawInline "latex" _]) | not (isEnabled Ext_citations opts) = inlineListToMarkdown opts lst | citationMode c == AuthorInText = do suffs <- inlineListToMarkdown opts $ citationSuffix c @@ -680,7 +670,7 @@ inlineToMarkdown opts (Cite (c:cs) lst) return $ pdoc <+> r modekey SuppressAuthor = "-" modekey _ = "" -inlineToMarkdown _ (Cite _ _) = return $ text "" +inlineToMarkdown opts (Cite _ lst) = inlineListToMarkdown opts lst inlineToMarkdown opts (Link txt (src, tit)) = do linktext <- inlineListToMarkdown opts txt let linktitle = if null tit |