List of tables/figures

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

List of tables/figures

Álvaro Sánchez-Mariscal
Hi,

What is the way (if any) to generate a list of tables / figures?

Cheers,
Álvaro.
Reply | Threaded
Open this post in threaded view
|

Re: List of tables/figures

krigu
+1

Is there a easy way to do that?
Reply | Threaded
Open this post in threaded view
|

Re: List of tables/figures

LightGuardjp
Afaik there isn't anything built that will do this, but an extension should be able to do this fairly easily. Seems to me like this was asked before. I haven't looked at the archives yet though. 

On Wednesday, March 25, 2015, krigu [via Asciidoctor :: Discussion] <[hidden email]> wrote:
+1

Is there a easy way to do that?


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/List-of-tables-figures-tp2829p2861.html
To start a new topic under Asciidoctor :: Discussion, email <a href="javascript:_e(%7B%7D,&#39;cvml&#39;,&#39;ml-node%2Bs49171n1h37@n6.nabble.com&#39;);" target="_blank">ml-node+s49171n1h37@...
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML


--

Reply | Threaded
Open this post in threaded view
|

Re: List of tables/figures

Álvaro Sánchez-Mariscal
I've looked extensively but couldn't find anything.

2015-03-30 17:11 GMT+02:00 LightGuardjp [via Asciidoctor :: Discussion] <[hidden email]>:
Afaik there isn't anything built that will do this, but an extension should be able to do this fairly easily. Seems to me like this was asked before. I haven't looked at the archives yet though. 

On Wednesday, March 25, 2015, krigu [via Asciidoctor :: Discussion] <[hidden email]> wrote:
+1

Is there a easy way to do that?


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/List-of-tables-figures-tp2829p2861.html
To start a new topic under Asciidoctor :: Discussion, email <a href="javascript:_e(%7B%7D,&#39;cvml&#39;,&#[hidden email]&#39;);" target="_blank">ml-node+s49171n1h37@...
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML


--




If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/List-of-tables-figures-tp2829p2873.html
To unsubscribe from List of tables/figures, click here.
NAML



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

Re: List of tables/figures

dmd
This would be extremely useful.

I've been doing some horrible shell code, based on my convention of naming figures fig-something:
#!/bin/bash

echo -e "// \$Id\$\n// DO NOT EDIT THIS AUTOGENERATED FILE.\n\n== List of Figures\n" > list-of-figures.adoc
grep -h "\[\[fig" $(grep include master.adoc | perl -p -e 's#.*:(.*)\[.*#$1#') |
    tr "[]" "<>" |
    sed "s/^/. /" >>  list-of-figures.adoc
echo >> list-of-figures.adoc

but it breaks in a LOT of ways.
Reply | Threaded
Open this post in threaded view
|

Re: List of tables/figures

LightGuardjp
I looked, but haven't seen code to do this. It was asked on SO, which I answered, but no code. It would be a great extension to have. Someone have a Document to use as testing fodder?

On Tuesday, March 31, 2015, dmd [via Asciidoctor :: Discussion] <[hidden email]> wrote:
This would be extremely useful.

I've been doing some horrible shell code, based on my convention of naming figures fig-something:
#!/bin/bash

echo -e "// \$Id\$\n// DO NOT EDIT THIS AUTOGENERATED FILE.\n\n== List of Figures\n" > list-of-figures.adoc
grep -h "\[\[fig" $(grep include master.adoc | perl -p -e 's#.*:(.*)\[.*#$1#') |
    tr "[]" "<>" |
    sed "s/^/. /" >>  list-of-figures.adoc
echo >> list-of-figures.adoc

but it breaks in a LOT of ways.


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/List-of-tables-figures-tp2829p2900.html
To start a new topic under Asciidoctor :: Discussion, email <a href="javascript:_e(%7B%7D,&#39;cvml&#39;,&#39;ml-node%2Bs49171n1h37@n6.nabble.com&#39;);" target="_blank">ml-node+s49171n1h37@...
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML


--

Reply | Threaded
Open this post in threaded view
|

Re: List of tables/figures

mojavelinux
Administrator
Actually, we do track the list of images / figures if you add the following option to the API:

 catalog_assets: true

For instance,

 doc = Asciidoctor.load_file 'sample.adoc', to_file: false, safe: :safe, catalog_assets: true

Then you can find the images in the references property:

 require 'pp'
 pp doc.references

There is a major limitation though. We don't preserve the calculated path to the image when it's saved in the reference table. That means you cannot resolve the image path from this information alone. But you do at least know the original target, so you could look back through the AST to figure out which node has the image and then get more information about it (a reverse lookup). There are plans to make these references more useful and robust.

Another option is to load the document, then use the query method to get nodes of a certain type.

 doc.find_by context: :image

Please note that find_by only looks for block-level content. It won't find inline images because they aren't parsed on load currently.


Cheers,

-Dan

On Tue, Mar 31, 2015 at 10:13 PM, LightGuardjp [via Asciidoctor :: Discussion] <[hidden email]> wrote:
I looked, but haven't seen code to do this. It was asked on SO, which I answered, but no code. It would be a great extension to have. Someone have a Document to use as testing fodder?

On Tuesday, March 31, 2015, dmd [via Asciidoctor :: Discussion] <[hidden email]> wrote:
This would be extremely useful.

I've been doing some horrible shell code, based on my convention of naming figures fig-something:
#!/bin/bash

echo -e "// \$Id\$\n// DO NOT EDIT THIS AUTOGENERATED FILE.\n\n== List of Figures\n" > list-of-figures.adoc
grep -h "\[\[fig" $(grep include master.adoc | perl -p -e 's#.*:(.*)\[.*#$1#') |
    tr "[]" "<>" |
    sed "s/^/. /" >>  list-of-figures.adoc
echo >> list-of-figures.adoc

but it breaks in a LOT of ways.


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/List-of-tables-figures-tp2829p2900.html
To start a new topic under Asciidoctor :: Discussion, email <a href="javascript:_e(%7B%7D,&#39;cvml&#39;,&#[hidden email]&#39;);" target="_blank">ml-node+s49171n1h37@...
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML


--




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



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

Re: List of tables/figures

dmd
As a non-Rubyist, is there anyone who could help me? I use the command line 'asciidoctor' tool, not the library.

Really, all I need is a very simple tool which takes on stdin an asciidoc, and spits out all the figure references (i.e., all the things that went in [[ ]], which I will want to reference in << >>.


(My shell script is getting more and more unwieldy because I have figure references that change depending on variable names and other defined values...)
Reply | Threaded
Open this post in threaded view
|

Re: List of tables/figures

mojavelinux
Administrator

On Thu, Apr 2, 2015 at 4:18 PM, dmd [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Really, all I need is a very simple tool which takes on stdin an asciidoc, and spits out all the figure references (i.e., all the things that went in [[ ]], which I will want to reference in << >>.

Perhaps something we could add to this folder to share with others:


Reply | Threaded
Open this post in threaded view
|

Re: List of tables/figures

mojavelinux
Administrator
In reply to this post by dmd

On Thu, Apr 2, 2015 at 5:43 PM, Dan Allen <[hidden email]> wrote:

On Thu, Apr 2, 2015 at 4:18 PM, dmd [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Really, all I need is a very simple tool which takes on stdin an asciidoc, and spits out all the figure references (i.e., all the things that went in [[ ]], which I will want to reference in << >>.

Perhaps something we could add to this folder to share with others:





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

Re: List of tables/figures

dmd
I'm now doing something a little better. I still don't understand how to extract the list of figures, but in my particular case I always name figures [[fig-something-or-other]], so the following works for me.

#!/usr/bin/ruby
require 'asciidoctor'

doc = Asciidoctor.load_file(ARGV[0], to_file: false, safe: :unsafe, catalog_assets: true)

print "// DO NOT EDIT THIS AUTOGENERATED FILE.\n\n"
print "== List of Figures\n\n"

figs = doc.references[:ids].keys.find_all { |x| x.start_with? "fig-" } 
figs.each do |fig|
    print ". <<" + fig + ">>\n"
end
print "\n\n"