Pavel Jurus wrote:
> Hello again,
> On Thursday 08 March 2007 20:39, Stuart Rackham wrote:
>> Hi Pavel
>> Pavel Jurus wrote:
>>> Hello,
>>> I cannot figure out how to turn on table of contents (in xhtml code) in
>>> document. I am able to generate table of contents by calling
>>> "asciidoc -a toc docname.txt". However I would prefer to be able to
>>> indicate that I want toc in text of my document. I tried to put ":toc:"
>>> or "[toc]" in my documents but it has no effect.
>>> I such thing possible? And how can I do this? You may ask why I want to
>>> put attribute into the text of document rather than to config file or to
>>> command line option. I want table of contents only in some longer
>>> documents and not in short ones, so config file is not suitable. And I'm
>>> generating xhtml dynamically by CGI (FastCGI to be exact) script, which
>>> means that command line options should be the same for all documents.
>> Not easily doable within AsciiDoc. You could go the DocBook route:
>> generate DocBook using AsciiDoc then XHTML with TOC using XSLT
>> Stylesheets. If you are able to run JavaScript server-side over the
>> XHTML you may be able to generate the TOC that way but I don't have any
>> experience with server-side JavaScript.
> correct me if I'm wrong. I thought that XHTML TOC is just matter of embedding
> or linking of toc.js. This script then generates TOC dynamically when 
> displayed by client (web browser). In this respect there is no difference 
> whether I generate my documect by command line or by CGI script. All I want 
> is to choose whether toc.js is included, and I want to do it separately for 
> each document.
> My question was basically whether I can choose that I want toc.js included by 
> putting an atribute into the text. I don't fully understand which attributes 
> can or cannot be part of an AttributeEntry. You can for example put
> ":encoding: ISO-8859-1" into document header but setting 
> e.g. ":iconsdir: /home/pavel/icons" in the document would have no effect?  I 
> am asking whether ":toc:" or something simillar would work in the document.

Here's the full explanation:

AsciiDoc has to read the configuration files *before* reading the
source document, this is necessary because the AsciiDoc source syntax
is mostly defined by the configuration files.

This means that any lines of markup eveloped by conditional inclusion
macros will be included or excluded *before* the attribute entries in
the AsciiDoc document header are read, so setting related attributes
in the AsciiDoc source document header will have no effect.  If you
need to control configuration file markup inclusion using attributes
in the AsciiDoc source file header you need to use attribute
references to control inclusion instead of conditional inclusion
macros (attribute references are substituted at the time the output is
written rather than at program startup).

These contrived examples illustrate the two forms of conditional
inclusion. The only difference between them is that the first is
evaluated at program load time while the second is evaluated when the
markup is written (after the AsciiDoc source header has been processed):

     <h2>Hello World!<\h2>

   {mytitle#}<h2>Hello World!<\h2>

So it can be done. You'll need to create a custom [header] based on the 
default xhtml11.conf [header]. You'll also need to replace the 
include1::[] macro call with the {include:} system attribute. The reason 
I decided not to make this the default behavior is that the {include:} 
system attribute is considered unsafe so all XHTML generation would have 
to run asciidoc using the --unsafe option.

Actually iconsdir can be set in the header but the path is relative to 
the generated HTML output i.e. it is the path at document view time 
rather than at document creation time (not spelled out in the 
documentation, I must make a note to that effect).

> Pavel
>>> Cheers
>>> Pavel
>>> _______________________________________________
>>> Asciidoc-discuss mailing list
>> Cheers, Stuart

Cheers, Stuart

Asciidoc-discuss mailing list

Reply via email to