The AsciiDoc syntax Metanorma syntax is an enriched syntax -- not supported by normal AsciiDoc parsers (including the vanilla asciidoctor parser we use)
Metanorma AsciiDoc syntax in a file is stored in an .adoc file, and parsed by Metanorma
Metanorma uses asciidoctor to parse the .adoc file(s). Metanorma has a "plugin" into asciidoctor to obtain a "pseudo document tree" state of the file as an Asciidoctor object.
Metanorma builds an XML file to represent that pseudo document tree object
Metanorma writes the XML file into "semantic XML" and "presentational XML" files. The semantic XML file contains mostly data, the presentational XML file contains mostly presentation (e.g. a NOTE is represented in semantic xml as a <note> element, but becomes a <p> in presentational XML)
The .xml file is loaded into Metanorma for rendering. Instead of loading the XML file as a Metanorma::Document object, it just runs XPath queries on this XML file using Nokogiri.
Metanorma converts the presentational or semantic .xml files into outputs, like HTML, PDF and Word.
The ideal flow:
Metanorma loads the AsciiDoc file using the new AsciiDoc parser. This gives us an AsciiDoc parse tree object (a generic AsciiDoc tree)
Metanorma "specializes" this AsciiDoc parse tree into a Metanorma::Document document node tree. For example, a generic AsciiDoc section object can be specialized as the Bibliography class object in Metanorma.
Metanorma processes the Metanorma::Document such as for link resolution
Metanorma calls Document.to_xml to write the XML files
The Metanorma Document object is passed to the presentation rendering stage, to generate the outputs
Note:
To support different standard we will need to build an extension mechanism where we can run callbacks on encountering document nodes, so different flavours can build their documents differently. E.g. there would be a Metanorma::Document::Iso vs Metanorma::Document::Ogc
Current Architecture
<note>
element, but becomes a<p>
in presentational XML)The ideal flow:
Note:
To support different standard we will need to build an extension mechanism where we can run callbacks on encountering document nodes, so different flavours can build their documents differently. E.g. there would be a Metanorma::Document::Iso vs Metanorma::Document::Ogc
//cc: @ronaldtse