Login  Register

Re: Dynamic Figure Indexing

Posted by mojavelinux on Oct 29, 2018; 1:13am
URL: https://discuss.asciidoctor.org/Dynamic-Figure-Indexing-tp6556p6562.html

That extension still needs some work. Here's generally how it works. If you pass the following document:

= Document Title
:doctype: book

== First Chapter

.Image in First Chapter
image::figure-a.png[]

== Second Chapter

.Image in Second Chapter
image::figure-b.png[]

You will get

Test Document

First Chapter

[figure-a]
Figure 1.1 Image in First Chapter

Second Chapter

[figure-b]
Figure 1.2 Image in Second Chapter

The numbering is not correct for the second figure. It should be Figure 2.1. But clearly it's showing that it is trying to make a two-part number. The key line in the extension is this one:

el.caption = replaced_caption

It's possible to change the caption (e.g., Figure 1.1) for any titled node in the document tree.

Feel free to open an issue in the extensions lab to get help from the community in using or improving that extension, or replacing it with a better one.

Cheers,

-Dan

On Sun, Oct 28, 2018 at 6:07 PM ellieborden [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Sorry, I don't think I understand.

I added lib/autoxref-treeprocessor.rb to my project and ran:

     asciidoctor -r ./lib/autoxref-treeprocessor.rb index.adoc

The document was processed, but the result is no different than if I had run Asciidoctor without the extension. I looked through the extension code, but am not very familiar with Asciidoctor's codebase or Ruby, so it is difficult to interpret what is happening.


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Dynamic-Figure-Indexing-tp6556p6561.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML


--
Dan Allen | @mojavelinux | https://twitter.com/mojavelinux