Considering that a book in DocBook format can be done in a "modular" fashion, I hoped I can do similar with AsciiDoc and split chapters and first-level sections in separate files. Unfortunately documentation does not say anything about this. The only possible solution I see so far is to write my own AsciiDoc preprocessor that will merge all "part"-files and generate the book. Did someone solve this problem by now?
Two example ways from the asciidoc cheatsheet: http://powerman.name/doc/asciidoc
include::footer.txt[]
or
[source,perl]
----
include::script.pl[]
----
I have set up a book template that I use in all by book, you can find it here: asciidoc-book-template-with-rake-and-github
= Nome da disciplina
:doctype: book
:lang: pt-BR
:ascii-ids:
:showcomments:
:gitrepo: https://github.com/xxx/yyy
:code_dir: code
:image_dir: imagens
include::capitulos/prefacio.adoc[]
////
= Nome da Parte =
////
include::capitulos/cap1.adoc[]
include::capitulos/feedback.adoc[]
include::capitulos/cap2.adoc[]
include::capitulos/feedback.adoc[]
include::capitulos/cap3.adoc[]
include::capitulos/feedback.adoc[]
// ...
include::capitulos/glossario.adoc[]
include::capitulos/respostas.adoc[]
////
Always end files with a blank line to avoid include problems.
////
Note the blank lines between the include directives: they prevent the first and last lines of the included files from being adjoined. I don't split chapter on more files because when you include a file asciidoc takes the included file path to be the parent of new includes, look this tree:
.
|-- capitulos
| |-- cap1.adoc
| |-- cap2.adoc
| |-- cap3.adoc
| |-- code
| | `-- cap1
| | |-- helloworld.c
| | `-- Makefile
| |-- feedback.adoc
| |-- glossario.adoc
| |-- prefacio.adoc
| |-- respostas.adoc
| `-- symbols.adoc
|-- docinfo.xml
|-- livro.asc
`-- wip.adoc
livro.adoc
and I what to include feedback.adoc
I will use include::capitulos/feedback.adoc[]
cap1.adoc
you will have to use include::feedback.adoc[]
(since they are at the same directory).I think it's more easy to keep all includes in one same place, it works for me. I only include codes using the other way.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With