0.9.1 • Published 4 years ago

@henriette-einstein/henni-doctor v0.9.1

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

Henni-Doctor

Henriette's Asciidoc converter henni-doctor. It converts AsciiDoc files and returns a JSON Object that contains the metadata, custom attributes and the HTML fragment content corresponding to the given Asciidoc file.

Henni-Doctor can also be used with vinyl streams and via Gulp.

Installation

To include henni-doctor in a project use

yarn add @henriette-einstein/henni-doctor

To use the command line of henni-doctor use

yarn add @henriette-einstein/henni-doctor

This will install the command henni-doctor

Usage

This section describes how to integrate henni-project in a node application. The invocation of the command line is described later

Direct Invocation

const henni = require('henni-doctor')

const myOptions = {
  prefixes: ['data-'],
  attributes: {
    creator: 'Your Creator',
    idprefix: 'myid_'
  }
}

const doctor = new henni.Doctor(myOptions)
const ret = doctor.parseFile('PUT FILENAME HERE')

Vinyl Streams

Here is a sample for invoking

const path = require('path')
const vfs = require('vinyl-fs')
const henni = require('../index')

const myOptions = {
  extension: '.json',
  prefixes: ['data-'],
  attributes: {
    creator: 'Your Creator',
    idprefix: 'id_'
  }
}

const pattern = path.join(__dirname, '/**/*.adoc')
const resultDir = path.join(__dirname__, '/result')
vfs
  .src(pattern)
  .pipe(henni())
  .pipe(vfs.dest(resultDir))

Options

The bahavior of henni-doctor can be controlled via the following option parameters

extension

Type: String

This option is only used when used with Gulp or vinyl-fs. It can be used, to define a different extension for the resulting file. The default for this option ist:

extension: '.json'

`prefixes

Type: Array of strings

Extract only attributes with the given prefixes from the AsciiDoc file. If the option is not set or the options contains the value 'all', all attributes will be included in the result.

The default vaule for this option is not set. Therefore all attributes are included by default.

To extract only attributes with the prefixes 'data-' and 'mydata-' from the instances, use the following configuration:

prefixes: ['data-', 'mydata-']

attributes

Type: JSON object

This option contains the attributes to be passed to the underlying AsciiDoctor converter. The default for this option is

attributes: {
  idprefix: 'id_'
}

Command Line

You can invoke henni-doctor via the CLI.

Usage: henni-doctor.js <options> pattern

Optionen:
  --version           Version anzeigen                                 [boolean]
  --output, -o        Path to output directory          [string] [Standard: "."]
  --extension, --ext  The extension for the resulting output files
                                                    [string] [Standard: ".json"]
  --prefixes, --pre   The prefix of the attributes to extract. Can be set more
                      than once                                         [string]
  --help              Hilfe anzeigen                                   [boolean]

The pattern must be a valid vinyl-fs source pattern (like "docs/*/.adoc"). You probably have to enclose the pattern otherwise your shell may try to expand the value before invoking the application.