= AsciiCSD: Metanorma processor for CSD standards

image:https://img.shields.io/gem/v/metanorma-csd.svg["Gem Version", link="https://rubygems.org/gems/metanorma-csd"]
image:https://img.shields.io/travis/metanorma/metanorma-csd/master.svg["Build Status", link="https://travis-ci.org/metanorma/metanorma-csd"]
image:https://ci.appveyor.com/api/projects/status/t3h1p2ycut673n8j?svg=true["Appveyor Build Status", link="https://ci.appveyor.com/project/ribose/metanorma-csd"]
image:https://codeclimate.com/github/metanorma/metanorma-csd/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/metanorma/metanorma-csd"]

_Formerly known as_ `asciidoctor-csd`.

WARNING: This gem is still under development.

== Functionality

This gem processes http://asciidoctor.org/[Asciidoctor] documents following
a template for generating CSD International Standards.

The gem currently inherits from the https://github.com/metanorma/metanorma-standoc
gem, and aligns closely to it. Refer to the ISO gem documentation
for guidance, including https://github.com/metanorma/metanorma-iso/wiki/Guidance-for-authoring

The following outputs are generated.

* (Optional) An HTML preview generated directly from the Asciidoctor document,
using native Asciidoc formatting.
** http://asciimath.org[AsciiMathML] is to be used for mathematical formatting.
The gem uses the https://github.com/asciidoctor/asciimath[Ruby AsciiMath parser],
which is syntactically stricter than the common MathJax processor;
if you do not get expected results, try bracketting terms your in AsciiMathML
expressions.
* an XML representation of the document, intended as a document model for CSD
International Standards.
* The XML representation is processed in turn to generate the following outputs
as end deliverable CSD standard drafts.
** HTML
** PDF

This AsciiDoc syntax for writing CSD standards is hereby named "AsciiCSD".

== Usage

The preferred way to invoke this gem is via the `metanorma` script:

[source,console]
----
$ metanorma --type csd a.adoc                   # output HTML and PDF
$ metanorma --type csd --extensions html a.adoc # output just HTML
$ metanorma --type csd --extensions pdf a.adoc  # output just PDF
$ metanorma --type csd --extensions xml a.adoc  # output CSD XML
----

The gem translates the document into CSD XML format, and then
validates its output against the CSD XML document model; errors are
reported to console against the XML, and are intended for users to
check that they have provided all necessary components of the
document.

The gem then converts the XML into HTML and PDF.

////
The gem can also be invoked directly within asciidoctor, though this is deprecated:

[source,console]
----
$ asciidoctor -b csd -r 'metanorma-csd' a.adoc
----
////

=== Installation

If you are using a Mac, the https://github.com/metanorma/metanorma-macos-setup
repository has instructions on setting up your machine to run Metanorma
scripts such as this one. You need only run the following in a Terminal console:

[source,console]
----
$ bash <(curl -s https://raw.githubusercontent.com/metanorma/metanorma-macos-setup/master/metanorma-setup)
$ gem install metanorma-csd
----

=== PDF output

PDF output is generated by printing the HTML output as PDF. This is done
within the gem, using
https://developers.google.com/web/updates/2017/04/headless-chrome[Headless Chrome],
via the https://github.com/GoogleChrome/puppeteer[Puppeteer] Node library.

To get the PDF output working, do the following:

* Install Node, with at least version 7.6.0: https://nodejs.org/en/download/,
https://nodejs.org/en/download/package-manager/ . (For Mac, `brew install node`)
* Install npm: https://docs.npmjs.com/getting-started/installing-node
* Install puppeteer: `npm install -g --save --save-exact puppeteer`

The https://github.com/metanorma/metanorma-macos-setup script includes Puppeteer
installation.

== Documentation

See https://www.metanorma.com/author/csd/[Author CalConnect documents with Metanorma-CSD].