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

Databases are better when they can run themselves. CockroachDB is a SQL database that automates scaling and recovery. Check it out here.

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.

Databases should be easy to deploy, easy to use, and easy to scale. If you agree, you should check out CockroachDB, a scalable SQL database built for businesses of every size. Check it out here. 

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 }}