Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Hi,
What is the way (if any) to generate a list of tables / figures? Cheers, Álvaro. |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
+1
Is there a easy way to do that? |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
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 -- |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
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. ... [show rest of quote] |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
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. |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
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. ... [show rest of quote] -- |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
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. For more information about find_by, see http://www.rubydoc.info/github/asciidoctor/asciidoctor/Asciidoctor/AbstractBlock#find_by-instance_method 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? ... [show rest of quote] Dan Allen | http://google.com/profiles/dan.j.allen |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
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...) |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Administrator
|
On Thu, Apr 2, 2015 at 4:18 PM, dmd [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Perhaps something we could add to this folder to share with others: |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Administrator
|
In reply to this post by dmd
Here's some raw material for the script: -Dan On Thu, Apr 2, 2015 at 5:43 PM, Dan Allen <[hidden email]> wrote:
Dan Allen | http://google.com/profiles/dan.j.allen |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
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" |
Free forum by Nabble | Edit this page |