1.8.1 • Published 7 months ago

@lukekaalim/act-markdown v1.8.1

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

@lukekaalim/act-markdown

npm (scoped) npm bundle size (scoped)

A component library that parses markdown syntax via remark and renders it to html elements in @lukekaalim/act.

⚠️ Security

While obviously theres no intentional way to execute code from markdown, this library is not equipped to handle arbitrary, malformed or (in general) user-generated markdown. It's intended to be fed known and developer-written strings.

This library performs no sanitisation. Use at your own risk.

Install

npm install @lukekaalim/act-markdown

Features

@lukekaalim/act-markdown supports the following markdown features:

It does not support:

  • Embedded HTML elements

Usage

::::api{name=MarkdownRenderer}

:::type

{
  type: "expression",
  expression: {
    type: "opaque",
    name: "Component",
    referenceURL: "/concepts#Component",
    genericArguments: [
      { type: "object", entries: [
        { key: "markdownText", value: { type: "opaque", name: "string" } },
        { key: "directiveComponents", optional: true, value: { type: "object", entries: [
          { key: "[directiveKey: string]", value: { type: "opaque", name: "Component", referenceURL: "/concepts#Component", genericArguments: [
            { type: "object", entries: [
              { key: "node", value: { type: "opaque", name: "MarkdownASTNode", referenceURL: "https://github.com/syntax-tree/mdast", } }
            ] }
          ] } }
        ] } }
      ] }
    ]
  }
}

:::

import { MarkdownRenderer } from '@lukekaalim/act-markdown';

const markdownText = `
# Heading

This is my first paragraph! Lorum Ipsum or whatever.

![MyCoolPicture](http://example.com/image.jpg)
`

const ExampleComponent = () => {
  return h(MarkdownRenderer, { markdownText })
};

::::

1.8.1

7 months ago

1.8.0

9 months ago

1.7.0

9 months ago

1.6.1

9 months ago

1.6.0

9 months ago

1.5.0

1 year ago

1.2.0

2 years ago

1.1.0

2 years ago

1.4.0

2 years ago

1.3.0

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago