Login  Register

Counters and ifeval

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

Counters and ifeval

halol
10 posts
This post was updated on Jun 30, 2021; 7:41pm.
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
| More
Print post
Permalink

Re: Counters and ifeval

halol
10 posts
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
| More
Print post
Permalink

Re: Counters and ifeval

mojavelinux
Administrator
2681 posts
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
| More
Print post
Permalink

Re: Counters and ifeval

halol
10 posts
OK, thanks.