@draftably/markdown 0.2.0 → 0.2.2

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.
package/README.md CHANGED
@@ -8,18 +8,35 @@ load no Draftably JavaScript.
8
8
  pnpm add @draftably/markdown
9
9
  ```
10
10
 
11
- ```ts
12
- import remarkDraft from '@draftably/markdown/remark';
13
- import { createFileAssets } from '@draftably/markdown/files';
11
+ For a standalone Markdown build, install `markdown-it`, then use the async adapter and write its
12
+ HTML:
14
13
 
15
- const assets = createFileAssets({ directory: '.cache/diagrams', publicPath: '/diagrams/' });
16
- processor.use(remarkDraft, { emitAsset: assets.emitAsset });
17
- // After the build: await assets.copyTo('dist/diagrams');
14
+ ```sh
15
+ pnpm add @draftably/markdown markdown-it
18
16
  ```
19
17
 
18
+ ````js
19
+ import { mkdir, writeFile } from 'node:fs/promises';
20
+ import MarkdownIt from 'markdown-it';
21
+ import { createMarkdownItDraft } from '@draftably/markdown/markdown-it';
22
+ import { createFileAssets } from '@draftably/markdown/files';
23
+
24
+ const assets = createFileAssets({ directory: 'dist/diagrams', publicPath: '/diagrams/' });
25
+ const adapter = createMarkdownItDraft({ emitAsset: assets.emitAsset });
26
+ const md = new MarkdownIt().use(adapter.plugin);
27
+ const source = '```draft\ndiagram "API" version=1\nnode api "API"\n```';
28
+ const { html } = await adapter.render(md, source);
29
+ await mkdir('dist', { recursive: true });
30
+ await writeFile('dist/index.html', html);
31
+ ````
32
+
33
+ Run it as an `.mjs` file. This writes `dist/index.html` and the referenced SVG under
34
+ `dist/diagrams/`. For `src` includes, errors, Mermaid fences, caching and interactive mode, use the
35
+ [Markdown guide](https://draftably.dev/docs/markdown).
36
+
20
37
  ## Docs
21
38
 
22
39
  - [Markdown](https://draftably.dev/docs/markdown): a first build, fence options, includes,
23
40
  Mermaid fences and interactive mode
24
- - [Documentation sites](https://draftably.dev/docs/documentation-sites): Astro Starlight,
25
- Docusaurus and VitePress recipes
41
+ - [Documentation sites](https://draftably.dev/docs/documentation-sites): complete Astro Starlight,
42
+ Docusaurus and VitePress setups, including development serving and build output