mirror of
https://github.com/jgm/pandoc.git
synced 2026-09-27 09:55:57 +00:00
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 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude
parent
1995134694
commit
b69753d23e
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user