From b69753d23ebe1d7d1dbb93eaf13b9865cfb02bea Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Wed, 16 Sep 2026 16:59:13 +0000 Subject: [PATCH] Chunks: remove vestigial nav-path attribute and rmNavAttrs walk. The nav-path attribute was added to each chunk's Div and then stripped again by a full walk over every chunk, without ever being read: since ec23d938e0 replaced attribute-based navigation with the chunkUp/chunkPrev/chunkNext fields, nothing consumes nav-* attributes. Removing the attribute and the rmNavAttrs pass saves a whole traversal of the chunked document in splitIntoChunks. Co-Authored-By: Claude --- src/Text/Pandoc/Chunks.hs | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/src/Text/Pandoc/Chunks.hs b/src/Text/Pandoc/Chunks.hs index 2975e1881..cb8756cee 100644 --- a/src/Text/Pandoc/Chunks.hs +++ b/src/Text/Pandoc/Chunks.hs @@ -57,8 +57,7 @@ splitIntoChunks :: PathTemplate -- ^ Template for filepath splitIntoChunks pathTemplate numberSections mbBaseLevel chunklev (Pandoc meta blocks) = addNav . - fixInternalReferences . - walk rmNavAttrs $ + fixInternalReferences $ ChunkedDoc{ chunkedMeta = meta , chunkedChunks = chunks , chunkedTOC = tocTree } @@ -214,10 +213,9 @@ makeChunks chunklev pathTemplate meta = secsToChunks 1 , chunkPrev = Nothing , chunkUnlisted = "unlisted" `elem` classes , chunkContents = - [Div (divid,"section":classes,kvs') (h : bs)] + [Div (divid,"section":classes,kvs) (h : bs)] } - where kvs' = kvs ++ [("nav-path", T.pack chunkpath)] - secnum = lookup "number" kvs + where secnum = lookup "number" kvs chunkpath = resolvePathTemplate pathTemplate chunknum (stringifyInlines ils) divid @@ -247,14 +245,6 @@ makeChunks chunklev pathTemplate meta = secsToChunks 1 -- should not happen --- Remove some attributes we added just to construct chunkNext etc. -rmNavAttrs :: Block -> Block -rmNavAttrs (Div (ident,classes,kvs) bs) = - Div (ident,classes,filter (not . isNavAttr) kvs) bs - where - isNavAttr (k,_) = "nav-" `T.isPrefixOf` k -rmNavAttrs b = b - resolvePathTemplate :: PathTemplate -> Int -- ^ Chunk number -> Text -- ^ Stringified heading text