Add documentation
This commit is contained in:
@@ -1,11 +1,29 @@
|
||||
# @welshman/content [](https://npmjs.com/package/@welshman/content)
|
||||
|
||||
Utilities for parsing note content.
|
||||
Utilities for parsing and rendering note content. Customizable via RenderOptions.
|
||||
|
||||
```typescript
|
||||
import {parse, render} from '@welshman/content'
|
||||
|
||||
const content = "Hello<br>from https://coracle.tools! <script>alert('evil')</script>"
|
||||
const html = parse({content}).map(render).join("")
|
||||
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<br>from https://coracle.tools/! <script>alert('evil')</script>
|
||||
|
||||
const result = renderAsHtml(parsed)
|
||||
// => Hello<br>from <a href="https://coracle.tools/" target="_blank">coracle.tools/</a>! <script>alert('evil')</script>
|
||||
```
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"entryPoints": ["src/index.ts"]
|
||||
}
|
||||
Reference in New Issue
Block a user