aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Text/Pandoc/Readers/RST.hs5
-rw-r--r--tests/rst-reader.native5
-rw-r--r--tests/rst-reader.rst10
3 files changed, 18 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Readers/RST.hs b/src/Text/Pandoc/Readers/RST.hs
index 2fbf11cf7..35fe5d768 100644
--- a/src/Text/Pandoc/Readers/RST.hs
+++ b/src/Text/Pandoc/Readers/RST.hs
@@ -539,13 +539,16 @@ bulletList = many1 (listItem bulletListStart) >>=
defaultRoleBlock :: GenParser Char ParserState Block
defaultRoleBlock = try $ do
- string ".. default-role:: "
+ string ".. default-role::"
+ -- doesn't enforce any restrictions on the role name; embedded spaces shouldn't be allowed, for one
role <- manyTill anyChar newline >>= return . removeLeadingTrailingSpace
updateState $ \s -> s { stateRstDefaultRole =
if null role
then stateRstDefaultRole defaultParserState
else role
}
+ -- skip body of the directive if it exists
+ many $ blanklines <|> (spaceChar >> manyTill anyChar newline)
return Null
--
diff --git a/tests/rst-reader.native b/tests/rst-reader.native
index 5bb646f61..bf794c849 100644
--- a/tests/rst-reader.native
+++ b/tests/rst-reader.native
@@ -315,6 +315,9 @@ Pandoc (Meta {docTitle = [Str "Pandoc",Space,Str "Test",Space,Str "Suite",Str ":
,Para [Str "All",Space,Str "done",Str "."]
,Header 1 [Str "Default",Str "-",Str "Role"]
,Para [Str "Try",Space,Str "changing",Space,Str "the",Space,Str "default",Space,Str "role",Space,Str "to",Space,Str "a",Space,Str "few",Space,Str "different",Space,Str "things",Str "."]
+,Header 2 [Str "Doesn",Str "\8217",Str "t",Space,Str "Break",Space,Str "Title",Space,Str "Parsing"]
,Para [Str "Inline",Space,Str "math",Str ":",Space,Math InlineMath "E=mc^2",Space,Str "or",Space,Math InlineMath "E=mc^2",Space,Str "or",Space,Math InlineMath "E=mc^2",Str ".",Space,Str "Other",Space,Str "roles",Str ":",Space,Superscript [Str "super"],Str ",",Space,Subscript [Str "sub"],Str "."]
+,Para [Math DisplayMath "\\alpha = beta",Math DisplayMath "E = mc^2"]
,Para [Str "Some",Space,Superscript [Str "of"],Space,Str "these",Space,Superscript [Str "words"],Space,Str "are",Space,Str "in",Space,Superscript [Str "superscript"],Str "."]
-,Para [Str "Reset",Space,Str "default",Str "-",Str "role",Space,Str "to",Space,Str "the",Space,Str "default",Space,Str "default",Str "."]]
+,Para [Str "Reset",Space,Str "default",Str "-",Str "role",Space,Str "to",Space,Str "the",Space,Str "default",Space,Str "default",Str "."]
+,Para [Str "And",Space,Str "now",Space,Str "`",Str "some",Str "-",Str "invalid",Str "-",Str "string",Str "-",Str "3231231",Str "`",Space,Str "is",Space,Str "nonsense",Str "."]]
diff --git a/tests/rst-reader.rst b/tests/rst-reader.rst
index d06d70907..abe6d4f69 100644
--- a/tests/rst-reader.rst
+++ b/tests/rst-reader.rst
@@ -572,9 +572,17 @@ Try changing the default role to a few different things.
.. default-role:: math
+Doesn't Break Title Parsing
+---------------------------
+
Inline math: `E=mc^2` or :math:`E=mc^2` or `E=mc^2`:math:.
Other roles: :sup:`super`, `sub`:sub:.
+.. math::
+ \alpha = beta
+
+ E = mc^2
+
.. default-role:: sup
Some `of` these :sup:`words` are in `superscript`:sup:.
@@ -583,3 +591,5 @@ Reset default-role to the default default.
.. default-role::
+And now `some-invalid-string-3231231` is nonsense.
+