Search code examples
asciidocasciidoctor

Is there a way to render the document attributes of an asciidoc file and output to an adoc file?


Consider the following example

:title: An AsciiDoc file
:CustomAttribute: XYZ

= {title}

Some paragraphs.

[comment]
--
Some comments including that {CustomAttribute} variable.
--

// EOF

Is there anyway I could render the above file with AsciiDoc/AsciiDoctor into

:title: An AsciiDoc file
:CustomAttribute: XYZ

= An AsciiDoc file

Some paragraphs.

[comment]
--
Some comments including that XYZ variable.
--

// EOF

... so that I could extract/work with the latest attributes? I've found nothing in the documentation, but I might have overlooked it.

The alternatives I see at the moment would require writing a script to make those substitutions and extract the information I need before converting the AsciiDoc file.

Perhaps there is a much simpler approach; any suggestions?


Solution

  • Today, Asciidoctor does not generate AsciiDoc. Once the AsciiDoc Language Specification is complete, generating AsciiDoc will be possible.

    You could use a script, as you suggested, to cement the attribute values. Another alternative might be:

    1. Generate DocBook XML using Asciidoctor:

      asciidoctor -b file.adoc
      
    2. Use pandoc to convert the DocBook XML to AsciiDoc:

      pandoc -f docbook -t asciidoc -o file-no_attributes.adoc file.xml
      

    Note: if you replace file.adoc with file-no_attributes.adoc, you won't see future attribute updates because they have been replaced with plain text.