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 | |
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')
-rw-r--r-- | src/Text/Pandoc/Biblio.hs | 2 | ||||
-rw-r--r-- | src/Text/Pandoc/Writers/Markdown.hs | 18 |
2 files changed, 5 insertions, 15 deletions
diff --git a/src/Text/Pandoc/Biblio.hs b/src/Text/Pandoc/Biblio.hs index 4116e3cbd..4dd82dd08 100644 --- a/src/Text/Pandoc/Biblio.hs +++ b/src/Text/Pandoc/Biblio.hs @@ -54,7 +54,7 @@ processBiblio (Just style) r p = cits_map = M.fromList $ zip grps (citations result) biblioList = map (renderPandoc' style) (bibliography result) Pandoc m b = bottomUp mvPunct . deNote . bottomUp (processCite style cits_map) $ p' - in Pandoc m $ b ++ (RawBlock "pandoc" "references" : biblioList) + in Pandoc m $ b ++ biblioList -- | Substitute 'Cite' elements with formatted citations. processCite :: Style -> M.Map [Citation] [FormattedOutput] -> Inline -> Inline 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 |