git.iko.soy/typeable/pandoc
on master help sign in
Added stripTags to Text.Pandoc.XML.

This is used in the HTML writer. git-svn-id: https://pandoc.googlecode.com/svn/trunk@1647 788f1e2b-df1e-0410-8736-df70ead52e1b

commit90c335c463f4fb706aa34e543476ea0263b5b308 authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateSat 5 Dec 2009, 07:28 (17 years ago) parent8671bc5
1 file changed+12−1
src/Text/Pandoc/XML.hs+12−1
src/Text/Pandoc/XML.hs+12−1
@@ -27,7 +27,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2727
2828Functions for escaping and formatting XML.
2929-}
30−module Text.Pandoc.XML ( escapeCharForXML,
30+module Text.Pandoc.XML ( stripTags,
31+ escapeCharForXML,
3132 escapeStringForXML,
3233 inTags,
3334 selfClosingTag,
@@ -35,6 +36,16 @@ module Text.Pandoc.XML ( escapeCharForXML,
3536 inTagsIndented ) where
3637import Text.PrettyPrint.HughesPJ
3738
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+
3849-- | Escape one character as needed for XML.
3950escapeCharForXML :: Char -> String
4051escapeCharForXML x = case x of