flatmarkdown-ast2html 0.8.0 → 0.9.0

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
@@ -15,7 +15,7 @@ The WebAssembly code is inside that file, so a page needs no second file.
15
15
  Load the file with a `<script>` tag.
16
16
 
17
17
  ```html
18
- <script src="https://unpkg.com/flatmarkdown-ast2html@0.8.0"></script>
18
+ <script src="https://unpkg.com/flatmarkdown-ast2html@0.9.0"></script>
19
19
  <script>
20
20
  const html = FmAst2Html.renderToHtml(
21
21
  '{"type":"paragraph","children":[{"type":"text","value":"Hello"}]}',
@@ -26,11 +26,24 @@ Load the file with a `<script>` tag.
26
26
 
27
27
  The script adds one global object, `FmAst2Html`.
28
28
 
29
- ### `FmAst2Html.renderToHtml(ast)`
29
+ ### `FmAst2Html.renderToHtml(ast, options)`
30
30
 
31
31
  `ast` is the AST as a JSON string, or as an object.
32
32
  The function returns the HTML as a string. It does not return a promise.
33
33
 
34
+ `options` can be left out. It is an object with these settings. A setting that is left out has its default value.
35
+
36
+ - `wikilinkHref`: the template of the `href` of a wikilink. The default is `{}`.
37
+ - `hashtagHref`: the template of the `href` of a hashtag. The default is `{}`.
38
+ - `wikilinkFragmentPattern`: the pattern of the fragment of a wikilink. The default is empty.
39
+
40
+ They are the settings of `HtmlOptions` of the crate, and give the same HTML.
41
+ See "Where links lead" in the [README of the crate](https://github.com/petajournal/flatmarkdown/tree/main/flatmarkdown-ast2html#readme).
42
+
43
+ ```js
44
+ FmAst2Html.renderToHtml(ast, { wikilinkHref: '/pages/{}', hashtagHref: '/pages/tags/{}' });
45
+ ```
46
+
34
47
  The function throws when `ast` cannot be read as an AST.
35
48
  For example, it throws for a string that is not JSON.
36
49
  A node of an unknown `type` is not an error. Only its children are rendered.
@@ -42,10 +55,10 @@ Do not render the AST of Markdown that you do not trust.
42
55
 
43
56
  Versions 0.1.x were written in TypeScript. From 0.6.0, the package is built from Rust.
44
57
 
45
- - The second argument of `renderToHtml`, the options for wikilinks and hashtags, is removed.
58
+ - The second argument of `renderToHtml`, the options for wikilinks and hashtags, was removed in 0.6.0. From 0.9.0, it is back with other settings.
46
59
  - The ES module build, the CommonJS build, and the TypeScript types are removed.
47
60
  - The types of the AST are not exported. They are in the npm package [flatmarkdown-ast](https://www.npmjs.com/package/flatmarkdown-ast).
48
- - The file is about 240KB. It was about 4KB.
61
+ - The file is about 340KB. It was about 4KB.
49
62
 
50
63
  ## Build
51
64