@@ -136,6 +136,7 @@ block = choice [ codeBlock
136136 , fieldList
137137 , figureBlock
138138 , directive
139+ , comment
139140 , header
140141 , hrule
141142 , lineBlock -- must go before definitionList
@@ -492,6 +493,19 @@ bulletList = B.bulletList . compactify' <$> many1 (listItem bulletListStart)
492493-- directive (e.g. comment, container, compound-paragraph)
493494--
494495
496+comment :: RSTParser Blocks
497+comment = try $ do
498+ getPosition >>= guard . (==1) . sourceColumn
499+ string ".."
500+ skipMany1 spaceChar <|> (() <$ lookAhead newline)
501+ notFollowedBy' directiveLabel
502+ manyTill anyChar blanklines
503+ optional indentedBlock
504+ return mempty
505+
506+directiveLabel :: RSTParser String
507+directiveLabel = many1Till (letter <|> char '-') (try $ string "::")
508+
495509directive :: RSTParser Blocks
496510directive = try $ do
497511 getPosition >>= guard . (==1) . sourceColumn
@@ -500,10 +514,8 @@ directive = try $ do
500514
501515directive' :: RSTParser Blocks
502516directive' = do
503− lookAhead (char '\n') <|> spaceChar
504− skipMany spaceChar
505− label <- option "" $ try
506− $ many1Till (letter <|> char '-') (try $ string "::")
517+ skipMany1 spaceChar
518+ label <- directiveLabel
507519 skipMany spaceChar
508520 top <- many $ satisfy (/='\n')
509521 <|> try (char '\n' <* notFollowedBy blankline <*
@@ -516,7 +528,6 @@ directive' = do
516528 body <- option "" indentedBlock
517529 let body' = body ++ "\n\n"
518530 case label of
519− "" -> return mempty -- comment
520531 "container" -> parseFromString parseBlocks body'
521532 "compound" -> parseFromString parseBlocks body'
522533 "pull-quote" -> B.blockQuote <$> parseFromString parseBlocks body'
@@ -653,7 +664,7 @@ substKey = try $ do
653664 skipMany1 spaceChar
654665 (alt,ref) <- withRaw $ trimInlines . mconcat
655666 <$> enclosed (char '|') (char '|') inline
656− res <- B.toList <$> directive'
667+ res <- B.toList <$> (directive' <|> para)
657668 il <- case res of
658669 -- use alt unless :alt: attribute on image:
659670 [Para [Image [Str "image"] (src,tit)]] ->