Is is possible to nest a counter within an ASCIIdoc macro?

Viewed 61

I use ASCIIdoc macros, and I would like to embedded counter in a substitution macro, but it doesn't work as expected.

source document:

:macro-with-counter: foo-{counter:id}

* {macro-with-counter}: bar-one
* {macro-with-counter}: bar-two
* {macro-with-counter}: bar-three

expected rendering with an incrementing counter:

  • foo-1: bar-one
  • foo-2: bar-two
  • foo-3: bar-three

actual rendering:

  • foo-1: bar-one
  • foo-1: bar-two
  • foo-1: bar-three

Is it possible to nest a counter in a substitution macro in ASCIIdoc?

2 Answers

Try this code:

foo-id: 0

* foo-{counter:foo-id}: bar-one
* foo-{counter:foo-id}: bar-two
* foo-{counter:foo-id}: bar-three

Simple answer: it is not possible to nest macros in ASCIIdoc. This implies a recursion capability that isn't there.

Related