From 75cba828b5c69299c3a4a1e33df8deae3a6c291e Mon Sep 17 00:00:00 2001
From: "paul.rivier" <paul.r.ml@gmail.com>
Date: Tue, 29 May 2012 13:41:28 +0200
Subject: [PATCH] Textile reader: fix for `<notextile>` and `==`.

Closes #517.
---
 src/Text/Pandoc/Readers/Textile.hs | 13 +++----------
 tests/textile-reader.native        |  4 ++++
 tests/textile-reader.textile       | 11 +++++++++++
 3 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/src/Text/Pandoc/Readers/Textile.hs b/src/Text/Pandoc/Readers/Textile.hs
index bed13a491..348900d38 100644
--- a/src/Text/Pandoc/Readers/Textile.hs
+++ b/src/Text/Pandoc/Readers/Textile.hs
@@ -493,19 +493,12 @@ escapedInline :: GenParser Char ParserState Inline
 escapedInline = escapedEqs <|> escapedTag
 
 escapedEqs :: GenParser Char ParserState Inline
-escapedEqs = Str <$> (try $ surrounded (string "==") anyChar)
-
--- -- | literal text escaped between == ... ==
--- escapedEqs :: GenParser Char ParserState Inline
--- escapedEqs = try $ do
---   string "=="
---   contents <- manyTill anyChar (try $ string "==")
---   return $ Str contents
+escapedEqs = Str <$> (try $ string "==" *> manyTill anyChar (try $ string "=="))
 
 -- | literal text escaped btw <notextile> tags
 escapedTag :: GenParser Char ParserState Inline
-escapedTag = try $ Str <$>
-  enclosed (string "<notextile>") (try $ string "</notextile>") anyChar
+escapedTag = Str <$>
+  (try $ string "<notextile>" *> manyTill anyChar (try $ string "</notextile>"))
 
 -- | Any special symbol defined in wordBoundaries
 symbol :: GenParser Char ParserState Inline
diff --git a/tests/textile-reader.native b/tests/textile-reader.native
index d9fbc4672..39359d13a 100644
--- a/tests/textile-reader.native
+++ b/tests/textile-reader.native
@@ -27,6 +27,10 @@ Pandoc (Meta {docTitle = [], docAuthors = [], docDate = []})
 ,CodeBlock ("",[],[]) "        this code block is indented by two tabs\n\n    These should not be escaped:  \\$ \\\\ \\> \\[ \\{"
 ,CodeBlock ("",[],[]) "Code block with .bc\n        continued\n    @</\\\n"
 ,Para [Str "Inline",Space,Str "code",Str ":",Space,Code ("",[],[]) "<tt>",Str ",",Space,Code ("",[],[]) "@",Str "."]
+,Header 1 [Str "Notextile"]
+,Para [Str "A",Space,Str "block",Space,Str "of",Space,Str "text",Space,Str "can",Space,Str "be",Space,Str "protected",Space,Str "with",Space,Str "notextile",Space,Str ":"]
+,Para [Str "\nNo *bold* and\n* no bullet\n"]
+,Para [Str "and",Space,Str "inlines",Space,Str "can",Space,Str "be",Space,Str "protected",Space,Str "with",Space,Str "double *equals (=)* markup",Str "."]
 ,Header 1 [Str "Lists"]
 ,Header 2 [Str "Unordered"]
 ,Para [Str "Asterisks",Space,Str "tight",Str ":"]
diff --git a/tests/textile-reader.textile b/tests/textile-reader.textile
index c6450fdfb..adfec90d3 100644
--- a/tests/textile-reader.textile
+++ b/tests/textile-reader.textile
@@ -70,6 +70,17 @@ bc. Code block with .bc
 
 Inline code: @<tt>@, <tt>@</tt>.
 
+h1. Notextile
+
+A block of text can be protected with notextile :
+
+<notextile>
+No *bold* and
+* no bullet
+</notextile>
+
+and inlines can be protected with ==double *equals (=)* markup==.
+
 h1. Lists
 
 h2. Unordered