Closed fullstopslash closed 2 years ago
Thanks for the compliment and support! That means a lot.
The problem may be with how you are invoking Asciidoctor PDF. We recommend using the provided asciidoctor-pdf
bin script (i.e., command). Using -b pdf -r asciidoctor/pdf
is not the typical usage. If you prefer to use the asciidoctor
command, then you need to require asciidoctor/pdf
in the require script (since it won't already be loaded).
require 'asciidoctor/pdf'
class PDFConverterTableRole < (Asciidoctor::Converter.for 'pdf')
register_for 'pdf'
# ...
end
Also, ensure you are using Asciidoctor PDF 2.
The command throws me this error: undefined method `start_with?' for :font_catalog:Symbol
Please turn on --trace
and share the full error so that we can see where in the source this is happening. I'm unable to reproduce it based on the information you have provided. Can you also tell me which version of Ruby you are using?
I think I may understand what's happening. In Ruby < 2.7, Symbol did not support the start_with?
method. Each key in the theme is a Symbol. The first key is typically font_catalog
. This is where the extended converter assumes it can call start_with?
on the key:
unless (role_entries = theme.each_pair.select {|name, val| name.start_with? key_prefix }).empty?
I can update the example to coerce the name to a String for portability.
In the future, can you ask questions about usage in the project chat? See https://docs.asciidoctor.org/about/support/#chat for details.
I'm still interested to know which combination of software you were using to produce this error. I can't find a combination that would produce the same error, even though I understand why it is happening.
Thank you for such a quick reply! I was able to get it working after amending the script then changing the relative parts of my theme to this:
role:
<table>:
normaltable:
font-size: 12
smalltable:
font-size: 8
I removed the standard table entry and the custom roles started working like a gem. I should note I'm using in nested tables (which the docs already mention should be used sparingly 😵) and I think there's some funny business going on in nested tables regarding font sizes, but this clears it up nicely!
In the future I'll direct my questions to the chat first!
That's great!
Could you still let me know which version of Ruby you are using?
Forgot to mention I'm on macOS, it's probably an exorbitantly outdated version! ruby 2.6.8p205 (2021-07-07 revision 67951) [universal.x86_64-darwin21]
Exactly what I needed to know. Thanks! That confirms why you were getting this error. But no need to worry anymore as the code is now portable.
I should note I'm using in nested tables and I think there's some funny business going on in nested tables regarding font sizes, but this clears it up nicely!
Aha! That is indeed unexpected behavior. I've reported it as #2276.
Firstly, thank you for this truly amazing software! It's so flexible, customizable, and has quickly become an integral part of my workflow! I've begun messing about with custom themes and want to try using the pdf-converter-table-role.rb script to be able to pass some custom table settings. This is the command I ended up needing to use to get the script to register with the asciidoctor-pdf backend.
asciidoctor --trace -a pdf-theme=./resources/themes/first-theme.yml -a compress -r asciidoctor-pdf -r ./resources/themes/pdf-converter-table-role.rb -b pdf "$(SOURCE_ADOC)" -o "$@"
This is my entire theme so far:
The command throws me this error:
undefined method `start_with?' for :font_catalog:Symbol
I haven't set "Symbol" in fonts, or messed with setting any custom fonts yet, so I believe this to be some kind of bug.
Thanks in advance for the help!