@welshman/content 0.0.13 → 0.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +20 -2
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -1,11 +1,29 @@
1
1
  # @welshman/content [![version](https://badgen.net/npm/v/@welshman/content)](https://npmjs.com/package/@welshman/content)
2
2
 
3
- Utilities for parsing note content.
3
+ Utilities for parsing and rendering note content. Customizable via RenderOptions.
4
4
 
5
5
  ```typescript
6
6
  import {parse, render} from '@welshman/content'
7
7
 
8
8
  const content = "Hello<br>from https://coracle.tools! <script>alert('evil')</script>"
9
- const html = parse({content}).map(render).join("")
9
+ const parsed = parse({content, tags: []})
10
+ // [
11
+ // { type: 'text', value: 'Hello<br>from ', raw: 'Hello<br>from ' },
12
+ // {
13
+ // type: 'link',
14
+ // value: { url: URL, isMedia: false },
15
+ // raw: 'https://coracle.tools'
16
+ // },
17
+ // {
18
+ // type: 'text',
19
+ // value: "! <script>alert('evil')</script>",
20
+ // raw: "! <script>alert('evil')</script>"
21
+ // }
22
+ // ]
23
+
24
+ const result = renderAsText(parsed)
25
+ // => Hello&lt;br&gt;from https://coracle.tools/! &lt;script&gt;alert('evil')&lt;/script&gt;
26
+
27
+ const result = renderAsHtml(parsed)
10
28
  // => Hello&lt;br&gt;from <a href="https://coracle.tools/" target="_blank">coracle.tools/</a>! &lt;script&gt;alert('evil')&lt;/script&gt;
11
29
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@welshman/content",
3
- "version": "0.0.13",
3
+ "version": "0.0.14",
4
4
  "author": "hodlbod",
5
5
  "license": "MIT",
6
6
  "description": "A collection of utilities for parsing nostr note content.",
@@ -32,7 +32,7 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "@braintree/sanitize-url": "^7.0.2",
35
- "@welshman/lib": "~0.0.28",
35
+ "@welshman/lib": "~0.0.33",
36
36
  "nostr-tools": "^2.7.2"
37
37
  }
38
38
  }