From 89a7703260703599a033be16e1581a0494326c2b Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Fri, 16 Aug 2013 13:22:27 -0700 Subject: Shared: Changed stringify so it ignores notes. Also documented this in README. --- README | 1 + src/Text/Pandoc/Shared.hs | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/README b/README index e5de97556..c25d611d6 100644 --- a/README +++ b/README @@ -980,6 +980,7 @@ automatically assigned a unique identifier based on the header text. To derive the identifier from the header text, - Remove all formatting, links, etc. + - Remove all footnotes. - Remove all punctuation, except underscores, hyphens, and periods. - Replace all spaces and newlines with hyphens. - Convert all alphabetic characters to lowercase. diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs index 72b467da5..eef150351 100644 --- a/src/Text/Pandoc/Shared.hs +++ b/src/Text/Pandoc/Shared.hs @@ -384,8 +384,10 @@ consolidateInlines (x : xs) = x : consolidateInlines xs consolidateInlines [] = [] -- | Convert list of inlines to a string with formatting removed. +-- Footnotes are skipped (since we don't want their contents in link +-- labels). stringify :: [Inline] -> String -stringify = query go +stringify = query go . walk deNote where go :: Inline -> [Char] go Space = " " go (Str x) = x @@ -393,6 +395,8 @@ stringify = query go go (Math _ x) = x go LineBreak = " " go _ = "" + deNote (Note _) = Str "" + deNote x = x -- | Change final list item from @Para@ to @Plain@ if the list contains -- no other @Para@ blocks. -- cgit v1.2.3