diff options
| author | John MacFarlane <[email protected]> | 2023-01-15 22:13:57 -0800 |
|---|---|---|
| committer | John MacFarlane <[email protected]> | 2023-01-15 22:32:16 -0800 |
| commit | c6551433b2229130000bd547c879751270430867 (patch) | |
| tree | 49b21f1967c1e86d7f52a90156384014bd4cce4a /pandoc-lua-engine | |
| parent | cdf8c69fb94aeae4f0284a6b534321552d4bed2a (diff) | |
T.P.Chunks changes.
+ Re-use `toTocTree` in constructing `chunkedTOC`.
Previously we used an entirely different function toTOCTree'.
+ Improve `tocToList` so that it avoids empty lists of
items that are omitted because they are below the toc depth.
pandoc-lua-engine:
+ Fix structure tests in light of last change.
T.P.Writers.ChunkedHTML:
+ Reuse `tocToList` in `buildTOC`.
T.P.Writers.EPUB:
+ Adjust EPUB writer for Chunks changes.
Diffstat (limited to 'pandoc-lua-engine')
| -rw-r--r-- | pandoc-lua-engine/test/lua/module/pandoc-structure.lua | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/pandoc-lua-engine/test/lua/module/pandoc-structure.lua b/pandoc-lua-engine/test/lua/module/pandoc-structure.lua index 4d59d9e6a..f5faa8377 100644 --- a/pandoc-lua-engine/test/lua/module/pandoc-structure.lua +++ b/pandoc-lua-engine/test/lua/module/pandoc-structure.lua @@ -99,40 +99,40 @@ return { end), test('returns a toc for a chunked doc', function () local doc = pandoc.Pandoc { - pandoc.Header(1, 'First'), + pandoc.Header(1, 'First', {id='first'}), pandoc.Para('A sentence placed below the first structure.'), - pandoc.Header(2, 'Subsection'), + pandoc.Header(2, 'Subsection', {id='subsection'}), pandoc.Para('Mauris ac felis vel velit tristique imperdiet.'), - pandoc.Header(1, 'Second'), + pandoc.Header(1, 'Second', {id='second'}), pandoc.Para('Integer placerat tristique nisl.') } local chunked = structure.split_into_chunks(doc, {chunk_level = 2}) assert.are_equal( structure.table_of_contents(chunked), pandoc.BulletList{ - {pandoc.Plain('First'), - pandoc.BulletList{{pandoc.Plain 'Subsection'}} + {pandoc.Plain({pandoc.Link('First', 'chunk-001', '', {id='toc-first'})}), + pandoc.BulletList{{pandoc.Plain({pandoc.Link('Subsection', 'chunk-002', '', {id='toc-subsection'})})}} }, - {pandoc.Plain('Second')} + {pandoc.Plain({pandoc.Link('Second', 'chunk-003', '', {id='toc-second'})})} } ) end), test('respects toc-depth option', function () local doc = pandoc.Pandoc { - pandoc.Header(1, 'First'), + pandoc.Header(1, 'First', {id='first'}), pandoc.Para('A sentence placed below the first structure.'), - pandoc.Header(2, 'Subsection'), + pandoc.Header(2, 'Subsection', {id='subsection'}), pandoc.Para('Mauris ac felis vel velit tristique imperdiet.'), - pandoc.Header(1, 'Second'), + pandoc.Header(1, 'Second', {id='second'}), pandoc.Para('Integer placerat tristique nisl.') } local chunked = structure.split_into_chunks(doc) assert.are_equal( + structure.table_of_contents(chunked, {toc_depth = 1}), pandoc.BulletList{ - {pandoc.Plain('First')}, - {pandoc.Plain('Second')} - }, - structure.table_of_contents(chunked, {toc_depth = 1}) + {pandoc.Plain({pandoc.Link('First', 'chunk-001', '', {id='toc-first'})})}, + {pandoc.Plain({pandoc.Link('Second', 'chunk-002', '', {id='toc-second'})})} + } ) end), }, |
