git.iko.soy/typeable/pandoc
on master help sign in
Added stripTags to Text.Pandoc.XML.
90c335cfiddlosopher
src/Text/Pandoc/XML.hs+12−1
@@ -27,7 +27,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27
27
28Functions for escaping and formatting XML.
28Functions for escaping and formatting XML.
29-}
29-}
30+module Text.Pandoc.XML ( stripTags,
30−module Text.Pandoc.XML ( escapeCharForXML,
31+ escapeCharForXML,
31 escapeStringForXML,
32 escapeStringForXML,
32 inTags,
33 inTags,
33 selfClosingTag,
34 selfClosingTag,
@@ -35,6 +36,16 @@ module Text.Pandoc.XML ( escapeCharForXML,
35 inTagsIndented ) where
36 inTagsIndented ) where
36import Text.PrettyPrint.HughesPJ
37import Text.PrettyPrint.HughesPJ
37
38
39+-- | Remove everything between <...>
40+stripTags :: String -> String
41+stripTags ('<':xs) =
42+ let (_,rest) = break (=='>') xs
43+ in if null rest
44+ then ""
45+ else stripTags (tail rest) -- leave off >
46+stripTags (x:xs) = x : stripTags xs
47+stripTags [] = []
48+
38-- | Escape one character as needed for XML.
49-- | Escape one character as needed for XML.
39escapeCharForXML :: Char -> String
50escapeCharForXML :: Char -> String
40escapeCharForXML x = case x of
51escapeCharForXML x = case x of