@@ -136,6 +136,7 @@ block = choice [ codeBlock
136 , fieldList
136 , fieldList
137 , figureBlock
137 , figureBlock
138 , directive
138 , directive
141 , lineBlock -- must go before definitionList
142 , lineBlock -- must go before definitionList
@@ -492,6 +493,19 @@ bulletList = B.bulletList . compactify' <$> many1 (listItem bulletListStart)
492-- directive (e.g. comment, container, compound-paragraph)
493-- directive (e.g. comment, container, compound-paragraph)
496+comment :: RSTParser Blocks
498+ getPosition >>= guard . (==1) . sourceColumn
500+ skipMany1 spaceChar <|> (() <$ lookAhead newline)
501+ notFollowedBy' directiveLabel
502+ manyTill anyChar blanklines
503+ optional indentedBlock
506+directiveLabel :: RSTParser String
507+directiveLabel = many1Till (letter <|> char '-') (try $ string "::")
495directive :: RSTParser Blocks
509directive :: RSTParser Blocks
496directive = try $ do
510directive = try $ do
497 getPosition >>= guard . (==1) . sourceColumn
511 getPosition >>= guard . (==1) . sourceColumn
@@ -500,10 +514,8 @@ directive = try $ do
501directive' :: RSTParser Blocks
515directive' :: RSTParser Blocks
502directive' = do
516directive' = do
503− lookAhead (char '\n') <|> spaceChar
504− skipMany spaceChar
517+ skipMany1 spaceChar
505− label <- option "" $ try
518+ label <- directiveLabel
506− $ many1Till (letter <|> char '-') (try $ string "::")
507 skipMany spaceChar
519 skipMany spaceChar
508 top <- many $ satisfy (/='\n')
520 top <- many $ satisfy (/='\n')
509 <|> try (char '\n' <* notFollowedBy blankline <*
521 <|> try (char '\n' <* notFollowedBy blankline <*
@@ -516,7 +528,6 @@ directive' = do
516 body <- option "" indentedBlock
528 body <- option "" indentedBlock
517 let body' = body ++ "\n\n"
529 let body' = body ++ "\n\n"
518 case label of
530 case label of
519− "" -> return mempty -- comment
520 "container" -> parseFromString parseBlocks body'
531 "container" -> parseFromString parseBlocks body'
521 "compound" -> parseFromString parseBlocks body'
532 "compound" -> parseFromString parseBlocks body'
522 "pull-quote" -> B.blockQuote <$> parseFromString parseBlocks body'
533 "pull-quote" -> B.blockQuote <$> parseFromString parseBlocks body'
@@ -653,7 +664,7 @@ substKey = try $ do
653 skipMany1 spaceChar
664 skipMany1 spaceChar
654 (alt,ref) <- withRaw $ trimInlines . mconcat
665 (alt,ref) <- withRaw $ trimInlines . mconcat
655 <$> enclosed (char '|') (char '|') inline
666 <$> enclosed (char '|') (char '|') inline
656− res <- B.toList <$> directive'
667+ res <- B.toList <$> (directive' <|> para)
657 il <- case res of
668 il <- case res of
658 -- use alt unless :alt: attribute on image:
669 -- use alt unless :alt: attribute on image:
659 [Para [Image [Str "image"] (src,tit)]] ->
670 [Para [Image [Str "image"] (src,tit)]] ->