git.iko.soy/typeable/pandoc
on master help sign in
Make --id-prefix affect footnote IDs in markdown writer.

Closes #614.

commit885ef2072f68fd01137d2eb41d1258932d2134c5 authorJohn MacFarlane <fiddlosopher@gmail.com> dateTue 25 Sep 2012, 20:26 (14 years ago) parent6ad7ac1
3 files changed+8−6
README+3−2 src/Text/Pandoc/Options.hs+1 src/Text/Pandoc/Writers/Markdown.hs+4−4
README+3−2
@@ -416,8 +416,9 @@ Options affecting specific writers
416416
417417`--id-prefix`=*STRING*
418418: Specify a prefix to be added to all automatically generated identifiers
419− in HTML and DocBook output. This is useful for preventing duplicate
420− identifiers when generating fragments to be included in other pages.
419+ in HTML and DocBook output, and to footnote numbers in markdown output.
420+ This is useful for preventing duplicate identifiers when generating
421+ fragments to be included in other pages.
421422
422423`-T` *STRING*, `--title-prefix=`*STRING*
423424: Specify *STRING* as a prefix at the beginning of the title
src/Text/Pandoc/Options.hs+1
@@ -215,6 +215,7 @@ data WriterOptions = WriterOptions
215215 , writerColumns :: Int -- ^ Characters in a line (for text wrapping)
216216 , writerEmailObfuscation :: ObfuscationMethod -- ^ How to obfuscate emails
217217 , writerIdentifierPrefix :: String -- ^ Prefix for section & note ids in HTML
218+ -- and for footnote marks in markdown
218219 , writerSourceDirectory :: FilePath -- ^ Directory path of 1st source file
219220 , writerUserDataDir :: Maybe FilePath -- ^ Path of user data directory
220221 , writerCiteMethod :: CiteMethod -- ^ How to print cites
src/Text/Pandoc/Writers/Markdown.hs+4−4
@@ -174,7 +174,7 @@ notesToMarkdown opts notes =
174174noteToMarkdown :: WriterOptions -> Int -> [Block] -> State WriterState Doc
175175noteToMarkdown opts num blocks = do
176176 contents <- blockListToMarkdown opts blocks
177− let num' = text $ show num
177+ let num' = text $ writerIdentifierPrefix opts ++ show num
178178 let marker = if isEnabled Ext_footnotes opts
179179 then text "[^" <> num' <> text "]:"
180180 else text "[" <> num' <> text "]"
@@ -655,7 +655,7 @@ inlineToMarkdown opts (Image alternate (source, tit)) = do
655655inlineToMarkdown opts (Note contents) = do
656656 modify (\st -> st{ stNotes = contents : stNotes st })
657657 st <- get
658− let ref = show $ (length $ stNotes st)
658+ let ref = text $ writerIdentifierPrefix opts ++ show (length $ stNotes st)
659659 if isEnabled Ext_footnotes opts
660− then return $ "[^" <> text ref <> "]"
661− else return $ "[" <> text ref <> "]"
660+ then return $ "[^" <> ref <> "]"
661+ else return $ "[" <> ref <> "]"