mirror of
https://github.com/jgm/pandoc.git
synced 2026-08-29 01:41:20 +08:00
Docx reader: fix anchor in header after anchor (#9626)
When the last parPart before a header was a bookmark, no span with an anchor was added for a bookmark in the header. But the function that adds header anchors to the anchor map, needs a span with an anchor. So this commit adds that span.
This commit is contained in:
@@ -439,11 +439,10 @@ parPartToInlines' (BookMark _ anchor) =
|
||||
-- avoid an extra pass.
|
||||
immedPrevAnchor <- gets docxImmedPrevAnchor
|
||||
case immedPrevAnchor of
|
||||
Just prevAnchor -> do
|
||||
unless inHdrBool
|
||||
(modify $ \s -> s { docxAnchorMap = M.insert anchor prevAnchor anchorMap})
|
||||
Just prevAnchor | not inHdrBool -> do
|
||||
(modify $ \s -> s { docxAnchorMap = M.insert anchor prevAnchor anchorMap})
|
||||
return mempty
|
||||
Nothing -> do
|
||||
_ -> do
|
||||
exts <- asks (readerExtensions . docxOptions)
|
||||
let newAnchor =
|
||||
if not inHdrBool && anchor `elem` M.elems anchorMap
|
||||
|
||||
@@ -235,6 +235,10 @@ tests = [ testGroup "document"
|
||||
"collapse overlapping targets (anchor spans)"
|
||||
"docx/overlapping_targets.docx"
|
||||
"docx/overlapping_targets.native"
|
||||
, testCompare
|
||||
"anchor in header after anchor"
|
||||
"docx/anchor_header_after_anchor.docx"
|
||||
"docx/anchor_header_after_anchor.native"
|
||||
, testCompare
|
||||
"text in shape format"
|
||||
"docx/text_in_shape_format.docx"
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,6 @@
|
||||
[Para [Link ("",[],[]) [Str "A",Space,Str "link",Space,Str "to",Space,Str "the",Space,Str "bookmark"] ("#referenced-title" , "")]
|
||||
,Para [Strong [Str "Accomplices:"]]
|
||||
,Para [Str "There",Space,Str "are",Space,Str "bookmarks",Space,Str "around",Space,Str "here."]
|
||||
,Para []
|
||||
,Header 1 ("referenced-title",[],[]) [Str "Referenced" ,Space ,Str "title"]
|
||||
,Para [Str "Content"]]
|
||||
Reference in New Issue
Block a user