@@ -57,6 +57,7 @@ module Text.Pandoc.Shared (
5757 normalize,
5858 normalizeInlines,
5959 normalizeBlocks,
60+ removeFormatting,
6061 stringify,
6162 compactify,
6263 compactify',
@@ -493,6 +494,19 @@ normalizeInlines (Cite cs ils : ys) =
493494normalizeInlines (x : xs) = x : normalizeInlines xs
494495normalizeInlines [] = []
495496
497+-- | Remove inline formatting from a list of inlines.
498+removeFormatting :: [Inline] -> [Inline]
499+removeFormatting = query go . walk deNote
500+ where go :: Inline -> [Inline]
501+ go (Str xs) = [Str xs]
502+ go Space = [Space]
503+ go (Code _ x) = [Str x]
504+ go (Math _ x) = [Str x]
505+ go LineBreak = [Space]
506+ go _ = []
507+ deNote (Note _) = Str ""
508+ deNote x = x
509+
496510-- | Convert pandoc structure to a string with formatting removed.
497511-- Footnotes are skipped (since we don't want their contents in link
498512-- labels).