Table of contents

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

Table of contents

jxxcarlson
I've put code at the links below that constructs a table of contents in HTML form given Asciidoctor text as
input.  I will post something shortly that describes better what it does and what the specification is.  I am using this
now at http://www.scripta.io; I would like evolve it to a state in which it could be useful for others.  To this end, I wold very much appreciate your comments.

https://github.com/jxxcarlson/noteshare/blob/master/lib/noteshare/modules/asciidoctor_helpers.rb[Code for table_of_contents] +
https://github.com/jxxcarlson/noteshare/blob/master/spec/noteshare/modules/asciidoctor_helpers_spec.rb[Code for the tests]

Here is an article that describes this in somewhat more detail:

http://home.noteshareblog.io/2015/12/09/Experiments-with-Asciidoctor-no-3-a-better-table-of-contents.html
Reply | Threaded
Open this post in threaded view
|

Re: Table of contents

mojavelinux
Administrator
I really like this effort because it shows that you should not feel bound / limited by what Asciidoctor does by default (in this case, with the TOC). The defaults are just that, defaults. They get you started without having to put in much thought or effort.

What Jim demonstrates here is that you have this whole API at your disposal and you can craft the output in whatever way you imagine by digging into that API. And not just as an extension, but as a client.

In doing these types of experiments, it's nice to have the API documentation handy.


Keep up the great work, Jim!

Cheers,

-Dan

On Tue, Dec 15, 2015 at 6:17 PM, jxxcarlson [via Asciidoctor :: Discussion] <[hidden email]> wrote:
I've put code at the links below that constructs a table of contents in HTML form given Asciidoctor text as
input.  I will post something shortly that describes better what it does and what the specification is.  I am using this
now at http://www.scripta.io; I would like evolve it to a state in which it could be useful for others.  To this end, I wold very much appreciate your comments.

https://github.com/jxxcarlson/noteshare/blob/master/lib/noteshare/modules/asciidoctor_helpers.rb[Code for table_of_contents] +
https://github.com/jxxcarlson/noteshare/blob/master/spec/noteshare/modules/asciidoctor_helpers_spec.rb[Code for the tests]

Here is an article that describes this in somewhat more detail:

http://home.noteshareblog.io/2015/12/09/Experiments-with-Asciidoctor-no-3-a-better-table-of-contents.html


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



--
Dan Allen | @mojavelinux | http://google.com/profiles/dan.j.allen
Reply | Threaded
Open this post in threaded view
|

Re: Table of contents -- need some AST code

jxxcarlson
In reply to this post by jxxcarlson
I would like to endow the table of contents code with a feature allowing the user to re-arrange sections of a document by dragging the titles around in a suitable display.  This already works for the "outer nodes" of the table in the demo at http://www.scripta.com.  (scripta is an open source project that will eventually replace notheshare).  You can play around with this buy logging into scripta with user name coram@foo.com, with password hohoho1234 .

I can do this using the AST that the Asciidoctor parser generates, but need to know the name of the method that returns the raw content, jus as #content yields the HTML.                                                                                                                                                                  
Reply | Threaded
Open this post in threaded view
|

Re: Table of contents -- need some AST code

jxxcarlson
Let's call the needed method 'raw_content'.  i see how it could
be written using the blocks an line methods plus a little
recursion, but if the method already exists, so much the better.
Reply | Threaded
Open this post in threaded view
|

Re: Table of contents -- need some AST code

jxxcarlson
One way to get the "raw_content" would be to have converter
that produced Asciidoc text instead of HTML.  Let's call this method
'convert back'.  Applied to a node in the AST, it would produce  Asciidoctor
text that when parsed would yield the give node.

This may have been discussed before -- an "Asciidoc backend".  It should
be very easy to write as an extension -- it would be like  a drastic simplification
of the latex converter: instead of doing something to a node's content, it
just passes it through.

Having said this I realize  in the latex converter, n.content is the html text.
So why am I getting html when I apply #content?  The problem must already
be solved!!??