asciidoctor / asciidoctor-vscode

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

How to support a custom pdf theme #307

Open wetzesa opened 4 years ago

wetzesa commented 4 years ago

I would like to show my custom pdf theme in preview mode.

My project structure is like...

|- projectRoot |-- docFolder |--- doc.adoc |-- shared |--- theme |---- theme.yml

I copied the theme.yml also to the projectRoot or to docFolder and changed the config but hadn't any affect. I changed many times the path because the config is not complete clear how it is to set. So I am now not sure if I do something wrong or the feature isn't working.

I hope someone can help me with that very very small issue ;-)

Additionally: I am also a bit wondering about the field descripton "...path to a CSS style sheet to use...". Must it be a CSS file and a theme.yml is not working? The 2nd wondering in the field description was "...to the workspace folder." Does it only work with a workspace project or is it also working if I used the "Open folder" option in VS Code?

danyill commented 4 years ago

Yes, it must be a path to a CSS stylesheet. This is for the generation of the html in the preview.

If I understand correctly, you are trying to generate a PDF using the Ruby asciidoctor-pdf.

I think it should work within a workspace or folder but happy to take but reports for this.

If I read the asciidoctor-pdf README correctly what you must do to use a custom theme is:

Perhaps a better alternative than setting the asciidoctor-pdf command is to leave the Asciidoctorpdf_command as asciidoctor-pdf without any arguments and set in your document header the pdf- attributes like for instance the following:

image

@wetzesa I think your theme should have a name with a suffix -theme.yml, e.g. custom-theme.yml according to the asciidoctor-pdf theming guide.

Then for the folder structure you showed you should be able to use the document attributes:

:pdf-themesdir: ../themes
:pdf-theme: custom

Let us know how you go!

(I tested this by using https://github.com/mderoullers/asciidoctor-pretty-theme and opening src/main/asciidoc/example.adoc which is where the above screenshot came -- that might be a good example to look at if you're having trouble getting your theme to run)