From 4beb0b9130705d7c2ffd0002634b8ab029494bbc Mon Sep 17 00:00:00 2001 From: fiddlosopher Date: Sun, 22 Jul 2007 21:26:22 +0000 Subject: Superscript and Subscript support for RST reader. git-svn-id: https://pandoc.googlecode.com/svn/trunk@777 788f1e2b-df1e-0410-8736-df70ead52e1b --- src/Text/Pandoc/Readers/RST.hs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src/Text/Pandoc') diff --git a/src/Text/Pandoc/Readers/RST.hs b/src/Text/Pandoc/Readers/RST.hs index 7fed7cbd3..000a8b97a 100644 --- a/src/Text/Pandoc/Readers/RST.hs +++ b/src/Text/Pandoc/Readers/RST.hs @@ -536,8 +536,8 @@ regularKey = try $ do -- inline -- -inline = choice [ escapedChar, link, image, hyphens, strong, emph, - superscript, subscript, code, +inline = choice [ superscript, subscript, + escapedChar, link, image, hyphens, strong, emph, code, str, tabchar, whitespace, endline, symbol ] "inline" hyphens = try (do @@ -567,13 +567,15 @@ strong = do result <- enclosed (string "**") (string "**") inline return (Strong (normalizeSpaces result)) -superscript = do - result <- enclosed (string "\\ :sup:`") (string "`\\ ") anyChar - return (Superscript [Str result]) +interpreted role = try $ do + option "" (try $ string "\\ ") + result <- enclosed (string $ ":" ++ role ++ ":`") (char '`') anyChar + nextChar <- lookAhead anyChar + try (string "\\ ") <|> lookAhead (count 1 $ oneOf " \t\n") <|> (eof >> return "") + return [Str result] -subscript = do - result <- enclosed (string "\\ :sub:`") (string "`\\ ") anyChar - return (Subscript [Str result]) +superscript = interpreted "sup" >>= (return . Superscript) +subscript = interpreted "sub" >>= (return . Subscript) whitespace = do many1 spaceChar "whitespace" -- cgit v1.2.3