RST writer: ensure blank line before directives.

Closes #11162.
This commit is contained in:
John MacFarlane
2025-09-24 21:32:08 +02:00
parent bdab9915ad
commit 9024df9348
2 changed files with 23 additions and 4 deletions
+4 -4
View File
@@ -251,8 +251,8 @@ blockToRST (Div (ident,classes,_kvs) bs) = do
let admonition = case classes of
(cl:_)
| cl `elem` admonitions
-> ".. " <> literal cl <> "::"
cls -> ".. container::" <> space <>
-> blankline <> ".. " <> literal cl <> "::"
cls -> blankline <> ".. container::" <> space <>
literal (T.unwords (filter (/= "container") cls))
-- if contents start with block quote, we need to insert
-- an empty comment to fix the indentation point (#10236)
@@ -323,7 +323,7 @@ blockToRST (CodeBlock (_,classes,kvs) str) = do
c `notElem` ["sourceCode","literate","numberLines",
"number-lines","example"]] of
[] -> "::"
(lang:_) -> (".. code:: " <> literal lang) $$ numberlines)
(lang:_) -> (blankline <> ".. code:: " <> literal lang) $$ numberlines)
$+$ nest 3 (literal str) $$ blankline
blockToRST (BlockQuote blocks) = do
contents <- blockListToRST blocks
@@ -358,7 +358,7 @@ blockToRST (Table _attrs blkCapt specs thead tbody tfoot) = do
return $ blankline $$
(if null caption || isList
then tbl
else (".. table:: " <> caption') $$ blankline $$ nest 3 tbl) $$
else (blankline <> ".. table:: " <> caption') $$ blankline $$ nest 3 tbl) $$
blankline
blockToRST (BulletList items) = do
contents <- mapM bulletListItemToRST items
+19
View File
@@ -0,0 +1,19 @@
```
% pandoc -f native -t rst
[ BulletList
[ [ Plain [ Str "list" ]
, CodeBlock ( "" , [ "ruby" ] , [] ) "code = 7 # comment"
]
, [ Plain [ Str "second" , Space , Str "item" ] ]
]
]
^D
- list
.. code:: ruby
code = 7 # comment
- second item
```