asciidoctor / asciidoctor-vscode

AsciiDoc support for Visual Studio Code using Asciidoctor
Other
335 stars 97 forks source link

PDF export ignores include files #593

Closed ioannisstavrakakis closed 2 years ago

ioannisstavrakakis commented 2 years ago

Description

When exporting a PDF using "AsciiDoc: Export document as PDF" quick command, the resulting PDF does not include the included adoc files. The PDF states the following error message:

Unresolved directive in - include::test.adoc[tag=guide]

System Information

VSCode: 1.68.1 OS: Windows_NT x64 10.0.19044 AsciiDoc v3.0.0.

To Reproduce

Steps to reproduce the issue:

  1. Open the command palette - ctrl+shift+p or F1 (Mac: cmd+shift+p)
  2. Select AsciiDoc: Export document as PDF
  3. Choose the folder and filename for the generated PDF

Additional Context

Running the asciidoctor-pdf bash command renders the PDF as expected.

ggrossetie commented 2 years ago

Are you using Asciidoctor PDF or wkhtmltopdf? Could you please share the workspace structure (i.e., where is located test.adoc, where is located the file you are exporting to PDF? etc...)

ioannisstavrakakis commented 2 years ago

I am using the asciidoctor-pdf engin, as checked in the extensions settings. Both adoc files are under the same folder.

ggrossetie commented 2 years ago

Both adoc files are under the same folder.

And both AsciiDoc files are at the root of the workspace or inside a sub-directory? Do you use a custom asciidoctor-pdf command? Did you install asciidoctor-pdf locally using Bundler when the extension asks you or did you have asciidoctor-pdf already installed?

ioannisstavrakakis commented 2 years ago

I tried both moving the files at the root, and in subfolders, but it is the same result. I use a custom command which I have configured also in the extensions settings, i.e.:

asciidoctor-pdf -r asciidoctor-lists master.adoc -a pdf-theme=styles/theme.yml -a pdf-fontsdir=styles/assets -a source-highlighter=coderay --trace

I had already installed asciidoctor-pdf.

If I run the command in bash, everything works fine. And the Export PDF function works fine if the adoc does not contain include files.

ioannisstavrakakis commented 2 years ago

I created a minimal master adoc and a minimal include adoc, without much content, nor formatting or document attributes, but it still does not work.

test.zip

Have a go and let me know if you managed to produce a PDF like this one using the Export PDF wuick command: testmaster.pdf

ggrossetie commented 2 years ago

Thanks for your input, I will try to reproduce. For reference, what is the absolute path to your workspace and to your AsciiDoc file? My guess is that the base directory is wrong and thus Asciidoctor PDF cannot resolve the target test.adoc.

ioannisstavrakakis commented 2 years ago

Not sure I understand. This is what I have:

image

ggrossetie commented 2 years ago

I meant the absolute path such as c:\path\to\workspace and c:\path\to\workspace\folder\test.adoc

ggrossetie commented 2 years ago

I cannot reproduce this issue. Though, I found a bug in how we detect if a command is available or not.

Could you please share your settings? @ext:asciidoctor.asciidoctor-vscode pdf

ioannisstavrakakis commented 2 years ago

I tried to move the files to another folder, and I got this: Unable to get the workspace folder, aborting.

ggrossetie commented 2 years ago

I tried to move the files to another folder, and I got this: Unable to get the workspace folder, aborting.

That's expected, if your AsciiDoc file is not in a workspace folder we cannot continue. We are using the workspace folder to set the base directory.

ioannisstavrakakis commented 2 years ago

image

Same settings for User and Workspace.

ioannisstavrakakis commented 2 years ago

I meant the absolute path such as c:\path\to\workspace and c:\path\to\workspace\folder\test.adoc

C:\Users\istavrak\product_documentation\testmaster.adoc

ggrossetie commented 2 years ago

ok

ggrossetie commented 2 years ago

C:\Users\istavrak\product_documentation\testmaster.adoc

Your path does not contain any special character... but maybe it's a Windows related issue 🤔 Do you notice anything different between what I'm doing and what you are doing?

ioannisstavrakakis commented 2 years ago

Nothing different I am afraid... and again, it works perfectly for any other adoc that does not have include adocs.

And it should not be a problem of the asciidoctor-pdf because running the command from bash works perfectly.

This is really strange.. it is definitely a Windows thing.

I also selected and unselected the "asciidoc.useWorkspaceRootAsBaseDirectory" setting, but all the same.

ioannisstavrakakis commented 2 years ago

Shouldn't the Export to PDF work also in the web VSC? There is not that option:

image

ioannisstavrakakis commented 2 years ago

I managed to solve this by using the absolute path to the file:

include::C:\Users\istavrak\product_documentation\testinclude.adoc[]

It is not ideal, and I am not sure if this will cause any problems later when we will develop our Antora-based portal, but at least it works this way.

ggrossetie commented 2 years ago

Shouldn't the Export to PDF work also in the web VSC? There is not that option:

The export relies on a binary (asciidoctor-pdf or wkhtmltopdf) and we cannot execute binary in VS Code Web. So it's intented.

I managed to solve this by using the absolute path to the file: include::C:\Users\istavrak\product_documentation\testinclude.adoc[] It is not ideal, and I am not sure if this will cause any problems later when we will develop our Antora-based portal, but at least it works this way.

You shouldn't do that. I might have an idea of why it's not working on Windows.

ggrossetie commented 2 years ago

I can reproduce it on Windows. As expected, the base directory is wrong, we are using:

https://github.com/asciidoctor/asciidoctor-vscode/blob/5af7e2caf18c62bacf58baca00135d376eba1c63/src/commands/exportAsPDF.ts#L33

On Windows, docUri.root is equals to c:\\ and docUri.dir is c:\\path\\to\\workspace. In the end, the baseDirectory is c:\\c:\\path\\to\\workspace.

Not sure why we do that, I will fix/simplify the code.

ioannisstavrakakis commented 2 years ago

Thank you very much!

ioannisstavrakakis commented 2 years ago

Yes, it works! Many thanks!

BTW, nice touch to have this prompt: generating_pdf

Much appreciated!

ggrossetie commented 2 years ago

I'm glad you've noticed this small detail 😄

ioannisstavrakakis commented 2 years ago

Are you kidding me? I live for such details 😅😅😅