From 188c444990f7ae70556f8bfc94b25c8dc7f77f98 Mon Sep 17 00:00:00 2001 From: John MacFarlane <jgm@berkeley.edu> Date: Fri, 25 Sep 2020 09:05:40 -0700 Subject: [PATCH] RST reader: apply `.. class::` directly to following Header. rather than creating a surrounding Div. Closes #6699. --- src/Text/Pandoc/Readers/RST.hs | 7 ++++++- test/command/6699.md | 13 +++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 test/command/6699.md diff --git a/src/Text/Pandoc/Readers/RST.hs b/src/Text/Pandoc/Readers/RST.hs index 50947c1be..eeb3d1389 100644 --- a/src/Text/Pandoc/Readers/RST.hs +++ b/src/Text/Pandoc/Readers/RST.hs @@ -758,7 +758,12 @@ directive' = do children <- case body of "" -> block _ -> parseFromString' parseBlocks body' - return $ B.divWith attrs children + return $ + case B.toList children of + [Header lev attrs' ils] + | T.null body -> -- # see #6699 + B.headerWith (attrs' <> attrs) lev (B.fromList ils) + _ -> B.divWith attrs children other -> do pos <- getPosition logMessage $ SkippedContent (".. " <> other) pos diff --git a/test/command/6699.md b/test/command/6699.md new file mode 100644 index 000000000..347e04577 --- /dev/null +++ b/test/command/6699.md @@ -0,0 +1,13 @@ +``` +% pandoc -f rst -t native +.. class:: allowframebreaks + +title +----- + +text +^D +[Header 1 ("title",["allowframebreaks"],[]) [Str "title"] +,Para [Str "text"]] +``` +