git.iko.soy/typeable/pandoc
on master help sign in
Made markdown writer sensitive to Ext_footnotes.
1d7fd80John MacFarlane
src/Text/Pandoc/Writers/Markdown.hs+10−4
@@ -146,12 +146,16 @@ noteToMarkdown :: WriterOptions -> Int -> [Block] -> State WriterState Doc
146noteToMarkdown opts num blocks = do
146noteToMarkdown opts num blocks = do
147 contents <- blockListToMarkdown opts blocks
147 contents <- blockListToMarkdown opts blocks
148 let num' = text $ show num
148 let num' = text $ show num
149+ let marker = if isEnabled Ext_footnotes opts
149− let marker = text "[^" <> num' <> text "]:"
150+ then text "[^" <> num' <> text "]:"
151+ else text "[" <> num' <> text "]"
150 let markerSize = 4 + offset num'
152 let markerSize = 4 + offset num'
151 let spacer = case writerTabStop opts - markerSize of
153 let spacer = case writerTabStop opts - markerSize of
152 n | n > 0 -> text $ replicate n ' '
154 n | n > 0 -> text $ replicate n ' '
153 _ -> text " "
155 _ -> text " "
156+ return $ if isEnabled Ext_footnotes opts
154− return $ hang (writerTabStop opts) (marker <> spacer) contents
157+ then hang (writerTabStop opts) (marker <> spacer) contents
158+ else marker <> spacer <> contents
155
159
156-- | Escape special characters for Markdown.
160-- | Escape special characters for Markdown.
157escapeString :: String -> String
161escapeString :: String -> String
@@ -526,8 +530,10 @@ inlineToMarkdown opts (Image alternate (source, tit)) = do
526 else alternate
530 else alternate
527 linkPart <- inlineToMarkdown opts (Link txt (source, tit))
531 linkPart <- inlineToMarkdown opts (Link txt (source, tit))
528 return $ "!" <> linkPart
532 return $ "!" <> linkPart
529−inlineToMarkdown _ (Note contents) = do
533+inlineToMarkdown opts (Note contents) = do
530 modify (\st -> st{ stNotes = contents : stNotes st })
534 modify (\st -> st{ stNotes = contents : stNotes st })
531 st <- get
535 st <- get
532 let ref = show $ (length $ stNotes st)
536 let ref = show $ (length $ stNotes st)
537+ if isEnabled Ext_footnotes opts
533− return $ "[^" <> text ref <> "]"
538+ then return $ "[^" <> text ref <> "]"
539+ else return $ "[" <> text ref <> "]"