git.iko.soy/typeable/pandoc
on master help sign in
Make --id-prefix affect footnote IDs in markdown writer.
885ef20John MacFarlane
README+3−2
@@ -416,8 +416,9 @@ Options affecting specific writers
416
416
417`--id-prefix`=*STRING*
417`--id-prefix`=*STRING*
418: Specify a prefix to be added to all automatically generated identifiers
418: Specify a prefix to be added to all automatically generated identifiers
419+ in HTML and DocBook output, and to footnote numbers in markdown output.
419− in HTML and DocBook output. This is useful for preventing duplicate
420+ This is useful for preventing duplicate identifiers when generating
420− identifiers when generating fragments to be included in other pages.
421+ fragments to be included in other pages.
421
422
422`-T` *STRING*, `--title-prefix=`*STRING*
423`-T` *STRING*, `--title-prefix=`*STRING*
423: Specify *STRING* as a prefix at the beginning of the title
424: Specify *STRING* as a prefix at the beginning of the title
src/Text/Pandoc/Options.hs+1
@@ -215,6 +215,7 @@ data WriterOptions = WriterOptions
215 , writerColumns :: Int -- ^ Characters in a line (for text wrapping)
215 , writerColumns :: Int -- ^ Characters in a line (for text wrapping)
216 , writerEmailObfuscation :: ObfuscationMethod -- ^ How to obfuscate emails
216 , writerEmailObfuscation :: ObfuscationMethod -- ^ How to obfuscate emails
217 , writerIdentifierPrefix :: String -- ^ Prefix for section & note ids in HTML
217 , writerIdentifierPrefix :: String -- ^ Prefix for section & note ids in HTML
218+ -- and for footnote marks in markdown
218 , writerSourceDirectory :: FilePath -- ^ Directory path of 1st source file
219 , writerSourceDirectory :: FilePath -- ^ Directory path of 1st source file
219 , writerUserDataDir :: Maybe FilePath -- ^ Path of user data directory
220 , writerUserDataDir :: Maybe FilePath -- ^ Path of user data directory
220 , writerCiteMethod :: CiteMethod -- ^ How to print cites
221 , writerCiteMethod :: CiteMethod -- ^ How to print cites
src/Text/Pandoc/Writers/Markdown.hs+4−4
@@ -174,7 +174,7 @@ notesToMarkdown opts notes =
174noteToMarkdown :: WriterOptions -> Int -> [Block] -> State WriterState Doc
174noteToMarkdown :: WriterOptions -> Int -> [Block] -> State WriterState Doc
175noteToMarkdown opts num blocks = do
175noteToMarkdown opts num blocks = do
176 contents <- blockListToMarkdown opts blocks
176 contents <- blockListToMarkdown opts blocks
177− let num' = text $ show num
177+ let num' = text $ writerIdentifierPrefix opts ++ show num
178 let marker = if isEnabled Ext_footnotes opts
178 let marker = if isEnabled Ext_footnotes opts
179 then text "[^" <> num' <> text "]:"
179 then text "[^" <> num' <> text "]:"
180 else text "[" <> num' <> text "]"
180 else text "[" <> num' <> text "]"
@@ -655,7 +655,7 @@ inlineToMarkdown opts (Image alternate (source, tit)) = do
655inlineToMarkdown opts (Note contents) = do
655inlineToMarkdown opts (Note contents) = do
656 modify (\st -> st{ stNotes = contents : stNotes st })
656 modify (\st -> st{ stNotes = contents : stNotes st })
657 st <- get
657 st <- get
658− let ref = show $ (length $ stNotes st)
658+ let ref = text $ writerIdentifierPrefix opts ++ show (length $ stNotes st)
659 if isEnabled Ext_footnotes opts
659 if isEnabled Ext_footnotes opts
660− then return $ "[^" <> text ref <> "]"
660+ then return $ "[^" <> ref <> "]"
661− else return $ "[" <> text ref <> "]"
661+ else return $ "[" <> ref <> "]"