Skip to content
HashML is a markup language based on #️⃣
TypeScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
benchmark
docs
src
test
.gitignore
.mocharc.json
.npmignore
.nycrc.json
.prettierignore
.prettierrc.json
.travis.yml
LICENSE
README.md
compileSchemaSchema.ts
package-lock.json
package.json
tsconfig.build.json
tsconfig.json
tslint.json

README.md

Hashml parser

npm version Build Status Coverage Status

Installation

npm install @hashml/hashml

What is Hashml?

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

#document Hashml parser
	#section Installation
		#code bash
			npm install @hashml/hashml

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

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

Usage

To parse a Hashml document from a Typescript program:

import { parse, ParsedSchema } from "@hashml/hashml";

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 "@hashml/hashml";
const xml: string = toXML(doc);
const json: string = toJSON(doc);

CLI

See the @hashml/cli package.

You can’t perform that action at this time.