0.3.0 • Published 11 months ago

wikiast-util-to-wikitext v0.3.0

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

wikiast-util-to-wikitext

Serialize Wiki AST back to wikitext.

Why not a $tw method?

This functionality is not included in the Tiddlywiki core, because Tiddlywiki normally will construct widget tree, and render Wiki AST as HTML for end user.

And Tiddlywiki itself does not allow directly edit rendered HTML or widget tree, so it doesn't need a way to get wikitext from rendered result in the core.

Usage

import { wikiAstToWikiText } from "wikiast-util-to-wikitext";

// with or without position info `start: 0, end: 3` are both ok
const wikiast = [
  {
    type: "element",
    tag: "p",
    children: [{ type: "text" as const, text: "AAA" }],
  },
];
const wikitext = wikiAstToWikiText(wikiast);
expect(wikitext).toEqual("AAA");
0.3.0

11 months ago

0.2.0

11 months ago

0.1.0

11 months ago