git.iko.soy/typeable/pandoc
on master help sign in
Docbook writer: Handle admonition titles from Markdown reader
70c7c57Jan Tojnar
src/Text/Pandoc/Writers/Docbook.hs+2
@@ -201,6 +201,8 @@ blockToDocbook opts (Div (ident,classes,_) bs) = do
201 (l:_) | l `elem` admonitions -> do
201 (l:_) | l `elem` admonitions -> do
202 let (mTitleBs, bodyBs) =
202 let (mTitleBs, bodyBs) =
203 case bs of
203 case bs of
204+ -- Matches AST produced by the DocBook reader → Markdown writer → Markdown reader chain.
205+ (Div (_,["title"],_) [Para ts] : rest) -> (Just (inlinesToDocbook opts ts), rest)
204 -- Matches AST produced by the Docbook reader.
206 -- Matches AST produced by the Docbook reader.
205 (Div (_,["title"],_) ts : rest) -> (Just (blocksToDocbook opts ts), rest)
207 (Div (_,["title"],_) ts : rest) -> (Just (blocksToDocbook opts ts), rest)
206 _ -> (Nothing, bs)
208 _ -> (Nothing, bs)
test/Tests/Writers/Docbook.hs+14
@@ -93,6 +93,20 @@ tests = [ testGroup "line blocks"
93 , " </para>"
93 , " </para>"
94 , "</attention>"
94 , "</attention>"
95 ]
95 ]
96+ , "admonition-with-title-in-para" =:
97+ divWith ("foo", ["attention"], []) (
98+ divWith ("foo", ["title"], [])
99+ (para "This is title") <>
100+ para "This is a test"
101+ )
102+ =?> unlines
103+ [ "<attention id=\"foo\">"
104+ , " <title>This is title</title>"
105+ , " <para>"
106+ , " This is a test"
107+ , " </para>"
108+ , "</attention>"
109+ ]
96 , "single-child" =:
110 , "single-child" =:
97 divWith ("foo", [], []) (para "This is a test")
111 divWith ("foo", [], []) (para "This is a test")
98 =?> unlines
112 =?> unlines