remark-docx 0.3.3 → 0.3.4
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
|
@@ -31,7 +31,7 @@ Currently, some of the default styles may not be nice. If you have feature reque
|
|
|
31
31
|
- [x] link / linkReference
|
|
32
32
|
- [x] image / imageReference ([remark-docx/plugins/image](#image) is required)
|
|
33
33
|
- [x] footnote / footnoteReference
|
|
34
|
-
- [ ]
|
|
34
|
+
- [x] html ([remark-docx/plugins/html](#html) is required)
|
|
35
35
|
- [ ] yaml
|
|
36
36
|
- [ ] toml
|
|
37
37
|
- [ ] code / inlineCode
|
|
@@ -102,6 +102,19 @@ const processor = unified()
|
|
|
102
102
|
.use(docx, { plugins: [imagePlugin()] });
|
|
103
103
|
```
|
|
104
104
|
|
|
105
|
+
### HTML
|
|
106
|
+
|
|
107
|
+
```javascript
|
|
108
|
+
import { unified } from "unified";
|
|
109
|
+
import markdown from "remark-parse";
|
|
110
|
+
import docx from "remark-docx";
|
|
111
|
+
import { htmlPlugin } from "remark-docx/plugins/html";
|
|
112
|
+
|
|
113
|
+
const processor = unified()
|
|
114
|
+
.use(markdown)
|
|
115
|
+
.use(docx, { plugins: [htmlPlugin()] });
|
|
116
|
+
```
|
|
117
|
+
|
|
105
118
|
### LaTeX
|
|
106
119
|
|
|
107
120
|
```javascript
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var hastUtilFromHtml = require('hast-util-from-html');
|
|
4
|
+
var hastUtilToMdast = require('hast-util-to-mdast');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A plugin to render "html" node.
|
|
8
|
+
*/
|
|
9
|
+
const htmlPlugin = () => {
|
|
10
|
+
return async () => {
|
|
11
|
+
return {
|
|
12
|
+
html: ({ value }, next) => {
|
|
13
|
+
const hast = hastUtilFromHtml.fromHtml(value, { fragment: true });
|
|
14
|
+
const mdast = hastUtilToMdast.toMdast(hast, {
|
|
15
|
+
nodeHandlers: {
|
|
16
|
+
comment: () => {
|
|
17
|
+
// Ignore comment node to avoid "RangeError: Maximum call stack size exceeded"
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
return next(mdast.children);
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
exports.htmlPlugin = htmlPlugin;
|
|
28
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../src/plugins/html/index.ts"],"sourcesContent":["import type { RemarkDocxPlugin } from \"../../types\";\nimport { fromHtml } from \"hast-util-from-html\";\nimport { toMdast } from \"hast-util-to-mdast\";\nimport type { Root } from \"mdast\";\n\n/**\n * A plugin to render \"html\" node.\n */\nexport const htmlPlugin = (): RemarkDocxPlugin => {\n return async () => {\n return {\n html: ({ value }, next) => {\n const hast = fromHtml(value, { fragment: true });\n const mdast = toMdast(hast, {\n nodeHandlers: {\n comment: () => {\n // Ignore comment node to avoid \"RangeError: Maximum call stack size exceeded\"\n },\n },\n });\n return next((mdast as Root).children);\n },\n };\n };\n};\n"],"names":["fromHtml","toMdast"],"mappings":";;;;;AAKA;;AAEG;AACI,MAAM,UAAU,GAAG,MAAuB;IAC/C,OAAO,YAAW;QAChB,OAAO;YACL,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,IAAI,KAAI;AACxB,gBAAA,MAAM,IAAI,GAAGA,yBAAQ,CAAC,KAAK,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AAChD,gBAAA,MAAM,KAAK,GAAGC,uBAAO,CAAC,IAAI,EAAE;AAC1B,oBAAA,YAAY,EAAE;wBACZ,OAAO,EAAE,MAAK;;wBAEd,CAAC;AACF,qBAAA;AACF,iBAAA,CAAC;AACF,gBAAA,OAAO,IAAI,CAAE,KAAc,CAAC,QAAQ,CAAC;YACvC,CAAC;SACF;AACH,IAAA,CAAC;AACH;;;;"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { fromHtml } from 'hast-util-from-html';
|
|
2
|
+
import { toMdast } from 'hast-util-to-mdast';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A plugin to render "html" node.
|
|
6
|
+
*/
|
|
7
|
+
const htmlPlugin = () => {
|
|
8
|
+
return async () => {
|
|
9
|
+
return {
|
|
10
|
+
html: ({ value }, next) => {
|
|
11
|
+
const hast = fromHtml(value, { fragment: true });
|
|
12
|
+
const mdast = toMdast(hast, {
|
|
13
|
+
nodeHandlers: {
|
|
14
|
+
comment: () => {
|
|
15
|
+
// Ignore comment node to avoid "RangeError: Maximum call stack size exceeded"
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
return next(mdast.children);
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export { htmlPlugin };
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/plugins/html/index.ts"],"sourcesContent":["import type { RemarkDocxPlugin } from \"../../types\";\nimport { fromHtml } from \"hast-util-from-html\";\nimport { toMdast } from \"hast-util-to-mdast\";\nimport type { Root } from \"mdast\";\n\n/**\n * A plugin to render \"html\" node.\n */\nexport const htmlPlugin = (): RemarkDocxPlugin => {\n return async () => {\n return {\n html: ({ value }, next) => {\n const hast = fromHtml(value, { fragment: true });\n const mdast = toMdast(hast, {\n nodeHandlers: {\n comment: () => {\n // Ignore comment node to avoid \"RangeError: Maximum call stack size exceeded\"\n },\n },\n });\n return next((mdast as Root).children);\n },\n };\n };\n};\n"],"names":[],"mappings":";;;AAKA;;AAEG;AACI,MAAM,UAAU,GAAG,MAAuB;IAC/C,OAAO,YAAW;QAChB,OAAO;YACL,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,IAAI,KAAI;AACxB,gBAAA,MAAM,IAAI,GAAG,QAAQ,CAAC,KAAK,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AAChD,gBAAA,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,EAAE;AAC1B,oBAAA,YAAY,EAAE;wBACZ,OAAO,EAAE,MAAK;;wBAEd,CAAC;AACF,qBAAA;AACF,iBAAA,CAAC;AACF,gBAAA,OAAO,IAAI,CAAE,KAAc,CAAC,QAAQ,CAAC;YACvC,CAAC;SACF;AACH,IAAA,CAAC;AACH;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "remark-docx",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4",
|
|
4
4
|
"description": "remark plugin to compile markdown to docx (Microsoft Word, Office Open XML).",
|
|
5
5
|
"main": "lib/index.cjs",
|
|
6
6
|
"module": "lib/index.js",
|
|
@@ -35,6 +35,8 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@unified-latex/unified-latex-util-parse": "1.8.3",
|
|
37
37
|
"docx": "9.5.1",
|
|
38
|
+
"hast-util-from-html": "^2.0.3",
|
|
39
|
+
"hast-util-to-mdast": "^10.1.2",
|
|
38
40
|
"image-size": "^2.0.2",
|
|
39
41
|
"mdast-util-definitions": "^6.0.0",
|
|
40
42
|
"unist-util-visit": "^5.0.0"
|