2.0.13 • Published 1 year ago

solid-markdown v2.0.13

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

solid-markdown

Render markdown as solid components.

The implementation is 90% shamelessly copied from https://github.com/remarkjs/react-markdown.

Changes include:

  • Replacing React specific component creation with SolidJS components
  • Porting the implementation from javascript with JSDoc types to typescript

Please check the original repo for in-depth details on how to use.

Installation

npm install solid-markdown

Usage

import { SolidMarkdown } from "solid-markdown";

const markdown = `
# This is a title

- here's
- a
- list
`;
const App = () => {
  return <SolidMarkdown children={markdown} />;
};

Rendering strategy

There's an extra option you can pass to the markdown component: renderingStrategy: "memo" | "reconcile".

The default value is "memo", which means that the markdown parser will generate a new full AST tree each time (inside a useMemo), and use that. As a consequence, the full DOM will be re-rendered, even the markdown nodes that haven't changed. (Should be fine 90% of the time).

Using reconcile will switch the strategy to using a solid store with the reconcile function (https://docs.solidjs.com/reference/store-utilities/reconcile). This will diff the previous and next markdown ASTs and only trigger re-renders for the parts that have changed. This will help with cases like streaming partial content and updating the markdown gradually (see https://github.com/andi23rosca/solid-markdown/issues/32).

<SolidMarkdown renderingStrategy="reconcile" children={markdown} />;

TODO

  • Port unit tests from from original library
2.0.13

1 year ago

2.0.5

1 year ago

2.0.4

1 year ago

2.0.11

1 year ago

2.0.7

1 year ago

2.0.12

1 year ago

2.0.6

1 year ago

2.0.9

1 year ago

2.0.10

1 year ago

2.0.8

1 year ago

2.0.3

1 year ago

2.0.2

1 year ago

2.0.1

1 year ago

2.0.0

2 years ago

1.2.2

2 years ago

1.2.1

2 years ago

1.2.0

3 years ago

1.1.0

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago