Skip to content
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

Collapsible nav-toc does not work when the map using "chunk=to-content" attribute #52

Closed
bing-10 opened this issue Sep 1, 2022 · 8 comments
Labels
Milestone

Comments

@bing-10
Copy link

bing-10 commented Sep 1, 2022

Hi, @infotexture

I applied @chunk="to-content" to the map in order to generate a single html. However, I found that the collapsible nav-toc did not work. In specific, the nav-toc item of current topic cannot be highlighted.

I have figured it out that this is because the class "active" cannot be added to the current nav item in this kind of transformation, but I have no idea on how to modify it to make the collapsible nav-toc compatible with single html output.

Could you please give me some suggestions?

@jason-fox
Copy link
Collaborator

That is a bug. There needs to be some defensive code added to avoid it. Just add

+ <xsl:when test="not(.)">
+ </xsl:when>
<xsl:when test="normalize-space($title)">
<xsl:variable name="id" select="dita-ot:generate-html-id(.)"/>

At line 561 of nav.xsl like this

@jason-fox jason-fox added the bug label Sep 1, 2022
@jason-fox
Copy link
Collaborator

Note that there is still a timing problem with using a side-toc with @chunk="to-content" , in that the nav bar is rendered before the content, so that if the main content is still in the process of rendering, the anchors for the nav won't be available and navigation won't work until all of the document is rendered.

@bing-10
Copy link
Author

bing-10 commented Sep 1, 2022

That is a bug. There needs to be some defensive code added to avoid it. Just add

+ <xsl:when test="not(.)">
+ </xsl:when>
<xsl:when test="normalize-space($title)">
<xsl:variable name="id" select="dita-ot:generate-html-id(.)"/>

At line 561 of nav.xsl like this

Thank you. I have added it as you adviced, but it seemed that there are no significant changes in the output.

@bing-10
Copy link
Author

bing-10 commented Sep 1, 2022

Note that there is still a timing problem with using a side-toc with @chunk="to-content" , in that the nav bar is rendered before the content, so that if the main content is still in the process of rendering, the anchors for the nav won't be available and navigation won't work until all of the document is rendered.

I did find that question. With @chunk="to-content", the side-toc item cannot be expanded and highlighted to be consistent with the current topic. I have noticed that without @chunk="to-content", the side-toc item is linked with the corresponding output html of each topic ([topic_file_name].html), while with @chunk="to-content", the side-toc item is linked with the single html of the whole map ([map_file_name].html) + #topic_id.
So I am thinking whether it can be solved when the anchor is associated with the topic @id.

@jason-fox
Copy link
Collaborator

If you are still getting errors of the form:

 [xslt] An empty sequence is not allowed as the first argument of dita-ot:generate-html-id()
     [xslt] Failed to transform document: Failed to transform document: An empty sequence is not allowed as the first argument of dita-ot:generate-html-id()

Then the issue will still occur. However just rendering ordinary <topic> element is fine. I was using the sample doc and I noticed an issue with offcanvas.dita so I just commented it out. The suggested fix was for the nav only.

@bing-10
Copy link
Author

bing-10 commented Sep 1, 2022

If you are still getting errors of the form:

 [xslt] An empty sequence is not allowed as the first argument of dita-ot:generate-html-id()
     [xslt] Failed to transform document: Failed to transform document: An empty sequence is not allowed as the first argument of dita-ot:generate-html-id()

Then the issue will still occur. However just rendering ordinary <topic> element is fine. I was using the sample doc and I noticed an issue with offcanvas.dita so I just commented it out. The suggested fix was for the nav only.

I haven't met this issue, and I am just confused that the selected nav-toc cannot be set "active" anymore, so I come here to ask you if I can modify some lines to make it work normally as it is transformed without @chunk="to-content".

jason-fox added a commit to jason-fox/dita-bootstrap that referenced this issue Sep 6, 2022
Only take the `id` after the `#` when generating the connected xref button.
@jason-fox
Copy link
Collaborator

You can see a working chunked example here: https://jason-fox.github.io/dita-bootstrap/Chunk2050729693.html I created it from the feature/5.2 branch. The collapsible nav now works as do the collapse and offcanvas components.

This was created by altering the ditamap

- <chapter>
+ <chapter chunk="to-content">
...
- <chapter>
+ <chapter chunk="to-content">
... etc.

https://jason-fox.github.io/dita-bootstrap/Chunk1343199979.html demonstrates the timing bug. Nav works eventually, but the DOM needs to complete loading.

@bing-10
Copy link
Author

bing-10 commented Sep 6, 2022 via email

@infotexture infotexture added this to the 5.3.2 milestone Sep 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants