git.iko.soy/typeable/pandoc
on master help sign in
Superscript and Subscript support for RST reader.

git-svn-id: https://pandoc.googlecode.com/svn/trunk@777 788f1e2b-df1e-0410-8736-df70ead52e1b

commit4beb0b9130705d7c2ffd0002634b8ab029494bbc authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateSun 22 Jul 2007, 21:26 (19 years ago) parentc1f3976
1 file changed+10−8
src/Text/Pandoc/Readers/RST.hs+10−8
src/Text/Pandoc/Readers/RST.hs+10−8
@@ -536,8 +536,8 @@ regularKey = try $ do
536536 -- inline
537537 --
538538
539−inline = choice [ escapedChar, link, image, hyphens, strong, emph,
540− superscript, subscript, code,
539+inline = choice [ superscript, subscript,
540+ escapedChar, link, image, hyphens, strong, emph, code,
541541 str, tabchar, whitespace, endline, symbol ] <?> "inline"
542542
543543hyphens = try (do
@@ -567,13 +567,15 @@ strong = do
567567 result <- enclosed (string "**") (string "**") inline
568568 return (Strong (normalizeSpaces result))
569569
570−superscript = do
571− result <- enclosed (string "\\ :sup:`") (string "`\\ ") anyChar
572− return (Superscript [Str result])
570+interpreted role = try $ do
571+ option "" (try $ string "\\ ")
572+ result <- enclosed (string $ ":" ++ role ++ ":`") (char '`') anyChar
573+ nextChar <- lookAhead anyChar
574+ try (string "\\ ") <|> lookAhead (count 1 $ oneOf " \t\n") <|> (eof >> return "")
575+ return [Str result]
573576
574−subscript = do
575− result <- enclosed (string "\\ :sub:`") (string "`\\ ") anyChar
576− return (Subscript [Str result])
577+superscript = interpreted "sup" >>= (return . Superscript)
578+subscript = interpreted "sub" >>= (return . Subscript)
577579
578580whitespace = do
579581 many1 spaceChar <?> "whitespace"