aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc
diff options
context:
space:
mode:
authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2007-07-22 21:26:22 +0000
committerfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2007-07-22 21:26:22 +0000
commit4beb0b9130705d7c2ffd0002634b8ab029494bbc (patch)
tree05778a2664d4b7bb2289215e38d398929ee987da /src/Text/Pandoc
parentc1f397622dc0fb3643041f0099d6b5e004d03fd0 (diff)
downloadpandoc-4beb0b9130705d7c2ffd0002634b8ab029494bbc.tar.gz
Superscript and Subscript support for RST reader.
git-svn-id: https://pandoc.googlecode.com/svn/trunk@777 788f1e2b-df1e-0410-8736-df70ead52e1b
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r--src/Text/Pandoc/Readers/RST.hs18
1 files changed, 10 insertions, 8 deletions
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"