@@ -47,7 +47,7 @@ import Text.Pandoc.Builder (Inlines, Blocks, trimInlines, (<>))
4747import qualified Text.Pandoc.Builder as B
4848import Data.Monoid (mconcat, mempty)
4949import Data.Sequence (viewr, ViewR(..))
50−import Data.Char (toLower, isHexDigit)
50+import Data.Char (toLower, isHexDigit, isSpace)
5151
5252-- | Parse reStructuredText string and return Pandoc document.
5353readRST :: ReaderOptions -- ^ Reader options
@@ -335,6 +335,13 @@ indentedBlock = try $ do
335335 optional blanklines
336336 return $ unlines lns
337337
338+quotedBlock :: Parser [Char] st [Char]
339+quotedBlock = try $ do
340+ quote <- lookAhead $ oneOf "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"
341+ lns <- many1 $ lookAhead (char quote) >> anyLine
342+ optional blanklines
343+ return $ unlines lns
344+
338345codeBlockStart :: Parser [Char] st Char
339346codeBlockStart = string "::" >> blankline >> blankline
340347
@@ -342,7 +349,8 @@ codeBlock :: Parser [Char] st Blocks
342349codeBlock = try $ codeBlockStart >> codeBlockBody
343350
344351codeBlockBody :: Parser [Char] st Blocks
345−codeBlockBody = try $ B.codeBlock . stripTrailingNewlines <$> indentedBlock
352+codeBlockBody = try $ B.codeBlock . stripTrailingNewlines <$>
353+ (indentedBlock <|> quotedBlock)
346354
347355lhsCodeBlock :: RSTParser Blocks
348356lhsCodeBlock = try $ do
@@ -513,7 +521,6 @@ directive = try $ do
513521-- TODO: line-block, parsed-literal, table, csv-table, list-table
514522-- date
515523-- include
516−-- class
517524-- title
518525directive' :: RSTParser Blocks
519526directive' = do
@@ -594,6 +601,13 @@ directive' = do
594601 Just t -> B.link (escapeURI $ trim t) ""
595602 $ B.image src "" alt
596603 Nothing -> B.image src "" alt
604+ "class" -> do
605+ let attrs = ("", (splitBy isSpace $ trim top), map (\(k,v) -> (k, trimr v)) fields)
606+ -- directive content or the first immediately following element
607+ children <- case body of
608+ "" -> block
609+ _ -> parseFromString parseBlocks body'
610+ return $ B.divWith attrs children
597611 _ -> return mempty
598612
599613-- TODO: