A lab for testing and demonstrating Asciidoctor extensions. Please do not use this code in production. If you want to use one of these extensions in your application, create a new project, import the code, and distribute it as a RubyGem. You can then request to make it a top-level project under the Asciidoctor organization.
Other
104
stars
101
forks
source link
sectnum offset tree processor always returns 1 or 2 #109
This version doesn't throw an error, but it doesn't seem to work as intended. It's supposed to increment the level-1 section numbers by the given offset, so if I set sectnumoffset to 5, the first section should be 6. Instead, I get 2.
In my tests, if I set sectnumoffset to 1 or greater, I get a result of 2. But if I set it to 0 or even a negative number, I get a result of 1. (The same result I'd get with no offset.)
My guess is that rather than loading the value of the sectnumoffset attribute, the tree processor creates a boolean that is "1" if the offset is >1 and "0" if it's not. But I'm not a Ruby programmer so I'm not sure how to test this.
For years I've been using the original version of the sectnumoffset treeprocessor (as coded here: https://github.com/asciidoctor/asciidoctor-pdf/issues/166#issuecomment-118458625 ) without a problem.
Today, after I upgraded Asciidoctor-PDF to beta 4, I started getting an error from the processor (
undefined method 'number='
).I replaced that tree processor code with the newer version found here: https://github.com/asciidoctor/asciidoctor-extensions-lab/blob/master/lib/sectnumoffset-treeprocessor.rb
This version doesn't throw an error, but it doesn't seem to work as intended. It's supposed to increment the level-1 section numbers by the given offset, so if I set
sectnumoffset
to 5, the first section should be 6. Instead, I get 2.In my tests, if I set
sectnumoffset
to 1 or greater, I get a result of 2. But if I set it to 0 or even a negative number, I get a result of 1. (The same result I'd get with no offset.)My guess is that rather than loading the value of the
sectnumoffset
attribute, the tree processor creates a boolean that is "1" if the offset is >1 and "0" if it's not. But I'm not a Ruby programmer so I'm not sure how to test this.