aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2012-08-02 21:00:02 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2012-08-02 21:00:02 -0700
commit1d7fd8012df7d9e9bb00d3be1f98917491d9c755 (patch)
treed72727b1a92b410072d4698aa11e40846efd0c30
parent2403ca86f937dd591a302b41c5d974f9228b2809 (diff)
downloadpandoc-1d7fd8012df7d9e9bb00d3be1f98917491d9c755.tar.gz
Made markdown writer sensitive to Ext_footnotes.
If footnotes not enabled, footnotes are formatted like normal markdown paragraphs, with a marker like [3].
-rw-r--r--src/Text/Pandoc/Writers/Markdown.hs14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs
index dac9bb8cc..3b79cbcd4 100644
--- a/src/Text/Pandoc/Writers/Markdown.hs
+++ b/src/Text/Pandoc/Writers/Markdown.hs
@@ -146,12 +146,16 @@ noteToMarkdown :: WriterOptions -> Int -> [Block] -> State WriterState Doc
noteToMarkdown opts num blocks = do
contents <- blockListToMarkdown opts blocks
let num' = text $ show num
- let marker = text "[^" <> num' <> text "]:"
+ let marker = if isEnabled Ext_footnotes opts
+ then text "[^" <> num' <> text "]:"
+ else text "[" <> num' <> text "]"
let markerSize = 4 + offset num'
let spacer = case writerTabStop opts - markerSize of
n | n > 0 -> text $ replicate n ' '
_ -> text " "
- return $ hang (writerTabStop opts) (marker <> spacer) contents
+ return $ if isEnabled Ext_footnotes opts
+ then hang (writerTabStop opts) (marker <> spacer) contents
+ else marker <> spacer <> contents
-- | Escape special characters for Markdown.
escapeString :: String -> String
@@ -526,8 +530,10 @@ inlineToMarkdown opts (Image alternate (source, tit)) = do
else alternate
linkPart <- inlineToMarkdown opts (Link txt (source, tit))
return $ "!" <> linkPart
-inlineToMarkdown _ (Note contents) = do
+inlineToMarkdown opts (Note contents) = do
modify (\st -> st{ stNotes = contents : stNotes st })
st <- get
let ref = show $ (length $ stNotes st)
- return $ "[^" <> text ref <> "]"
+ if isEnabled Ext_footnotes opts
+ then return $ "[^" <> text ref <> "]"
+ else return $ "[" <> text ref <> "]"