Hi guys, I am working on my ASCIIDoctor site, and an issue raised its head. Right now, in each .adoc file, I have the following line right after the top header: include::toc.adoc[] This component (toc.adoc) is generated from the collection of documents by an outside script. The thing is, the documentation author shouldn’t have to worry about including
that magic incantation – ideally, it would be brought in from outside, by the framework. However, I have no idea how to do this. I am having a vague feeling that I should do something in
_ext/pipeline.rb to address this, but I have no idea how. Any suggestions? Code snippets? Thanks in advance. |
Administrator
|
It would be pretty ugly. You'd have to load up the AsciiDoc document, read it into an array, add the line you'd need then save that as the new page.raw_content. On Wed, Mar 26, 2014 at 11:57 AM, Victor Danilchenko <[hidden email]> wrote:
|
There’s no clean way to hook into the parsing process, and just insert two lines dynamically, as the .adoc file is being read? From: Jason Porter [mailto:[hidden email]]
It would be pretty ugly. You'd have to load up the AsciiDoc document, read it into an array, add the line you'd need then save that as the new page.raw_content. On Wed, Mar 26, 2014 at 11:57 AM, Victor Danilchenko <[hidden email]> wrote: Hi guys, I am working on my ASCIIDoctor site, and an issue raised its head. Right now, in each .adoc file, I have the following line right after the top header:
include::toc.adoc[] This component (toc.adoc) is generated from the collection of documents by an outside script. The thing is, the documentation
author shouldn’t have to worry about including that magic incantation – ideally, it would be brought in from outside, by the framework. However, I have no idea how to do this. I am having a vague feeling that I should do something in
_ext/pipeline.rb to address this, but I have no idea how. Any suggestions? Code snippets? Thanks in advance.
-- Jason Porter |
Administrator
|
No, asciidoctor doesn't support that unfortunately. On Wed, Mar 26, 2014 at 12:17 PM, Victor Danilchenko <[hidden email]> wrote:
|
In reply to this post by vdanilchenko@vistaprint.com
> Right now, in each .adoc file, I have the following line right after the top header: I do like that idea to keep it DRY. Asciidoctor (and AsciiDoc) supports a "docinfo" file, which is source that is included in the header or footer of the output. We're talking about having an AsciiDoc docinfo that is included in the header or footer of the input...similar to prepend / append directives in Apache httpd. However, we don't support that yet. On Wed, Mar 26, 2014 at 12:17 PM, Victor Danilchenko <[hidden email]> wrote: There’s no clean way to hook into the parsing process, and just insert two lines dynamically, as the .adoc file is being read? Actually, it does. You can use a preprocessor extension. You could also use a postprocessor extension and just inject the toc into the output. You can find extension examples here: You'd put the extension in your site (under _ext) and then require them from _ext/pipeline.rb. You can see an example in the Asciidoctor website. |
Free forum by Nabble | Edit this page |