Skip to content

Links Header Missing from ToC #62

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
MeanderingProgrammer opened this issue Mar 27, 2024 · 1 comment
Closed

Links Header Missing from ToC #62

MeanderingProgrammer opened this issue Mar 27, 2024 · 1 comment

Comments

@MeanderingProgrammer
Copy link
Contributor

MeanderingProgrammer commented Mar 27, 2024

Hi, thanks for creating this awesome script to automate document generation!

When I run this script I notice that it adds a Links heading but does not add this to the ToC section.

This happens in the example for this repo as well: https://github.com/kdheepak/panvimdoc/blob/main/doc/panvimdoc.txt

Where there is a heading at the bottom "13. Links", but its not in the ToC at the top.

Based on this line: https://github.com/kdheepak/panvimdoc/blob/main/scripts/panvimdoc.lua#L173, this does not seem intentional.

table.insert(toc, { 1, left, right_link })

I believe this happens because of the order the Writer calls methods in: https://github.com/kdheepak/panvimdoc/blob/main/scripts/panvimdoc.lua#L202C1-L206C32

local d = blocks(doc.blocks)
local toc = renderToc()
local notes = renderNotes()
local title = renderTitle()
local footer = renderFooter()

Here the toc gets generated before the notes and as a result appending to the toc table in renderToc has no effect.

I believe the fix for this is just to re-order these calls so that renderNotes is called before renderToc:

local d = blocks(doc.blocks)
local notes = renderNotes()
local toc = renderToc()
local title = renderTitle()
local footer = renderFooter()
@MeanderingProgrammer
Copy link
Contributor Author

I've created a PR with this minor order change: #63

Feel free to close if this is not an issue!

kdheepak pushed a commit that referenced this issue Mar 27, 2024
# Details

Problem outlined in: #62

Link header is added to `toc` table, however this happens after the
ToC is rendered so it is effectively ignored.

Change rendering order so links are added before the ToC.

Updated a unit test case to catch this.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant