From 73cbae72026ad43d80d0005296adb9f5c8fe858a Mon Sep 17 00:00:00 2001
From: fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>
Date: Mon, 12 Feb 2007 03:53:14 +0000
Subject: [PATCH] Added 'try' in front of 'string', where needed, or used a
 different parser, in RST reader. This fixes a bug where ````` would not be
 correctly parsed as a verbatim `.

git-svn-id: https://pandoc.googlecode.com/svn/trunk@526 788f1e2b-df1e-0410-8736-df70ead52e1b
---
 src/Text/Pandoc/Readers/RST.hs | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/Text/Pandoc/Readers/RST.hs b/src/Text/Pandoc/Readers/RST.hs
index 9a25fe84a..a0bcc822f 100644
--- a/src/Text/Pandoc/Readers/RST.hs
+++ b/src/Text/Pandoc/Readers/RST.hs
@@ -397,8 +397,8 @@ romanNumeral = do
   return result
 
 orderedListEnumerator = choice [ many1 digit, 
-                                 string "#", 
-                                 count 1 letter, 
+                                 count 1 (char '#'),
+                                 count 1 letter,
                                  romanNumeral ]
 
 -- parses ordered list start and returns its length (inc following whitespace)
@@ -506,7 +506,7 @@ imageKey = try (do
               (Src (removeLeadingTrailingSpace src) "")))
 
 anonymousKey = try (do
-  choice [string ".. __:", string "__"]
+  oneOfStrings [".. __:", "__"]
   skipSpaces
   option ' ' newline
   src <- manyTill anyChar newline
@@ -515,7 +515,8 @@ anonymousKey = try (do
 
 regularKeyQuoted = try (do
   string ".. _`"
-  ref <- manyTill inline (string "`:")
+  ref <- manyTill inline (char '`')
+  char ':'
   skipSpaces
   option ' ' newline
   src <- manyTill anyChar newline
@@ -557,7 +558,7 @@ symbol = do
 -- parses inline code, between codeStart and codeEnd
 code = try (do 
   string "``"
-  result <- manyTill anyChar (string "``")
+  result <- manyTill anyChar (try (string "``"))
   let result' = removeLeadingTrailingSpace $ joinWithSep " " $ lines result
   return (Code result'))
 
@@ -624,7 +625,8 @@ anonymousLinkEnding = try (do
 
 referenceLink = try (do
   char '`'
-  label <- manyTill inline (string "`_")
+  label <- manyTill inline (char '`')
+  char '_'
   src <- option (Ref []) anonymousLinkEnding
   return (Link (normalizeSpaces label) src))