0.1.0 • Published 4 months ago

@welshman/content v0.1.0

Weekly downloads
-
License
MIT
Repository
-
Last release
4 months ago

@welshman/content version

Utilities for parsing and rendering note content. Customizable via RenderOptions.

import {parse, render} from '@welshman/content'

const content = "Hello<br>from https://coracle.tools! <script>alert('evil')</script>"
const parsed = parse({content, tags: []})
// [
//   { type: 'text', value: 'Hello<br>from ', raw: 'Hello<br>from ' },
//   {
//     type: 'link',
//     value: { url: URL, isMedia: false },
//     raw: 'https://coracle.tools'
//   },
//   {
//     type: 'text',
//     value: "! <script>alert('evil')</script>",
//     raw: "! <script>alert('evil')</script>"
//   }
// ]

const result = renderAsText(parsed)
// => Hello&lt;br&gt;from https://coracle.tools/! &lt;script&gt;alert('evil')&lt;/script&gt;

const result = renderAsHtml(parsed)
// => Hello&lt;br&gt;from <a href="https://coracle.tools/" target="_blank">coracle.tools/</a>! &lt;script&gt;alert('evil')&lt;/script&gt;
0.1.0

4 months ago

0.0.16

5 months ago

0.0.17

5 months ago

0.0.18

5 months ago

0.0.19

4 months ago

0.0.15

6 months ago

0.0.13

7 months ago

0.0.14

6 months ago

0.0.10

9 months ago

0.0.11

9 months ago

0.0.12

9 months ago

0.0.9

10 months ago

0.0.8

10 months ago

0.0.7

11 months ago

0.0.6

11 months ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago