From a2194f23dbc3251908a5cc20198a2b3fbad7b759 Mon Sep 17 00:00:00 2001 From: fiddlosopher Date: Sat, 21 Jul 2007 22:54:40 +0000 Subject: Added support for Strikeout, Superscript, and Subscript to HTML reader. Thanks to Bradley Sif for the patch for Strikeout (Issue #18). git-svn-id: https://pandoc.googlecode.com/svn/trunk@753 788f1e2b-df1e-0410-8736-df70ead52e1b --- src/Text/Pandoc/Readers/HTML.hs | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'src/Text') diff --git a/src/Text/Pandoc/Readers/HTML.hs b/src/Text/Pandoc/Readers/HTML.hs index 824f615c0..c7832fbf0 100644 --- a/src/Text/Pandoc/Readers/HTML.hs +++ b/src/Text/Pandoc/Readers/HTML.hs @@ -384,7 +384,9 @@ plain = do inline = choice [ text, special ] "inline" -text = choice [ entity, strong, emph, code, str, linebreak, whitespace ] "text" +text = choice [ entity, strong, emph, superscript, subscript, + strikeout, spanStrikeout, code, str, + linebreak, whitespace ] "text" special = choice [ link, image, rawHtmlInline ] "link, inline html, or image" @@ -416,6 +418,29 @@ emph = try (do result <- choice [betweenTags "em", betweenTags "it"] return (Emph result)) +superscript = try $ do + failIfStrict -- strict markdown has no superscript, so treat as raw HTML + result <- betweenTags "sup" + return (Superscript result) + +subscript = try $ do + failIfStrict -- strict markdown has no subscript, so treat as raw HTML + result <- betweenTags "sub" + return (Subscript result) + +strikeout = try $ do + failIfStrict -- strict markdown has no strikeout, so treat as raw HTML + result <- choice [betweenTags "s", betweenTags "strike"] + return (Strikeout result) + +spanStrikeout = try $ do + failIfStrict -- strict markdown has no strikeout, so treat as raw HTML + (tag, attributes) <- htmlTag "span" + result <- case (extractAttribute "class" attributes) of + Just "strikeout" -> inlinesTilEnd "span" + Nothing -> fail "not a strikeout" + return (Strikeout result) + strong = try (do result <- choice [betweenTags "b", betweenTags "strong"] return (Strong result)) -- cgit v1.2.3