# noddity-template-parser

> Turns Noddity posts into a really simple AST

Latest version **1.1.1** (published 2017-01-31) · WTFPL license · 0 weekly downloads

## Install

```sh
npm install noddity-template-parser
pnpm add noddity-template-parser
yarn add noddity-template-parser
bun add noddity-template-parser
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2017-01-31 |
| First published | 2015-09-28 |
| Weekly downloads | 0 |
| License | WTFPL |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | TehShrike |
| Maintainers | tehshrike |
| Keywords | noddity |

## Links

- npm: https://www.npmjs.com/package/noddity-template-parser
- Repository: https://github.com/TehShrike/noddity-template-parser
- Issues: https://github.com/TehShrike/noddity-template-parser/issues
- npm.io page: https://npm.io/package/noddity-template-parser

## Dependencies (3)

- [ent](https://npm.io/package/ent.md) 2.2.0
- [remarkable](https://npm.io/package/remarkable.md) ^1.6.0
- [regexp.execall](https://npm.io/package/regexp.execall.md) ^1.0.2

## Recent versions

- 1.1.1 (latest) — 2017-01-31
- 1.1.0 — 2016-06-21
- 1.0.4 — 2015-10-28
- 1.0.3 — 2015-10-08
- 1.0.2 — 2015-10-06
- 1.0.1 — 2015-10-06
- 1.0.0 — 2015-09-28

## README

[![Build Status](https://travis-ci.org/TehShrike/noddity-template-parser.svg)](https://travis-ci.org/TehShrike/noddity-template-parser)

Turns [Noddity](http://noddity.com) post objects into basic [abstract syntax trees](https://en.wikipedia.org/wiki/Abstract_syntax_tree).

## Example

```js
var parser = require('noddity-template-parser')
var Linkify = require('linkify')

var linkify = Linkify('#/prefix')

var ast = parser(post, linkify)

var full = ast.reduce(function (full, piece) {
	if (piece.type === 'string') full += piece.value
	if (piece.type === 'template') full += 'TEMPLATE GOES HERE'
	return full
}, '')
```

## API

```js
var parser = require('noddity-template-parser')
```

### `var ast = parser(post, linkify, [options])`

- `post`: a Noddity post object (from a [Noddity Butler](https://github.com/TehShrike/noddity-butler))
- `linkify`: a [Noddity Linkifier](https://github.com/TehShrike/noddity-linkifier)
- `options`: an optional object of options
	- `convertToHtml`: convert posts from markdown to HTML. Defaults to true. (If `markdown: false` is on the post's metadata, it will not be converted, even when this is set to true.)

```js
var ast = parser(post, linkify, { convertToHtml: false })
```

### `ast`

An array of objects returned from `parser()`. Each object has a type property which can be `string`, or `template`.

- `string` type properties:
	- `value` string with html or markdown
- `template` type properties:
	- `filename` string, e.g. `'my-post.md'`
	- `arguments` object, e.g. `{ 1: 'hello', key: 'value' }`

The AST for this post...

```
---
prop: val
---

::child|arg|key=value::

I see you like {{prop}} templates
```

...would look like:

```js
[{
	type: 'string',
	value: '<p>'
}, {
	type: 'template',
	filename: 'child',
	arguments: {
		1: 'arg',
		key: 'value'
	}
}, {
	type: 'string',
	value: '</p>\n<p>I see you like {{prop}} templates</p>\n'
}]
```

## License

[WTFPL](http://wtfpl2.com)

---
_Source: https://npm.io/package/noddity-template-parser · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
