asciidoctor-vscode icon indicating copy to clipboard operation
asciidoctor-vscode copied to clipboard

Fix document to document xrefs in preview when the documents are included

Open birdman7260 opened this issue 1 year ago • 1 comments
trafficstars

Refer to my comment made on the issue for details about the issue and resolution: https://github.com/asciidoctor/asciidoctor-vscode/issues/425#issuecomment-2071267886

Resolves: in a preview, when a document xref's another document and then that document include::'s the first document

The changes made:

  • src/asciidocEngine.ts
    • added the intrinsic attributes that were missing. These are missing because they are only intrinsically assigned when asciidoctor processes a file but we process with the input as a string. Reference the asciidoctor documentation, notice that the modifiable column calls out that these are only assignable via the API in this situation: https://github.com/asciidoctor/asciidoctor-vscode/issues/425#issuecomment-2071267886
    • Now that docname is set, the macros substitution is properly able to handle the xref macros when they are referencing the same document that is include::'ing them
  • src/test/asciidoctorWebViewConverter.test.ts
    • refactored the two types of conversions to utilize a new function that creates the converter options. This applies the same intrinsic attributes solution
    • also, this sets the safe mode to UNSAFE as it is in the preview code, this way includes:: are actually resolved
    • Added two tests: 1) test that the included file is able to xref into the parent file, 2) new test to make sure an included file can xref a separate included file

resolves #425

birdman7260 avatar Apr 23 '24 21:04 birdman7260