diff options
author | John MacFarlane <jgm@berkeley.edu> | 2017-02-07 23:07:35 +0100 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2017-02-07 23:18:56 +0100 |
commit | e4d7bed51ceaf2b5b7cb2773fdc6060ca2818fe3 (patch) | |
tree | 424d0907c3b12a7b11744ad2b7d5c76395e1fd48 /src/Text | |
parent | 857d35fce4e364039092a9da37b93b67bd566bb6 (diff) | |
download | pandoc-e4d7bed51ceaf2b5b7cb2773fdc6060ca2818fe3.tar.gz |
RST reader: Improved admonition support.
* We no longer add an "admonition" class, we just use the
class for the type of admonition, "note" for example.
* We put the word corresponding to the label in a paragraph
inside a div at the beginning of the admonition with class
"admonition-title".
* This is about as close as we can get to RST's own output.
See #223.
Diffstat (limited to 'src/Text')
-rw-r--r-- | src/Text/Pandoc/Readers/RST.hs | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/Text/Pandoc/Readers/RST.hs b/src/Text/Pandoc/Readers/RST.hs index 85db52e02..3fbb533a8 100644 --- a/src/Text/Pandoc/Readers/RST.hs +++ b/src/Text/Pandoc/Readers/RST.hs @@ -46,7 +46,7 @@ import Text.Printf ( printf ) import Text.Pandoc.Builder (Inlines, Blocks, trimInlines) import qualified Text.Pandoc.Builder as B import Data.Sequence (viewr, ViewR(..)) -import Data.Char (toLower, isHexDigit, isSpace) +import Data.Char (toLower, isHexDigit, isSpace, toUpper) import Data.Monoid ((<>)) import Control.Monad.Except (throwError) import Text.Pandoc.Class (PandocMonad, warning, readFileFromDirs, @@ -633,12 +633,14 @@ directive' = do "highlights" -> B.blockQuote <$> parseFromString parseBlocks body' "rubric" -> B.para . B.strong <$> parseInlineFromString top _ | label `elem` ["attention","caution","danger","error","hint", - "important","note","tip","warning"] -> + "important","note","tip","warning","admonition"] -> do bod <- parseFromString parseBlocks $ top ++ "\n\n" ++ body' - return $ B.divWith ("",["admonition", label],[]) bod - "admonition" -> - do bod <- parseFromString parseBlocks $ top ++ "\n\n" ++ body' - return $ B.divWith ("",["admonition"],[]) bod + let lab = case label of + "admonition" -> mempty + (l:ls) -> B.divWith ("",["admonition-title"],[]) + (B.para (B.str (toUpper l : ls))) + [] -> mempty + return $ B.divWith ("",[label],[]) (lab <> bod) "sidebar" -> do let subtit = maybe "" trim $ lookup "subtitle" fields tit <- B.para . B.strong <$> parseInlineFromString |