writr 4.4.3 → 4.4.5

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
@@ -4,7 +4,6 @@
4
4
  [![tests](https://github.com/jaredwray/writr/actions/workflows/tests.yml/badge.svg)](https://github.com/jaredwray/writr/actions/workflows/tests.yml)
5
5
  [![GitHub license](https://img.shields.io/github/license/jaredwray/writr)](https://github.com/jaredwray/writr/blob/master/LICENSE)
6
6
  [![codecov](https://codecov.io/gh/jaredwray/writr/branch/master/graph/badge.svg?token=1YdMesM07X)](https://codecov.io/gh/jaredwray/writr)
7
- [![jsDelivr](https://data.jsdelivr.com/v1/package/npm/writr/badge)](https://www.jsdelivr.com/package/npm/writr)
8
7
  [![npm](https://img.shields.io/npm/dm/writr)](https://npmjs.com/package/writr)
9
8
  [![npm](https://img.shields.io/npm/v/writr)](https://npmjs.com/package/writr)
10
9
 
@@ -25,7 +24,6 @@
25
24
 
26
25
  # Table of Contents
27
26
  - [Getting Started](#getting-started)
28
- - [Running via Browser as an ESM Module](#running-via-browser-as-an-esm-module)
29
27
  - [API](#api)
30
28
  - [`new Writr(arg?: string | WritrOptions, options?: WritrOptions)`](#new-writrarg-string--writroptions-options-writroptions)
31
29
  - [`.content`](#content)
@@ -97,33 +95,6 @@ const writr = new Writr(`# Hello World ::-):\n\n This is a test.`, writrOptions)
97
95
  const html = await writr.render(options); // <h1>Hello World ::-):</h1><p>This is a test.</p>
98
96
  ```
99
97
 
100
- # Running via Browser as an ESM Module
101
-
102
- You can also run Writr via the browser. Here is an example of how to do that.
103
-
104
- ```html
105
- <!DOCTYPE html>
106
- <html lang="en">
107
- <head>
108
- <meta charset="UTF-8">
109
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
110
- <title>Writr Example</title>
111
- <script type="module">
112
- import {Writr} from 'https://cdn.jsdelivr.net/npm/writr@latest/+esm'
113
-
114
- const writr = new Writr(`# Hello World ::-):\n\n This is a test.`);
115
- writr.render().then(html => {
116
- document.body.innerHTML = html;
117
- });
118
- </script>
119
- </head>
120
- <body>
121
- </body>
122
- </html>
123
- ```
124
-
125
- This will render the markdown to HTML and display it in the body of the page.
126
-
127
98
  # API
128
99
 
129
100
  ## `new Writr(arg?: string | WritrOptions, options?: WritrOptions)`
@@ -178,19 +149,19 @@ console.log(writr.body); // '# Hello World ::-):\n\n This is a test.'
178
149
 
179
150
  ## `.options`
180
151
 
181
- Accessing the default options for this instance of Writr. Here is the default settings for `WritrOptions`.
152
+ Accessing the default options for this instance of Writr. Here is the default settings for `WritrOptions`. These are the default settings for the `WritrOptions`:
182
153
 
183
154
  ```javascript
184
155
  {
185
156
  throwErrors: false,
186
157
  renderOptions: {
187
158
  emoji: true,
188
- toc: false,
189
- slug: false,
190
- highlight: false,
159
+ toc: true,
160
+ slug: true,
161
+ highlight: true,
191
162
  gfm: true,
192
- math: false,
193
- mdx: false,
163
+ math: true,
164
+ mdx: true,
194
165
  caching: false,
195
166
  }
196
167
  }
@@ -248,7 +219,8 @@ const html = await writr.render(options); // <h1>Hello World ::-):</h1><p>This i
248
219
 
249
220
  ## `.engine`
250
221
 
251
- Accessing the underlying engine for this instance of Writr. This is a `Processor<Root, Root, Root, undefined, undefined>` fro the unified `.use()` function. You can use this to add additional plugins to the engine.
222
+ Accessing the underlying engine for this instance of Writr. This is a `Processor<Root, Root, Root, undefined, undefined>` fro the unified `.use()` function. You can use this to add additional plugins to the engine. You can learn more about the unified engine [here](https://unifiedjs.com/) and a getting started guide [here](https://unifiedjs.com/learn/guide/using-unified/).
223
+
252
224
 
253
225
  ## `.render(options?: RenderOptions): Promise<string>`
254
226
 
package/dist/writr.d.ts CHANGED
@@ -9,6 +9,7 @@ import { CacheableMemory } from 'cacheable';
9
9
  declare class WritrCache {
10
10
  private readonly _store;
11
11
  private readonly _hashStore;
12
+ private readonly _hash;
12
13
  get store(): CacheableMemory;
13
14
  get hashStore(): CacheableMemory;
14
15
  get(markdown: string, options?: RenderOptions): string | undefined;
package/dist/writr.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // src/writr.ts
2
- import fs from "node:fs";
3
- import { dirname } from "node:path";
2
+ import fs from "fs";
3
+ import { dirname } from "path";
4
4
  import { unified } from "unified";
5
5
  import remarkParse from "remark-parse";
6
6
  import remarkRehype from "remark-rehype";
@@ -18,10 +18,11 @@ import * as yaml from "js-yaml";
18
18
  import { Hookified } from "hookified";
19
19
 
20
20
  // src/writr-cache.ts
21
- import { CacheableMemory } from "cacheable";
21
+ import { CacheableMemory, Cacheable } from "cacheable";
22
22
  var WritrCache = class {
23
23
  _store = new CacheableMemory();
24
24
  _hashStore = new CacheableMemory();
25
+ _hash = new Cacheable();
25
26
  get store() {
26
27
  return this._store;
27
28
  }
@@ -47,7 +48,7 @@ var WritrCache = class {
47
48
  if (result) {
48
49
  return result;
49
50
  }
50
- result = this._hashStore.hash(content);
51
+ result = this._hash.hash(content);
51
52
  this._hashStore.set(key, result);
52
53
  return result;
53
54
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "writr",
3
- "version": "4.4.3",
3
+ "version": "4.4.5",
4
4
  "description": "Markdown Rendering Simplified",
5
5
  "type": "module",
6
6
  "main": "./dist/writr.js",
@@ -53,9 +53,9 @@
53
53
  "website:serve": "rimraf ./site/README.md ./site/dist && npx docula serve -s ./site -o ./site/dist"
54
54
  },
55
55
  "dependencies": {
56
- "cacheable": "^1.8.10",
57
- "hookified": "^1.8.2",
58
- "html-react-parser": "^5.2.3",
56
+ "cacheable": "^1.10.0",
57
+ "hookified": "^1.9.1",
58
+ "html-react-parser": "^5.2.5",
59
59
  "js-yaml": "^4.1.0",
60
60
  "react": "^19.1.0",
61
61
  "rehype-highlight": "^7.0.2",
@@ -73,17 +73,17 @@
73
73
  },
74
74
  "devDependencies": {
75
75
  "@types/js-yaml": "^4.0.9",
76
- "@types/node": "^22.15.3",
77
- "@types/react": "^19.1.2",
78
- "@vitest/coverage-v8": "^3.1.2",
79
- "docula": "^0.11.1",
76
+ "@types/node": "^24.0.4",
77
+ "@types/react": "^19.1.8",
78
+ "@vitest/coverage-v8": "^3.2.4",
79
+ "docula": "^0.13.0",
80
80
  "rimraf": "^6.0.1",
81
81
  "ts-node": "^10.9.2",
82
- "tsup": "^8.4.0",
82
+ "tsup": "^8.5.0",
83
83
  "typescript": "^5.8.3",
84
- "vitest": "^3.1.2",
85
- "webpack": "^5.99.7",
86
- "xo": "^0.60.0"
84
+ "vitest": "^3.2.4",
85
+ "webpack": "^5.99.9",
86
+ "xo": "^1.1.1"
87
87
  },
88
88
  "xo": {
89
89
  "ignores": [