@hashmark/parser
Hashmark parser
Last updated 10 months ago by maximekjaer .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @hashmark/parser 
SYNC missed versions from official npm registry.

Hashmark parser

npm version Build Status Coverage Status

Installation

npm install @hashmark/parser

What is Hashmark?

Hashmark is a markup language. It's more structured than Markdown, but less verbose than XML. Here's what this README would look like in Hashmark:

#document Hashmark parser
	#section Installation
		#code bash
			npm install @hashmark/parser

	#section What is Hasmark?
		Hashmark is a markup language. It's more structured than Markdown, ...

You can read more about the Hashmark language in the docs.

Usage

To parse a Hashmark document,

import { parse, ParsedSchema } from "@hashmark/parser";

const file = "#tag example";
const schemaFile = "#block tag"
const schemaSchemaFile = "#block block";

// Parse with a schema:
const schemaSchema = new ParsedSchema(parse(schemaSchemaFile));
const schema = new ParsedSchema(parse(schemaFile, schemaSchema));
const doc = parse(file, schema)

// ... or parse without a schema:
const noSchemaDoc = parse(file)

Parsing with a schema allows you to define syntactic sugar in the schema, like default elements and inline syntactic sugar.

To validate the document using the schema, use the validateBlock method on the schema. This returns an array of validation errors. If there are no errors, it will return an empty array.

const errors = schema.validateBlock(doc);

To export the document to JSON or XML:

import { toXML, toJSON} from "@hashmark/parser";
const xml: string = toXML(doc);
const json: string = toJSON(doc);

CLI

See the @hashmark/cli package.

Current Tags

  • 0.1.0                                ...           latest (10 months ago)

3 Versions

  • 0.1.0                                ...           10 months ago
  • 0.0.4                                ...           a year ago
  • 0.0.3                                ...           a year ago
Maintainers (2)
Downloads
Today 0
This Week 3
This Month 3
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (17)
Dependents (1)

Copyright 2014 - 2017 © taobao.org |