diff options
author | John MacFarlane <jgm@berkeley.edu> | 2014-07-13 10:13:22 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2014-07-13 10:13:22 -0700 |
commit | 172a18427480da79e069df55bcc5a5e6bdab99ac (patch) | |
tree | d7a66a4ec58f2c57dd0f3b068021ece934fe0518 | |
parent | cb62cd08e083d581bcfdba5ce3059925d08c5dba (diff) | |
download | pandoc-172a18427480da79e069df55bcc5a5e6bdab99ac.tar.gz |
Shared: Added removeFormatting.
API change (addition of exported function).
-rw-r--r-- | src/Text/Pandoc/Shared.hs | 14 |
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). |