Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Asciidoc to Asciidoc: Exploding Includes

DZone's Guide to

Asciidoc to Asciidoc: Exploding Includes

I don't want to have to convert my code to one of these formats each time — I want to convert asciidoc to asciidoc! Here's how I accomplished this.

· Database Zone ·
Free Resource

RavenDB vs MongoDB: Which is Better? This White Paper compares the two leading NoSQL Document Databases on 9 features to find out which is the best solution for your next project.  

One of my favorite features in AsciiDoc is the ability to include other files, but when using lots of includes, it becomes difficult to read the whole document unless you convert it to one of the supported backends.

I don't want to have to convert my code to one of these formats each time — I want to convert asciidoc to asciidoc!

For example, given the following files:

mydoc.adoc:

= My Blog example
 
== Heading 1
 
Some awesome text
 
== Heading 2
 
include::blog_include.adoc[]

blog_include.adoc:

Some included text

I want to generate another asciidoc file where the contents of the include file are exploded and displayed inline.

After a lot of searching, I came across an excellent script written by Dan Allen and put it in a file called adoc.rb. We can then call it like this:

$ ruby adoc.rb mydoc.adoc
= My Blog example
 
== Heading 1
 
Some awesome text
 
== Heading 2
 
Some included text

Problem solved!

In my case, I actually wanted to explode HTTP includes, so I needed to pass the -a allow-uri-read flag to the script:

$ ruby adoc.rb mydoc.adoc -a allow-uri-read

And now I can generate asciidoc files until my heart’s content.

Get comfortable using NoSQL in a free, self-directed learning course provided by RavenDB. Learn to create fully-functional real-world programs on NoSQL Databases. Register today.

Topics:
database ,tutorial ,asciidoc

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}