Inline elements with a content body (emph, strong, underline, strike, sub, super, smallcaps, highlight, link, lower, upper, ...) failed with a parse error when the body contained a paragraph break or other block content, since inline handlers parse their bodies with pInlines, which cannot consume paragraph breaks. Example: ``` #emph[hi there] ``` Generalize `fixNesting`, which already hoisted single block children out of inline elements (#11017): the content of an inline element is now split at paragraph breaks and at block children; inline runs are wrapped back in the element, and block children are pulled out with the styling applied to their own contents when they have a body. A pandoc inline cannot span paragraphs, so this is the closest structural rendering; the paragraph structure is preserved. Remove the kludge we used for `#quote`, using `getInlineBody`; it is no longer needed with this general fix.
1.5 KiB
1.5 KiB
Highlighted text should be read as a mark span, round-tripping with
the Typst writer.
% pandoc -f typst -t native
#highlight[hello]
^D
[ Para [ Span ( "" , [ "mark" ] , [] ) [ Str "hello" ] ] ]
% pandoc -f markdown -t typst
[hello]{.mark}
^D
#highlight[hello]
% pandoc -f typst -t typst
#highlight[hello]
^D
#highlight[hello]
highlight may also wrap multiple paragraphs. A pandoc inline cannot
span paragraphs, so the body is split at paragraph breaks and each
paragraph is read as a mark span. The same holds for other
inline-styling elements, such as emph.
% pandoc -f typst -t native
Before.
#highlight[
Para one.
Para two.
]
^D
[ Para [ Str "Before." ]
, Para
[ Span
( "" , [ "mark" ] , [] )
[ SoftBreak , Str "Para" , Space , Str "one." ]
]
, Para
[ Span
( "" , [ "mark" ] , [] ) [ Str "Para" , Space , Str "two." ]
]
]
% pandoc -f typst -t typst
Before.
#highlight[
Para one.
Para two.
]
^D
Before.
#highlight[ Para one.]
#highlight[Para two.]
Highlight bodies may contain math, inline or display, without breaking the reader.
% pandoc -f typst -t native
#highlight[$ a = b $]
^D
[ Para
[ Span ( "" , [ "mark" ] , [] ) [ Math DisplayMath "a = b" ]
]
]
% pandoc -f typst -t native
#highlight[
Para.
$ c = d $
]
^D
[ Para
[ Span ( "" , [ "mark" ] , [] ) [ SoftBreak , Str "Para." ]
]
, Para
[ Span ( "" , [ "mark" ] , [] ) [ Math DisplayMath "c = d" ]
]
]