writr 6.0.1 → 6.1.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 +8 -0
- package/dist/writr.d.ts +2 -0
- package/dist/writr.js +40 -4
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
* Github Flavor Markdown (remark-gfm).
|
|
23
23
|
* Emoji Support (remark-emoji).
|
|
24
24
|
* MDX Support (remark-mdx).
|
|
25
|
+
* Raw HTML Passthrough (rehype-raw).
|
|
25
26
|
* Built in Hooks for adding code to render pipeline.
|
|
26
27
|
* AI-powered metadata generation, SEO, and translation via the [Vercel AI SDK](https://sdk.vercel.ai).
|
|
27
28
|
|
|
@@ -118,6 +119,7 @@ const writrOptions = {
|
|
|
118
119
|
gfm: true,
|
|
119
120
|
math: true,
|
|
120
121
|
mdx: true,
|
|
122
|
+
rawHtml: false,
|
|
121
123
|
caching: true,
|
|
122
124
|
}
|
|
123
125
|
};
|
|
@@ -142,6 +144,7 @@ const writrOptions = {
|
|
|
142
144
|
gfm: true,
|
|
143
145
|
math: true,
|
|
144
146
|
mdx: true,
|
|
147
|
+
rawHtml: false,
|
|
145
148
|
caching: true,
|
|
146
149
|
}
|
|
147
150
|
};
|
|
@@ -190,11 +193,16 @@ Accessing the default options for this instance of Writr. Here is the default se
|
|
|
190
193
|
gfm: true,
|
|
191
194
|
math: true,
|
|
192
195
|
mdx: false,
|
|
196
|
+
rawHtml: false,
|
|
193
197
|
caching: true,
|
|
194
198
|
}
|
|
195
199
|
}
|
|
196
200
|
```
|
|
197
201
|
|
|
202
|
+
By default, raw HTML in markdown (such as `<iframe>`, `<video>`, or `<div>` tags) is stripped during rendering. Set `rawHtml: true` to preserve raw HTML elements and their attributes in the rendered output. This is useful for embedding videos, widgets, or custom HTML in your markdown content.
|
|
203
|
+
|
|
204
|
+
**Note:** Setting `mdx: true` also enables raw HTML passthrough as part of the MDX specification. The `rawHtml` option is for enabling raw HTML in standard markdown without using MDX.
|
|
205
|
+
|
|
198
206
|
## `.frontmatter`
|
|
199
207
|
|
|
200
208
|
Accessing the frontmatter for this instance of Writr. This is a `Record<string, any>` and can be set via the `.content` property.
|
package/dist/writr.d.ts
CHANGED
|
@@ -26,6 +26,7 @@ type WritrOptions = {
|
|
|
26
26
|
* @property {boolean} [gfm] - Github flavor markdown (default: true)
|
|
27
27
|
* @property {boolean} [math] - Math support (default: true)
|
|
28
28
|
* @property {boolean} [mdx] - MDX support (default: false)
|
|
29
|
+
* @property {boolean} [rawHtml] - Raw HTML passthrough (default: false)
|
|
29
30
|
* @property {boolean} [caching] - Caching (default: true)
|
|
30
31
|
*/
|
|
31
32
|
type RenderOptions = {
|
|
@@ -36,6 +37,7 @@ type RenderOptions = {
|
|
|
36
37
|
gfm?: boolean;
|
|
37
38
|
math?: boolean;
|
|
38
39
|
mdx?: boolean;
|
|
40
|
+
rawHtml?: boolean;
|
|
39
41
|
caching?: boolean;
|
|
40
42
|
};
|
|
41
43
|
/**
|
package/dist/writr.js
CHANGED
|
@@ -6,6 +6,7 @@ import parse from "html-react-parser";
|
|
|
6
6
|
import * as yaml from "js-yaml";
|
|
7
7
|
import rehypeHighlight from "rehype-highlight";
|
|
8
8
|
import rehypeKatex from "rehype-katex";
|
|
9
|
+
import rehypeRaw from "rehype-raw";
|
|
9
10
|
import rehypeSlug from "rehype-slug";
|
|
10
11
|
import rehypeStringify from "rehype-stringify";
|
|
11
12
|
import remarkEmoji from "remark-emoji";
|
|
@@ -461,6 +462,7 @@ var Writr = class extends Hookified {
|
|
|
461
462
|
gfm: true,
|
|
462
463
|
math: true,
|
|
463
464
|
mdx: false,
|
|
465
|
+
rawHtml: false,
|
|
464
466
|
caching: true
|
|
465
467
|
}
|
|
466
468
|
};
|
|
@@ -942,7 +944,23 @@ ${yamlString}---
|
|
|
942
944
|
if (options.emoji) {
|
|
943
945
|
processor.use(remarkEmoji);
|
|
944
946
|
}
|
|
945
|
-
|
|
947
|
+
if (options.mdx) {
|
|
948
|
+
processor.use(remarkMDX);
|
|
949
|
+
}
|
|
950
|
+
const rehypeOptions = {};
|
|
951
|
+
if (options.rawHtml) {
|
|
952
|
+
rehypeOptions.allowDangerousHtml = true;
|
|
953
|
+
}
|
|
954
|
+
if (options.mdx) {
|
|
955
|
+
rehypeOptions.handlers = {
|
|
956
|
+
mdxJsxFlowElement: mdxJsxHandler,
|
|
957
|
+
mdxJsxTextElement: mdxJsxHandler
|
|
958
|
+
};
|
|
959
|
+
}
|
|
960
|
+
processor.use(remarkRehype, rehypeOptions);
|
|
961
|
+
if (options.rawHtml) {
|
|
962
|
+
processor.use(rehypeRaw);
|
|
963
|
+
}
|
|
946
964
|
if (options.slug) {
|
|
947
965
|
processor.use(rehypeSlug);
|
|
948
966
|
}
|
|
@@ -952,9 +970,6 @@ ${yamlString}---
|
|
|
952
970
|
if (options.math) {
|
|
953
971
|
processor.use(remarkMath).use(rehypeKatex);
|
|
954
972
|
}
|
|
955
|
-
if (options.mdx) {
|
|
956
|
-
processor.use(remarkMDX);
|
|
957
|
-
}
|
|
958
973
|
processor.use(rehypeStringify);
|
|
959
974
|
return processor;
|
|
960
975
|
}
|
|
@@ -980,12 +995,33 @@ ${yamlString}---
|
|
|
980
995
|
if (options.mdx !== void 0) {
|
|
981
996
|
current.mdx = options.mdx;
|
|
982
997
|
}
|
|
998
|
+
if (options.rawHtml !== void 0) {
|
|
999
|
+
current.rawHtml = options.rawHtml;
|
|
1000
|
+
}
|
|
983
1001
|
if (options.caching !== void 0) {
|
|
984
1002
|
current.caching = options.caching;
|
|
985
1003
|
}
|
|
986
1004
|
return current;
|
|
987
1005
|
}
|
|
988
1006
|
};
|
|
1007
|
+
function mdxJsxHandler(state, node) {
|
|
1008
|
+
const properties = {};
|
|
1009
|
+
for (const attr of node.attributes) {
|
|
1010
|
+
if (attr.type === "mdxJsxAttribute") {
|
|
1011
|
+
if (attr.value === null) {
|
|
1012
|
+
properties[attr.name] = true;
|
|
1013
|
+
} else if (typeof attr.value === "string") {
|
|
1014
|
+
properties[attr.name] = attr.value;
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
return {
|
|
1019
|
+
type: "element",
|
|
1020
|
+
tagName: node.name ?? "div",
|
|
1021
|
+
properties,
|
|
1022
|
+
children: state.all(node)
|
|
1023
|
+
};
|
|
1024
|
+
}
|
|
989
1025
|
export {
|
|
990
1026
|
Writr,
|
|
991
1027
|
WritrAI,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "writr",
|
|
3
|
-
"version": "6.0
|
|
3
|
+
"version": "6.1.0",
|
|
4
4
|
"description": "Markdown Rendering Simplified",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/writr.js",
|
|
@@ -58,6 +58,7 @@
|
|
|
58
58
|
"react": "^19.2.4",
|
|
59
59
|
"rehype-highlight": "^7.0.2",
|
|
60
60
|
"rehype-katex": "^7.0.1",
|
|
61
|
+
"rehype-raw": "^7.0.0",
|
|
61
62
|
"rehype-slug": "^6.0.0",
|
|
62
63
|
"rehype-stringify": "^10.0.1",
|
|
63
64
|
"remark-emoji": "^5.0.2",
|