@lukekaalim/act-markdown
TypeScript icon, indicating that this package has built-in type declarations

1.8.1 • Public • Published

@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 })
};

::::

Readme

Keywords

none

Package Sidebar

Install

npm i @lukekaalim/act-markdown

Weekly Downloads

1

Version

1.8.1

License

MIT

Unpacked Size

12.6 kB

Total Files

5

Last publish

Collaborators

  • lukekaalim