diff --git a/src/Text/Pandoc/Transforms.hs b/src/Text/Pandoc/Transforms.hs index daa6e6d99..fdaad33e3 100644 --- a/src/Text/Pandoc/Transforms.hs +++ b/src/Text/Pandoc/Transforms.hs @@ -154,6 +154,11 @@ headerShift n (Pandoc meta (Header m _ ils : bs)) | n < 0 , m + n == 0 = headerShift n $ B.setTitle (B.fromList ils) $ Pandoc meta bs +-- for this case, see #10459: +headerShift n (Pandoc meta (Div attr@(_,"section":_,_) (Header m _ ils : as) : bs)) + | n < 0 + , m + n == 0 = headerShift n $ + B.setTitle (B.fromList ils) $ Pandoc meta (Div attr as : bs) headerShift n (Pandoc meta bs) = Pandoc meta (walk shift bs) where diff --git a/test/command/10459.md b/test/command/10459.md new file mode 100644 index 000000000..b45950cf0 --- /dev/null +++ b/test/command/10459.md @@ -0,0 +1,11 @@ +``` +% pandoc -s --shift-heading-level-by=-1 -f djot -t native +# hi +^D +Pandoc + Meta + { unMeta = + fromList [ ( "title" , MetaInlines [ Str "hi" ] ) ] + } + [ Div ( "hi" , [ "section" ] , [] ) [] ] +```