Counters and ifeval

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Counters and ifeval

halol
This post was updated on .
Hello,

I am having an issue with counters and using them in ifeval directives:

Given the file:

{counter2:test}

The value of my counter is now {test}

// ifeval::[{test} > 1]
// The value of my counter is now {test}
// endif::[]
// => Leads to error Failed to load AsciiDoc document - undefined method `>' for nil:NilClass

ifeval::[{counter:newtest} == 1]
The value of my new counter is now {newtest}
endif::[]

The output produced is:
The value of my counter is now 1

The value of my new counter is now {newtest}

1. The first ifeval (commented out) causes an error and cannot be used at all (presumably because the counter defined beforehand is null in ifeval).
2. In the second case, the counter defined in the ifeval directive cannot be used elsewhere.

Am I doing something wrong?

Using:
asciidoctor -version
Asciidoctor 2.0.15 [https://asciidoctor.org]
On Fedora 34.
Reply | Threaded
Open this post in threaded view
|

Re: Counters and ifeval

halol
Nobody can comment on this?

Would be nice to know if this is a bug, or if this is by design and I am doing something wrong.
Reply | Threaded
Open this post in threaded view
|

Re: Counters and ifeval

mojavelinux
Administrator
You're probably going to find you get better support in the community chat at https://asciidoctor.zulipchat.com. That's where most of the community hangs out.

The short answer to your question is that how you're attempting to use counters is outside the scope of what they were intended to do. Counters are essentially for making a sequence of numbers or letters in the output document. The primary example is a column that presents a sequence of numbers. Once you start setting and unsetting them during parsing, the behavior is unspecified.

Best Regards,

-Dan
Reply | Threaded
Open this post in threaded view
|

Re: Counters and ifeval

halol
OK, thanks.