0.1.1 • Published 4 years ago

@unified-doc/text-parse v0.1.1

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

text-parse

unified parser to parse text content into a hast tree with a single text node.

Install

yarn add @unified-doc/text-parse

Use

import text from '@unified-doc/text-parse';
import unified from 'unified';
import html from 'rehype-stringify';

const processor = unified()
	.use(text)
	.use(html)

processor.parse('\na to the \nb to the \n\nc to the d');

Yields a hast tree where the input content string is represented as a single text node.

{
	type: 'root',
	children: [
		{
			type: 'text',
			value: '\na to the \nb to the \n\nc to the d',
			position: {
				start: {
					column: 1,
					line: 1,
					offset: 0,
				},
				end: {
					column: 11,
					line: 5,
					offset: 32,
				},
			},
		},
	],
}

API

export default function parse(): void;

Simply use the plugin with any unified processor.

export default ({ children }) => children

0.1.1

4 years ago

0.1.0

4 years ago