summaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers/RST.hs
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2012-09-29 17:25:14 -0400
committerJohn MacFarlane <jgm@berkeley.edu>2012-09-29 17:25:14 -0400
commit93600ec9b82f9e7ffd2b9b25eb910f022b1a8e6a (patch)
tree0897b1471a866dfcbc6ec4a25591a90f70f9361d /src/Text/Pandoc/Readers/RST.hs
parent93e92a47169ee84e1a42c68f9b890314f8866de1 (diff)
RST reader: Folded default-role parser into directive.
Diffstat (limited to 'src/Text/Pandoc/Readers/RST.hs')
-rw-r--r--src/Text/Pandoc/Readers/RST.hs29
1 files changed, 8 insertions, 21 deletions
diff --git a/src/Text/Pandoc/Readers/RST.hs b/src/Text/Pandoc/Readers/RST.hs
index 2dfdd5377..a9c31b64c 100644
--- a/src/Text/Pandoc/Readers/RST.hs
+++ b/src/Text/Pandoc/Readers/RST.hs
@@ -137,7 +137,6 @@ block = choice [ codeBlock
, imageBlock
, figureBlock
, customCodeBlock
- , defaultRoleBlock
, directive
, header
, hrule
@@ -533,24 +532,6 @@ bulletList :: RSTParser Blocks
bulletList = B.bulletList . compactify' <$> many1 (listItem bulletListStart)
--
--- default-role block
---
-
-defaultRoleBlock :: RSTParser Blocks
-defaultRoleBlock = try $ do
- 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 . trim
- updateState $ \s -> s { stateRstDefaultRole =
- if null role
- then stateRstDefaultRole defaultParserState
- else role
- }
- -- skip body of the directive if it exists
- skipMany $ blanklines <|> (spaceChar >> manyTill anyChar newline)
- return mempty
-
---
-- directive (e.g. comment, container, compound-paragraph)
--
@@ -559,7 +540,8 @@ directive = try $ do
string ".."
lookAhead (char '\n') <|> spaceChar
skipMany spaceChar
- label <- option "" $ try $ many1Till letter (try $ string "::")
+ label <- option "" $ try
+ $ many1Till (letter <|> char '-') (try $ string "::")
skipMany spaceChar
top <- many $ satisfy (/='\n')
<|> try (char '\n' <* notFollowedBy blankline <*
@@ -572,7 +554,7 @@ directive = try $ do
body <- option "" indentedBlock
let body' = body ++ "\n\n"
case label of
- "" -> return mempty
+ "" -> return mempty -- comment
"container" -> parseFromString parseBlocks body'
"compound" -> parseFromString parseBlocks body'
"pull-quote" -> B.blockQuote <$> parseFromString parseBlocks body'
@@ -580,6 +562,11 @@ directive = try $ do
"highlights" -> B.blockQuote <$> parseFromString parseBlocks body'
"rubric" -> B.para . B.strong <$> parseFromString
(trimInlines . mconcat <$> many inline) top
+ "default-role" -> mempty <$ updateState (\s ->
+ s { stateRstDefaultRole =
+ case trim top of
+ "" -> stateRstDefaultRole def
+ role -> role })
"math" -> return $ B.para $ mconcat $ map B.displayMath
$ toChunks $ top ++ "\n\n" ++ body
_ -> return mempty