dbhtml Processing Instruction Problem

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

dbhtml Processing Instruction Problem

eskwayrd
Hi,

I've been managing a DocBook-based workflow for a number of technical guides. I'm incorporating AsciiDoc to make it easier for new authors to use the same workflow, but use much easier syntax. I'm using AsciiDoctor to handle the generation of DocBook 5, which then feeds into the common HTML/PDF/CHM transformations. So far, most everything is working well enough, but I'm struggling to get the dbhtml processing instruction (PI) for a guide to work properly.

The problem we solved in DocBook was that, without the dbhtml PI, the generated index.html file included just the book's copyright information, and we wanted the first chapter to be chunked as index.html. The solution was to add <?dbhtml filename="index.html"?> to the first chapter, and <?dbhtml filename="copyright.html"?> to book.xml.

Using AsciiDoc, adding the dbhtml PI to the first chapter works well. For example, in chapter.adoc:

== Chapter Title
++++
<?dbhtml filename="index.html"?>
++++

...

which renders as:

<chapter xml:id="chapter">
<title>Chapter Title</title>
<?dbhtml filename="index.html"?>
...

However, I cannot get the dbhtml PI to render correctly for the book. If book.adoc starts with:

= Book Title
:doctype: book
:toc:

++++
<?dbhtml filename="copyright.html"?>
++++
...

this renders as:

<?xml version="1.0" encoding="UTF-8"?>
<?asciidoc-toc?>
<?asciidoc-numbered?>
<book xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" version="5.0" xml:lang="en"><title>Book Title</title>
<info>

<date>2015-04-17</date>
</info>
<preface>
<title></title>
<?dbhtml filename="copyright.html"?>
</preface>
...

Basically, an empty preface is generated to contain the PI, which does nothing good since we're chunking at the chapter level (including prefaces) or tighter in each book. If I remove the blank line between the header and the passthrough, the initial ++++ becomes the author name and the remainder becomes paragraph text.

Is there a way to solve this problem in AsciiDoc? So far, I'm having to post-process the generated DocBook prior to initiating the XSLT transforms, but this requires some convention-based text-replacement which I'm not altogether happy with.

Thanks for any suggestions!
Reply | Threaded
Open this post in threaded view
|

Re: dbhtml Processing Instruction Problem

mojavelinux
Administrator
This is just the way that the book doctype is parsed in AsciiDoc. The content that proceeds the first section is treated as the preamble.

One way to work around this is to create a Treeprocessor extension that reaches into the AST and "unwraps" the preamble block so that it renders as raw content. This would be a cleaner solution to the XSLT transform.

Here's an example of a Treeprocessor.


On Fri, Apr 17, 2015 at 3:49 PM, eskwayrd [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Hi,

I've been managing a DocBook-based workflow for a number of technical guides. I'm incorporating AsciiDoc to make it easier for new authors to use the same workflow, but use much easier syntax. I'm using AsciiDoctor to handle the generation of DocBook 5, which then feeds into the common HTML/PDF/CHM transformations. So far, most everything is working well enough, but I'm struggling to get the dbhtml processing instruction (PI) for a guide to work properly.

The problem we solved in DocBook was that, without the dbhtml PI, the generated index.html file included just the book's copyright information, and we wanted the first chapter to be chunked as index.html. The solution was to add <?dbhtml filename="index.html"?> to the first chapter, and <?dbhtml filename="copyright.html"?> to book.xml.

Using AsciiDoc, adding the dbhtml PI to the first chapter works well. For example, in chapter.adoc:

== Chapter Title
++++
<?dbhtml filename="index.html"?>
++++

...

which renders as:

<chapter xml:id="chapter">
<title>Chapter Title</title>
<?dbhtml filename="index.html"?>
...

However, I cannot get the dbhtml PI to render correctly for the book. If book.adoc starts with:

= Book Title
:doctype: book
:toc:

++++
<?dbhtml filename="copyright.html"?>
++++
...

this renders as:

<?xml version="1.0" encoding="UTF-8"?>
<?asciidoc-toc?>
<?asciidoc-numbered?>
<book xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" version="5.0" xml:lang="en"><title>Book Title</title>
<info>

<date>2015-04-17</date>
</info>
<preface>
<title></title>
<?dbhtml filename="copyright.html"?>
</preface>
...

Basically, an empty preface is generated to contain the PI, which does nothing good since we're chunking at the chapter level (including prefaces) or tighter in each book. If I remove the blank line between the header and the passthrough, the initial ++++ becomes the author name and the remainder becomes paragraph text.

Is there a way to solve this problem in AsciiDoc? So far, I'm having to post-process the generated DocBook prior to initiating the XSLT transforms, but this requires some convention-based text-replacement which I'm not altogether happy with.

Thanks for any suggestions!


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



--