aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2014-07-13 10:13:22 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2014-07-13 10:13:22 -0700
commit172a18427480da79e069df55bcc5a5e6bdab99ac (patch)
treed7a66a4ec58f2c57dd0f3b068021ece934fe0518 /src/Text
parentcb62cd08e083d581bcfdba5ce3059925d08c5dba (diff)
downloadpandoc-172a18427480da79e069df55bcc5a5e6bdab99ac.tar.gz
Shared: Added removeFormatting.
API change (addition of exported function).
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Shared.hs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs
index 5cb64c1e7..8504e996c 100644
--- a/src/Text/Pandoc/Shared.hs
+++ b/src/Text/Pandoc/Shared.hs
@@ -57,6 +57,7 @@ module Text.Pandoc.Shared (
normalize,
normalizeInlines,
normalizeBlocks,
+ removeFormatting,
stringify,
compactify,
compactify',
@@ -493,6 +494,19 @@ normalizeInlines (Cite cs ils : ys) =
normalizeInlines (x : xs) = x : normalizeInlines xs
normalizeInlines [] = []
+-- | Remove inline formatting from a list of inlines.
+removeFormatting :: [Inline] -> [Inline]
+removeFormatting = query go . walk deNote
+ where go :: Inline -> [Inline]
+ go (Str xs) = [Str xs]
+ go Space = [Space]
+ go (Code _ x) = [Str x]
+ go (Math _ x) = [Str x]
+ go LineBreak = [Space]
+ go _ = []
+ deNote (Note _) = Str ""
+ deNote x = x
+
-- | Convert pandoc structure to a string with formatting removed.
-- Footnotes are skipped (since we don't want their contents in link
-- labels).