|
| 1 | +import textile = require("textile-js"); |
| 2 | + |
| 3 | +const txt = "h1. Hello World"; |
| 4 | +const opt: textile.Options = { breaks: true }; |
| 5 | + |
| 6 | +const rendered: string = textile(txt, opt); |
| 7 | + |
| 8 | +const parsed: string = textile.parse(txt, opt); |
| 9 | +const converted: string = textile.convert(txt, opt); |
| 10 | + |
| 11 | +const doc: textile.JMLDocument = textile.jsonml(txt, opt); |
| 12 | +const serializedDoc: string = textile.serialize(doc); |
| 13 | + |
| 14 | +const node: textile.JMLElement = ["p", { class: "intro", "data-id": 1 }, "Hello"]; |
| 15 | +const serializedNode: string = textile.serialize(node); |
| 16 | + |
| 17 | +const textOnlySerialized: string = textile.serialize("plain text"); |
| 18 | + |
| 19 | +const defaults: textile.Options = textile.defaults; |
| 20 | +const chained: typeof textile = textile.setOptions(defaults).setoptions({ breaks: false }); |
| 21 | + |
| 22 | +const tokens: textile.Token[] = [ |
| 23 | + { type: "OPEN", tag: "p", pos: 0, src: "<p>" }, |
| 24 | + { type: "TEXT", data: "Hello", pos: 3, src: "Hello" }, |
| 25 | + { type: "CLOSE", tag: "p", pos: 8, src: "</p>" }, |
| 26 | +]; |
| 27 | + |
| 28 | +const parsedNode: textile.JMLNode = textile.html_parser(tokens); |
| 29 | +const parsedNodeLazy: textile.JMLNode = textile.html_parser(tokens, true); |
| 30 | + |
| 31 | +void rendered; |
| 32 | +void parsed; |
| 33 | +void converted; |
| 34 | +void serializedDoc; |
| 35 | +void serializedNode; |
| 36 | +void textOnlySerialized; |
| 37 | +void chained; |
| 38 | +void parsedNode; |
| 39 | +void parsedNodeLazy; |
0 commit comments