git.iko.soy/typeable/pandoc
on master help sign in
Shared: Changed stringify so it ignores notes.

Also documented this in README.

commit89a7703260703599a033be16e1581a0494326c2b authorJohn MacFarlane <fiddlosopher@gmail.com> dateFri 16 Aug 2013, 13:22 (13 years ago) parent399c75d
2 files changed+6−1
README+1 src/Text/Pandoc/Shared.hs+5−1
README+1
@@ -980,6 +980,7 @@ automatically assigned a unique identifier based on the header text.
980980To derive the identifier from the header text,
981981
982982 - Remove all formatting, links, etc.
983+ - Remove all footnotes.
983984 - Remove all punctuation, except underscores, hyphens, and periods.
984985 - Replace all spaces and newlines with hyphens.
985986 - Convert all alphabetic characters to lowercase.
src/Text/Pandoc/Shared.hs+5−1
@@ -384,8 +384,10 @@ consolidateInlines (x : xs) = x : consolidateInlines xs
384384consolidateInlines [] = []
385385
386386-- | Convert list of inlines to a string with formatting removed.
387+-- Footnotes are skipped (since we don't want their contents in link
388+-- labels).
387389stringify :: [Inline] -> String
388−stringify = query go
390+stringify = query go . walk deNote
389391 where go :: Inline -> [Char]
390392 go Space = " "
391393 go (Str x) = x
@@ -393,6 +395,8 @@ stringify = query go
393395 go (Math _ x) = x
394396 go LineBreak = " "
395397 go _ = ""
398+ deNote (Note _) = Str ""
399+ deNote x = x
396400
397401-- | Change final list item from @Para@ to @Plain@ if the list contains
398402-- no other @Para@ blocks.