1.3.0 • Published 7 months ago

uniorg-stringify v1.3.0

Weekly downloads
-
License
GPL-3.0-or-later
Repository
github
Last release
7 months ago

uniorg-stringify

uniorg plugin to serialize org-mode.

Install

npm install uniorg-stringify

Use

import { unified } from 'unified';
import uniorgParse from 'uniorg-parse';
import { uniorgStringify } from 'uniorg-stringify';

const result = unified()
  .use(uniorgParse)
  .use(uniorgStringify)
  .processSync('Some /emphasis/, *importance*, and ~code~.');

console.log(String(result)); //=> Some /emphasis/, *importance*, and ~code~.

API

processor().use(uniorgStringify[, options])

uniorg plugin to serialize uniast into string.

stringify(uniast[, options])

Convert uniorg AST into a string.

import { parse } from 'uniorg-parse/lib/parser';
import { stringify } from 'uniorg-stringify/lib/stringify';

stringify(parse(`* headline`));

options

handlers

Allow overriding rendering for any uniorg type. Each handler receives the node of the corresponding type and should return a string.

For example to output bold emphasis with dollar signs instead of stars:

const processor = unified()
  .use(uniorgParse)
  .use(uniorgStringify, {
    handlers: {
      'bold': (org, options) => {
        return `$${stringify(org.children, options)}$`;
      },
    },
  });

License

GNU General Public License v3.0 or later

1.2.0

7 months ago

1.3.0

7 months ago

1.1.1

1 year ago

1.1.0

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

0.5.6

2 years ago

0.5.3

2 years ago

0.5.2

3 years ago

0.5.0

3 years ago

0.5.1

3 years ago

0.4.9

3 years ago