git.iko.soy/typeable/pandoc
on master help sign in
Added a "try" to the end parser in enclosed (Text.Pandoc.ParserCombinators).

This makes errors in its use less likely. Removed some now-unneeded try's in calling code. git-svn-id: https://pandoc.googlecode.com/svn/trunk@776 788f1e2b-df1e-0410-8736-df70ead52e1b

commitc1f397622dc0fb3643041f0099d6b5e004d03fd0 authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateSun 22 Jul 2007, 21:01 (19 years ago) parent3ca9932
3 files changed+16−13
src/Text/Pandoc/ParserCombinators.hs+1−1 src/Text/Pandoc/Readers/LaTeX.hs+3−5 src/Text/Pandoc/Readers/RST.hs+12−7
src/Text/Pandoc/ParserCombinators.hs+1−1
@@ -76,7 +76,7 @@ enclosed :: GenParser Char st t -- ^ start parser
7676enclosed start end parser = try (do
7777 start
7878 notFollowedBy space
79− result <- many1Till parser end
79+ result <- many1Till parser (try end)
8080 return result)
8181
8282-- | Like @manyTill@, but reads at least one item.
src/Text/Pandoc/Readers/LaTeX.hs+3−5
@@ -552,13 +552,11 @@ doubleQuoted = try (do
552552
553553singleQuoteStart = char '`'
554554
555−singleQuoteEnd = try (do
556− char '\''
557− notFollowedBy alphaNum)
555+singleQuoteEnd = char '\'' >> notFollowedBy alphaNum
558556
559−doubleQuoteStart = try (string "``")
557+doubleQuoteStart = string "``"
560558
561−doubleQuoteEnd = try (string "''")
559+doubleQuoteEnd = string "''"
562560
563561ellipses = try (do
564562 string "\\ldots"
src/Text/Pandoc/Readers/RST.hs+12−7
@@ -536,12 +536,9 @@ regularKey = try $ do
536536 -- inline
537537 --
538538
539−text = choice [ strong, emph, code, str, tabchar, whitespace,
540− endline ] <?> "text"
541−
542−inline = choice [ escapedChar, special, hyphens, text, symbol ] <?> "inline"
543−
544−special = choice [ link, image ] <?> "link, inline html, or image"
539+inline = choice [ escapedChar, link, image, hyphens, strong, emph,
540+ superscript, subscript, code,
541+ str, tabchar, whitespace, endline, symbol ] <?> "inline"
545542
546543hyphens = try (do
547544 result <- many1 (char '-')
@@ -567,9 +564,17 @@ emph = do
567564 return (Emph (normalizeSpaces result))
568565
569566strong = do
570− result <- enclosed (try (string "**")) (try (string "**")) inline
567+ result <- enclosed (string "**") (string "**") inline
571568 return (Strong (normalizeSpaces result))
572569
570+superscript = do
571+ result <- enclosed (string "\\ :sup:`") (string "`\\ ") anyChar
572+ return (Superscript [Str result])
573+
574+subscript = do
575+ result <- enclosed (string "\\ :sub:`") (string "`\\ ") anyChar
576+ return (Subscript [Str result])
577+
573578whitespace = do
574579 many1 spaceChar <?> "whitespace"
575580 return Space