From 0646eef97691794eeac5549db18ac82cb6b84576 Mon Sep 17 00:00:00 2001 From: fiddlosopher Date: Wed, 24 Jan 2007 17:43:39 +0000 Subject: Rewrote 'extractTagType' in HTML reader so that it doesn't use regexs. git-svn-id: https://pandoc.googlecode.com/svn/trunk@507 788f1e2b-df1e-0410-8736-df70ead52e1b --- src/Text/Pandoc/Readers/HTML.hs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/Text/Pandoc/Readers/HTML.hs b/src/Text/Pandoc/Readers/HTML.hs index b3ddc8985..66b55c448 100644 --- a/src/Text/Pandoc/Readers/HTML.hs +++ b/src/Text/Pandoc/Readers/HTML.hs @@ -40,7 +40,6 @@ module Text.Pandoc.Readers.HTML ( htmlBlockElement ) where -import Text.Regex ( matchRegex, mkRegex ) import Text.ParserCombinators.Parsec import Text.ParserCombinators.Pandoc import Text.Pandoc.Definition @@ -84,10 +83,13 @@ inlinesTilEnd tag = try (do return inlines) -- | Extract type from a tag: e.g. 'br' from '
' -extractTagType tag = - case (matchRegex (mkRegex "<[[:space:]]*/?([A-Za-z0-9]+)") tag) of - Just [match] -> (map toLower match) - Nothing -> "" +extractTagType :: String -> String +extractTagType "" = "" +extractTagType ('<':rest) = + if (not (null rest)) && (last rest == '>') + then map toLower $ removeLeadingTrailingSpace (init rest) + else "" +extractTagType _ = "" -- | Parse any HTML tag (closing or opening) and return text of tag anyHtmlTag = try (do -- cgit v1.2.3