Asciidoctor pdf - Custom admonition icons

classic Classic list List threaded Threaded
24 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Asciidoctor pdf - Custom admonition icons

IlliteratePhD
Is there a way to specify custom admonition icons in the yml file?

Thanks
// Patrik
Reply | Threaded
Open this post in threaded view
|

Re: Asciidoctor pdf - Custom admonition icons

rockyallen
I don't think it can be done in the yml (though I am happy to be proved wrong). Do it in the Asciidoc source instead by setting attributes icons, iconsdir and icontype.

http://asciidoctor.org/docs/user-manual/#attribute-catalog
Reply | Threaded
Open this post in threaded view
|

Re: Asciidoctor pdf - Custom admonition icons

abelsromero
In reply to this post by IlliteratePhD
If you mean use alternative icons, you can use some of the included ones: https://github.com/asciidoctor/asciidoctor-pdf/blob/master/docs/theming-guide.adoc#key-prefix-admonition-icon
Make sure you check the third footnote, contains a link to the available icons, check the correspondent .yml for the proper names. In my experience, not all work however, if there's some problem, it will appear in the output.

Otoh, if what you want is add a custom font with custom icons, I don't think it can't be done without messing with the code. You can try replicating the folder/file structure in prawn, but even if this works, I would not recommend it for maintenance sake.
Reply | Threaded
Open this post in threaded view
|

Re: Asciidoctor pdf - Custom admonition icons

IlliteratePhD
Ok, thanks for the information and the link. I think I understand the options I have then.
Reply | Threaded
Open this post in threaded view
|

Re: Asciidoctor pdf - Custom admonition icons

mojavelinux
Administrator
To expand on what Abel said, yes, you can use any icon for admonitions that is supported by prawn-icon (https://github.com/jessedoyle/prawn-icon/).

It's possible to add other icon fonts, but it would mean loading some Ruby code that extends prawn-icon. The resolution of the icon is separate from the theme. The theme just passed on this information.

Cheers,

-Dan

On Fri, Aug 18, 2017 at 12:40 AM, IlliteratePhD [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Ok, thanks for the information and the link. I think I understand the options I have then.


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Asciidoctor-pdf-Custom-admonition-icons-tp5850p5853.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--
Dan Allen | @mojavelinux | https://twitter.com/mojavelinux
Reply | Threaded
Open this post in threaded view
|

Re: Asciidoctor pdf - Custom admonition icons

be.wood
I am trying to figure out the correct theme for the PDF output. I have successfully edited my custom admonition block extension for HTML output, but I am having trouble figuring out exactly how to make the theme.yml file so PDF output can match the custom admonition of the HTML.

I tried to follow the information here: https://github.com/asciidoctor/asciidoctor-extensions-lab/issues/9

but when I try to create a separate template, I am getting error messages. I don't have a problem just editing the default template either, but when I tried to do that by adding this into the admonition section:

  icon:
    question:
      name: fas-question
      stroke_color: 871452
      size: 24

(question is just my filler for now), I get errors in the output stating this:

asciidoctor: DEBUG: sample.adoc: line 5: unknown style for example block: QUESTION

(line 5 is line with the ==== after the [QUESTION] of the sample file).

I have tried adding it to a custom style, but was having trouble figuring out how to call it, and when I thought I did, I got a lot more errors since the only thing in it was the admonition block, so I went back to editing the default (again, this is fine for my purposes), but always get this or some other error message.

I am at a loss as to how to edit the default template (or create my own and to call it since that isn't clear either) so I can define the new admonition styles.
Reply | Threaded
Open this post in threaded view
|

Re: Asciidoctor pdf - Custom admonition icons

mojavelinux
Administrator
QUESTION is not a valid admonition type. See https://asciidoctor.org/docs/user-manual/#admonition

If you want to customize the icon for NOTE, for example, here's a theme file you can use:

extends: default
admonition:
  icon:
    note:
      name: far-question-circle

(It's no longer necessary to modify the default theme file. You can simply extend it).

Cheers,

-Dan

On Tue, Aug 6, 2019 at 12:00 PM be.wood [via Asciidoctor :: Discussion] <[hidden email]> wrote:
I am trying to figure out the correct theme for the PDF output. I have successfully edited my custom admonition block extension for HTML output, but I am having trouble figuring out exactly how to make the theme.yml file so PDF output can match the custom admonition of the HTML.

I tried to follow the information here: https://github.com/asciidoctor/asciidoctor-extensions-lab/issues/9

but when I try to create a separate template, I am getting error messages. I don't have a problem just editing the default template either, but when I tried to do that by adding this into the admonition section:

  icon:
    question:
      name: fas-question
      stroke_color: 871452
      size: 24

(question is just my filler for now), I get errors in the output stating this:

asciidoctor: DEBUG: sample.adoc: line 5: unknown style for example block: QUESTION

(line 5 is line with the ==== after the [QUESTION] of the sample file).

I have tried adding it to a custom style, but was having trouble figuring out how to call it, and when I thought I did, I got a lot more errors since the only thing in it was the admonition block, so I went back to editing the default (again, this is fine for my purposes), but always get this or some other error message.

I am at a loss as to how to edit the default template (or create my own and to call it since that isn't clear either) so I can define the new admonition styles.


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Asciidoctor-pdf-Custom-admonition-icons-tp5850p7046.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML


--
Dan Allen | @mojavelinux | https://twitter.com/mojavelinux
Reply | Threaded
Open this post in threaded view
|

Re: Asciidoctor pdf - Custom admonition icons

be.wood
Thank you for the quick response. I see how to extend, now, but my problem is that I actually need to create new admonition types. I have defined them without problem for HTML output (actually with REVIEW and GUIDANCE as types), and can generate the HTML without problems. I would like to add these as valid for the PDF output as well, which is where I am stuck, how can I create them as I can using the custom-admonition-block extension?

Thank you
Reply | Threaded
Open this post in threaded view
|

Re: Asciidoctor pdf - Custom admonition icons

mojavelinux
Administrator
Ah,  I see what you're saying.


Combine it with this theme:

extends: default
admonition:
  icon:
    question:
      name: far-question-circle
      size: 24

Cheers,

-Dan

On Tue, Aug 6, 2019 at 1:36 PM be.wood [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Thank you for the quick response. I see how to extend, now, but my problem is that I actually need to create new admonition types. I have defined them without problem for HTML output (actually with REVIEW and GUIDANCE as types), and can generate the HTML without problems. I would like to add these as valid for the PDF output as well, which is where I am stuck, how can I create them as I can using the custom-admonition-block extension?

Thank you


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Asciidoctor-pdf-Custom-admonition-icons-tp5850p7048.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML


--
Dan Allen | @mojavelinux | https://twitter.com/mojavelinux
Reply | Threaded
Open this post in threaded view
|

Re: Asciidoctor pdf - Custom admonition icons

be.wood
Thank you. One last question, I ran this command (I renamed the custom-admonition-block to notice-block):

asciidoctor-pdf -a pdf-style:admonition.yml -r notice-block ./notice-block/sample.adoc

This ended up giving me this error when I run a trace (and the styles are unknown if I just run verbose):

asciidoctor-pdf-1.5.0.beta.2/lib/asciidoctor-pdf/converter.rb:666:in `convert_admonition': undefined method `[]' for nil:NilClass (NoMethodError)

The admonition.yml has the styles defined with the extends line first (and nothing else).

I don't know if I have the command wrong or if I'm missing something else.

Brian
Reply | Threaded
Open this post in threaded view
|

Re: Asciidoctor pdf - Custom admonition icons

mojavelinux
Administrator
Brian,

You didn't set the size for your custom admonition icon. Please follow the example I provided:

extends: default
admonition:
  icon:
    question:
      name: far-question-circle
      size: 24

(I could make the default size match twice the base font size so this wouldn't be required, but that won't help you until it's released).

Best,

-Dan

On Wed, Aug 7, 2019 at 6:05 AM be.wood [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Thank you. One last question, I ran this command (I renamed the custom-admonition-block to notice-block):

asciidoctor-pdf -a pdf-style:admonition.yml -r notice-block ./notice-block/sample.adoc

This ended up giving me this error when I run a trace (and the styles are unknown if I just run verbose):

asciidoctor-pdf-1.5.0.beta.2/lib/asciidoctor-pdf/converter.rb:666:in `convert_admonition': undefined method `[]' for nil:NilClass (NoMethodError)

The admonition.yml has the styles defined with the extends line first (and nothing else).

I don't know if I have the command wrong or if I'm missing something else.

Brian


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Asciidoctor-pdf-Custom-admonition-icons-tp5850p7050.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML


--
Dan Allen | @mojavelinux | https://twitter.com/mojavelinux
Reply | Threaded
Open this post in threaded view
|

Re: Asciidoctor pdf - Custom admonition icons

be.wood
This is my admonition.yml file (what I called it, anyway):

extends: default
admonition:
  icon:
    boilerplate:
      name: fas-lock
      stroke_color: 3F903E
      size: 24
  icon:
    review:
      name: fas-clipboard
      stroke_color: FDB109
      size: 24
  icon:
    guidance:
      name: fas-book
      stroke_color: 0909FD
      size: 24

Brian
Reply | Threaded
Open this post in threaded view
|

Re: Asciidoctor pdf - Custom admonition icons

be.wood
Sorry to keep asking, but I am still unable to make the PDF output correctly output with the icons. I keep getting the same message and I do have the size specified.

Thank you for the assistance.

Brian
Reply | Threaded
Open this post in threaded view
|

Re: Asciidoctor pdf - Custom admonition icons

mojavelinux
Administrator
Brian,

Please share a sample project so that I can investigate. You are missing a piece, but without seeing the project, it's hard to guess where that piece is.

Best,

-Dan

On Fri, Aug 9, 2019 at 7:05 AM be.wood [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Sorry to keep asking, but I am still unable to make the PDF output correctly output with the icons. I keep getting the same message and I do have the size specified.

Thank you for the assistance.

Brian


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Asciidoctor-pdf-Custom-admonition-icons-tp5850p7057.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML


--
Dan Allen | @mojavelinux | https://twitter.com/mojavelinux
Reply | Threaded
Open this post in threaded view
|

Re: Asciidoctor pdf - Custom admonition icons

be.wood
admonition.yml
extension.rb
notice-block.rb

sample.adoc

These are the three files (with the extension.rb being placed into a notice-block folder in the lib folder). I have tried to call the admonition.yml without success.

If I run the straight asciidoctor and call the notice-block to generate HTML output I get what I expect with icons for each of the admonitions in the sample, but when I try to run it for asciidoctor-pdf I don't get anything (they are admonitions, but with no icons), and I get the error messages.

This is all on Windows with ruby installed (if that makes any difference).

I appreciate all your help (this is for an external community that will rely on what I'm doing here, hopefully to standardize document creation on Asciidoctor and GitHub).

Thank you.
Reply | Threaded
Open this post in threaded view
|

Re: Asciidoctor pdf - Custom admonition icons

mojavelinux
Administrator
Aha! I see what it is.

In your theme, you're redefining the icon category over and over, so only the last one wins. Here's how it should look:

extends: default
admonition:
  icon:
    boilerplate:
      name: fas-lock
      stroke_color: 3F903E
      size: 24
    review:
      name: fas-clipboard
      stroke_color: FDB109
      size: 24
    guidance:
      name: fas-book
      stroke_color: 0909FD
      size: 24

Notice how all the icon types are defined under a single parent. This is a limitation imposed by the YAML language itself. If you redeclare a parent in the hierarchy, it replaces all previous declarations. (This does not affect keys that were defined in the theme you extended).

Best,

-Dan

On Fri, Aug 9, 2019 at 1:29 PM be.wood [via Asciidoctor :: Discussion] <[hidden email]> wrote:
admonition.yml
extension.rb
notice-block.rb

sample.adoc

These are the three files (with the extension.rb being placed into a notice-block folder in the lib folder). I have tried to call the admonition.yml without success.

If I run the straight asciidoctor and call the notice-block to generate HTML output I get what I expect with icons for each of the admonitions in the sample, but when I try to run it for asciidoctor-pdf I don't get anything (they are admonitions, but with no icons), and I get the error messages.

This is all on Windows with ruby installed (if that makes any difference).

I appreciate all your help (this is for an external community that will rely on what I'm doing here, hopefully to standardize document creation on Asciidoctor and GitHub).

Thank you.


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Asciidoctor-pdf-Custom-admonition-icons-tp5850p7059.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML


--
Dan Allen | @mojavelinux | https://twitter.com/mojavelinux
Reply | Threaded
Open this post in threaded view
|

Re: Asciidoctor pdf - Custom admonition icons

be.wood
After making that edit, I try to run this command (which I think is correct for getting all the pieces together (this is from the folder where both the YML and sample files are located):

asciidoctor-pdf -r notice-block -a pdf-style:admonition.yml sample.adoc

I get this error though when I try to run this:

undefined method `[]' for nil:NilClass
  Use --trace for backtrace

If I run the trace, I get this contents of the attached file. trace.txt

Just to be clear, here is the version information from the build I'm using:

Asciidoctor PDF 1.5.0.beta.2 using Asciidoctor 2.0.10 [https://asciidoctor.org]
Runtime Environment (ruby 2.6.3p62 (2019-04-16 revision 67580) [x64-mingw32]) (lc:IBM437 fs:Windows-1252 in:IBM437 ex:IBM437)

Thank you
Reply | Threaded
Open this post in threaded view
|

Re: Asciidoctor pdf - Custom admonition icons

be.wood
So I figured out that the problem is using the "-r notice-block" with the asciidoctor-pdf, but if I just use the admonition.yml file I don't get any admonitions.

So the admonition.yml file seems like it needs something else to get it to process, which kind of makes sense, maybe, but if i just call

asciidoctor-pdf -a pdf-style:admonition.yml sample.adoc

sample.pdf

I get this output, which doesn't have any icons.

If I run the command

asciidoctor -r notice-block sample.adoc

sample.html

I get the file with all the icons.

Thanks
Reply | Threaded
Open this post in threaded view
|

Re: Asciidoctor pdf - Custom admonition icons

mojavelinux
Administrator
Please check your command. You're typing it incorrectly. It should be:

asciidoctor-pdf -r ./notice-block.rb -a pdf-theme=./admonition-theme.yml sample.adoc

* pdf-style is the deprecated attribute name
* themes should be named with the -theme.yml extension
* the syntax is pdf-theme=./admonition-theme.yml not pdf-theme:admonition-theme.yml
* it's best to reference the extension filename exactly, so -r ./notice-block.rb instead of -r notice-block

-Dan

On Mon, Aug 12, 2019 at 4:02 PM be.wood [via Asciidoctor :: Discussion] <[hidden email]> wrote:
So I figured out that the problem is using the "-r notice-block" with the asciidoctor-pdf, but if I just use the admonition.yml file I don't get any admonitions.

So the admonition.yml file seems like it needs something else to get it to process, which kind of makes sense, maybe, but if i just call

asciidoctor-pdf -a pdf-style:admonition.yml sample.adoc

sample.pdf

I get this output, which doesn't have any icons.

If I run the command

asciidoctor -r notice-block sample.adoc

sample.html

I get the file with all the icons.

Thanks


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Asciidoctor-pdf-Custom-admonition-icons-tp5850p7072.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML


--
Dan Allen | @mojavelinux | https://twitter.com/mojavelinux
Reply | Threaded
Open this post in threaded view
|

Re: Asciidoctor pdf - Custom admonition icons

be.wood
THANK YOU!!!!!

I figured I had to have something wrong, and whatever combination it was, this worked exactly as I expected.

I appreciate your help and the great tool you have created.

Brian
12