-
Notifications
You must be signed in to change notification settings - Fork 97
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
Support xref navigation in the preview #425
Comments
Thank you for filing this issue and providing a complete example of the issue. 👍 This extension currently seems to have issues with the include preprocessor directive and I suspect with the xref directive also. I don't see any issue with your markup. Somehow I think we are not providing the correct document directory/folder when we called asciidoctor.js. I will look into it. |
Part of #425, fix base directory references
Still valid. Seems to be only
creates identical HTML:
so it very much looks like the preview pane behaves differently than saving to HTML. macOS: Sonoma 14.3.1 |
Chiming in to confirm that this does not work correctly at all. Expected behavior: Current behavior: As-is, the user is required to write inter-document links in a way that would never compile correctly into HTML just to make the previews navigable in VS Code. Please fix :). OS: MacOS Sonoma 14.3.1 |
Thanks @ViToni and @getawaywithrmdir for your analysis. We are listening to click events in the preview in the following file: asciidoctor-vscode/preview-src/index.ts Lines 131 to 162 in acbb890
If the In the following file we are listening to this event: asciidoctor-vscode/src/features/preview.ts Lines 152 to 154 in acbb890
And we call this function: asciidoctor-vscode/src/features/preview.ts Lines 453 to 464 in acbb890
Please, feel free to open a pull request to support navigation from a xref. |
I renamed this issue to make it actionable. If they are other things to improve/fix, please create a new issue. |
@ggrossetie Thanks for the hints. I'll try to get a PR done. |
@ggrossetie I can see a bit of the things going on, but see the full picture. It seems I cannot do breakpoints in |
I don't know if it's possible to debug in |
@ggrossetie Thanks. The hint with the developer tools ( But it seems to do what it should. @Ormesome Maybe you'd like to give it a try, to see if it works for you as well. |
Hi, this is almost working correctly: it does not handle when xref'ing to a different file and using an Even with that, there are two separate issues:
Here are two example files that would cause the issue (if there were enough text to allow the preview to scroll vertically sufficiently) docA.adoc = Parent document
Some text
[#anchor]
== Link to here
Please scroll me into position
include::docB[] docB.adoc = Child document
Other text
I want to link to xref:docA.adoc#anchor[] I have debugged and i know how to resolve the second case: asciidoctor-vscode/src/asciidocEngine.ts Lines 164 to 176 in 56b0d49
Why does this work? Because the way that xref's have their target changed when they end up in the same document via an include:: directive is through the macros substitution and part of that step is to look through all of the includes on the document but it also compares against the docname attribute. That is the issue here, if the xref from docB is targeting docA#anchor and we are previewing docA which is including docB.
Several of those intrinsic document attributes are not being set because we are processing the text directly instead of the file. I don't know if the other attributes (like To be clear, Regarding the xref issue 1 from above of not scrolling into position when the preview opens the other file I do not have a good idea how to resolve this and unfortunately do not have much more time to look. I'm only familiar with asciidoctor and I suspect this is something that would need to be resolved in the preview code. forgive me if I went into the weeds on things you already know above, I mostly typed it all out for my future reference |
@birdman7260 Feel free to provide a PR. IMHO even if it "only" would fix case 2) it's an improvement already. |
…uded and use an anchor
…uded and use an anchor
Description
Given:
When using the preview pane of vscode:
System Information
Using
Additional Context
I really want to use asciidoc as a local document repo, a styled way to store tons of notes with tables and images in a hierarchal file structure with the potential to export as HTML.
Is my markup incorrect or does asciidoc have issues with xref and include?
The text was updated successfully, but these errors were encountered: