uniorg-stringify
TypeScript icon, indicating that this package has built-in type declarations

1.3.0 • Public • Published

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

Package Sidebar

Install

npm i uniorg-stringify

Weekly Downloads

7

Version

1.3.0

License

GPL-3.0-or-later

Unpacked Size

61 kB

Total Files

9

Last publish

Collaborators

  • rasendubi
  • thomasfkjorna