@@ -185,22 +185,22 @@ block = choice [ codeBlock
185-- field list
185-- field list
188−rawFieldListItem :: String -> RSTParser (String, String)
188+rawFieldListItem :: Int -> RSTParser (String, String)
189−rawFieldListItem indent = try $ do
189+rawFieldListItem minIndent = try $ do
190− string indent
190+ indent <- length <$> many (char ' ')
191+ guard $ indent >= minIndent
192 name <- many1Till (noneOf "\n") (char ':')
193 name <- many1Till (noneOf "\n") (char ':')
193 (() <$ lookAhead newline) <|> skipMany1 spaceChar
194 (() <$ lookAhead newline) <|> skipMany1 spaceChar
194 first <- anyLine
195 first <- anyLine
195− rest <- option "" $ try $ do lookAhead (string indent >> spaceChar)
196+ rest <- option "" $ try $ do lookAhead (count indent (char ' ') >> spaceChar)
196 indentedBlock
197 indentedBlock
197 let raw = (if null first then "" else (first ++ "\n")) ++ rest ++ "\n"
198 let raw = (if null first then "" else (first ++ "\n")) ++ rest ++ "\n"
198− return (name, raw)
199+ return (name, trimr raw)
200−fieldListItem :: String
201− -> RSTParser (Inlines, [Blocks])
201+fieldListItem :: Int -> RSTParser (Inlines, [Blocks])
202−fieldListItem indent = try $ do
202+fieldListItem minIndent = try $ do
203− (name, raw) <- rawFieldListItem indent
203+ (name, raw) <- rawFieldListItem minIndent
204 let term = B.str name
204 let term = B.str name
205 contents <- parseFromString parseBlocks raw
205 contents <- parseFromString parseBlocks raw
206 optional blanklines
206 optional blanklines
@@ -208,7 +208,7 @@ fieldListItem indent = try $ do
209fieldList :: RSTParser Blocks
209fieldList :: RSTParser Blocks
210fieldList = try $ do
210fieldList = try $ do
211− indent <- lookAhead $ many spaceChar
211+ indent <- length <$> lookAhead (many spaceChar)
212 items <- many1 $ fieldListItem indent
212 items <- many1 $ fieldListItem indent
213 case items of
213 case items of
214 [] -> return mempty
214 [] -> return mempty
@@ -521,11 +521,11 @@ directive' = do
521 skipMany spaceChar
521 skipMany spaceChar
522 top <- many $ satisfy (/='\n')
522 top <- many $ satisfy (/='\n')
523 <|> try (char '\n' <*
523 <|> try (char '\n' <*
524− notFollowedBy' (rawFieldListItem " ") <*
524+ notFollowedBy' (rawFieldListItem 3) <*
525 count 3 (char ' ') <*
525 count 3 (char ' ') <*
526 notFollowedBy blankline)
526 notFollowedBy blankline)
528− fields <- many $ rawFieldListItem " "
528+ fields <- many $ rawFieldListItem 3
529 body <- option "" $ try $ blanklines >> indentedBlock
529 body <- option "" $ try $ blanklines >> indentedBlock
530 optional blanklines
530 optional blanklines
531 let body' = body ++ "\n\n"
531 let body' = body ++ "\n\n"
@@ -576,6 +576,9 @@ directive' = do
576 role -> role })
576 role -> role })
577 "code" -> codeblock (lookup "number-lines" fields) (trim top) body
577 "code" -> codeblock (lookup "number-lines" fields) (trim top) body
578 "code-block" -> codeblock (lookup "number-lines" fields) (trim top) body
578 "code-block" -> codeblock (lookup "number-lines" fields) (trim top) body
580+ let attribs = ("", ["aafig"], fields)
581+ return $ B.codeBlockWith attribs $ stripTrailingNewlines body
579 "math" -> return $ B.para $ mconcat $ map B.displayMath
582 "math" -> return $ B.para $ mconcat $ map B.displayMath
580 $ toChunks $ top ++ "\n\n" ++ body
583 $ toChunks $ top ++ "\n\n" ++ body
581 "figure" -> do
584 "figure" -> do