-
-
Notifications
You must be signed in to change notification settings - Fork 114
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
Collapsing not working in xhtml #239
Comments
Hi, there! Do you have an example somewhere that reproduces this behavior? |
Well I am working on my local server but here's the code I am using from your example: |
When I try this locally it appears to nest as I would expect. Maybe I am not testing right though. |
Ha interesting...I am testing locally on macos 10.14.6 with chrome and firefox and none appear to nest...I have been wondering if there was an issue with xhtml strict rules and the javascript code for nesting but it seems to work for you. Would you have any other idea as to what is going on? Thanks. |
I’m not sure what else would be going on. Would you be able to host an example that reproduces this. |
Thanks for your reply. I don't have the ability to host right now. But the page source of my test when displayed in a browser is exactly the same as the code posted earlier. Really puzzling that it is working perfectly for you! |
Are you able to post a screenshot or something that shows the issue? Also I'm curious, what reason do you have for using xhtml? I would definitely be open to a PR if you are able to figure out what the fix is but for now I'll just keep this open. |
Hey, I was doing some reading and apparently tagName, a native DOM api, which is used by tocbot may return lowercase letters in xml. Does changing / overwriting this function to be like below fix the issue for you?
|
Thanks, Tim. I must confess I am not very versed in javascript or any of this. I see the code you are suggesting me to replace is in the parse-content.js but as I am calling the script with a link and didn't install it locally with npm, how can I modify/override this function? Don't worry about it if it requires tedious explanations. Appreciate your help. |
Can you paste your code again? The link above seems to have expired |
Sure here it is: https://pastebin.com/QyPd2seV |
It still seems to work fine for me with the code you provided. If you run |
no luck :( Could it be that it is working for you because you have tocbot installed with npm? I have installed it with npm but I am not clear about the following step to try it on my xhtml page: If you installed it with npm and use sass / postcss you might try importing the styles from 'node_modules', see the includePath option documentation for more info
|
It looks like you are using it off the CDN though so I don't think that's the issue. |
True. Using the same code as html (apart from the xhtlm specific DTDs etc.) works perfectly well. So it is definitely related to xhtml and how the javascript code is parsed in this context. What you mentioned earlier about xhtml/xml parsing javascript as lowercase would make sense as a potential cause for the issue I am encountering. But then I don't understand why it works as it is supposed to in your system. It can't be browser related either, the issue is encountered on Chrome, Firefox and Safari. MacOs? I don't see how that would affect anything but then I am not an expert in these things. |
I made this PR with updated build files with the possible fix. Can you test it out and let me know if it fixes the issue for you? |
This has completely fixed it! It works now as it should on xhtml! Thanks so much for your help and this great piece of code! |
Hey, glad the fix worked! And thanks for your helping testing it out and verifying! This is released in version 4.13.3 |
Hello,
thanks for the great js! I am encountering issues in making the toc behave correctly in xhtml. The sections that should collapse don't as the parent/children relationship is not honored and all levels (h1, h2, h3) are considered to be at the same level. Everything else is functioning as it should. The collapsing works perfectly well in html but not in xhtml. Do you have any idea what would be the cause ot that?
The text was updated successfully, but these errors were encountered: