asciidoctor / asciidoctor-pdf

:page_with_curl: Asciidoctor PDF: A native PDF converter for AsciiDoc based on Asciidoctor and Prawn, written entirely in Ruby.
https://docs.asciidoctor.org/pdf-converter/latest/
MIT License
1.14k stars 501 forks source link

Undefined variable used theme.yml quietly disables footer generation #2425

Closed Jibec closed 1 year ago

Jibec commented 1 year ago

Hi,

the issue: when a variable name is undefined in footer content, the pdf generation succeed, but the footer content will be empty.

expected behavior: I would like the command line to trigger a warning or an error when an undefined variable is used in the theme.yml

how to reproduce: change the value of the content to use an undefined variable the whole content will be empty

Here is my footer definition:

# Page Footers
footer:
  font-size: 9
  # NOTE if background-color is set, background and border will span width of page
  border-color: 000000
  border-width: 0.25
  height: $base-line-height-length * 2.5
  padding: [$base-line-height-length / 2, 1, 0, 1]
  vertical-align: top
  recto:
    right:
      content: ' Page {page-number} of {page-count} pages'
    left:
      content: '{copyright} - {docclass_footer} '
  verso:
    right:
      content: ' Page {page-number} of {page-count} pages'
    left:
      content: '{copyright}  - {docclass_footer} '

versions:

asciidoctor-pdf --version
Asciidoctor PDF 2.3.7 using Asciidoctor 2.0.20 [https://asciidoctor.org]
Runtime Environment (ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x64-mingw-ucrt]) (lc:IBM437 fs:UTF-8 in:UTF-8 ex:UTF-8)

command used:

asciidoctor-pdf --attribute pdf-stylesdir=./themes ^
    --attribute pdf-theme=mytheme ^
    --attribute pdf-themesdir=./themes ^
    --attribute pdf-fontsdir=./fonts ^
    --attribute imagesoutdir=./.pdf-images/ ^
    --doctype book ^
    mydocument.adoc ^
    --trace ^
    --warnings ^
    --verbose

thanks a lot for your work, asciidor is a good tooling

mojavelinux commented 1 year ago

Your observation is consistent with the design. As stated on the docs page at https://docs.asciidoctor.org/pdf-converter/latest/theme/add-running-content/#attribute-references

If you reference an attribute which is not defined, all the text on that same line in the running content will be dropped.

You can find the tests that verify this behavior here: https://github.com/asciidoctor/asciidoctor-pdf/blob/aecd91a324bb055664bcb90fddf92877c175c710/spec/running_content_spec.rb#L1505-L1530

This behavior was borrowed from Asciidoctor's predecessor as a way to control which lines are used. We're not planning on changing this behavior.

mojavelinux commented 1 year ago

If you need help using this feature, please ask in the project chat at https://chat.antora.org.