@meowdown/core 0.81.2 → 0.81.3
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/dist/index.js +7 -4
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -17,9 +17,9 @@ import { defineEnterRule } from "@prosekit/extensions/enter-rule";
|
|
|
17
17
|
import { InputRule } from "@prosekit/pm/inputrules";
|
|
18
18
|
import { createTextBlockEnterRule } from "prosemirror-enter-rules";
|
|
19
19
|
import { NO_BREAK_SPACE } from "unicode-by-name";
|
|
20
|
+
import { fromDom } from "hast-util-from-dom";
|
|
20
21
|
import { defaultHandlers } from "hast-util-to-mdast";
|
|
21
22
|
import { defaultHandlers as defaultHandlers$1 } from "mdast-util-to-markdown";
|
|
22
|
-
import rehypeParse from "rehype-parse";
|
|
23
23
|
import rehypeRemark from "rehype-remark";
|
|
24
24
|
import remarkGfm from "remark-gfm";
|
|
25
25
|
import remarkStringify from "remark-stringify";
|
|
@@ -945,7 +945,7 @@ const textToMarkdown = (node, parent, state, info) => {
|
|
|
945
945
|
}, info);
|
|
946
946
|
};
|
|
947
947
|
function createProcessor() {
|
|
948
|
-
return unified().use(
|
|
948
|
+
return unified().use(rehypeRemark, { handlers: {
|
|
949
949
|
mark: markToHighlight,
|
|
950
950
|
li: taskAwareListItem
|
|
951
951
|
} }).use(remarkGfm).use(remarkStringify, {
|
|
@@ -967,8 +967,11 @@ const getProcessor = once(createProcessor);
|
|
|
967
967
|
/**
|
|
968
968
|
* Convert HTML into Markdown text.
|
|
969
969
|
*/
|
|
970
|
-
function htmlToMarkdown(html) {
|
|
971
|
-
|
|
970
|
+
function htmlToMarkdown(html, parser) {
|
|
971
|
+
const processor = getProcessor();
|
|
972
|
+
const domDoc = (parser ?? new window.DOMParser()).parseFromString(html, "text/html");
|
|
973
|
+
const hast = fromDom(domDoc);
|
|
974
|
+
return processor.stringify(processor.runSync(hast));
|
|
972
975
|
}
|
|
973
976
|
|
|
974
977
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meowdown/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.81.
|
|
4
|
+
"version": "0.81.3",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
"@prosekit/extensions": "^0.18.4",
|
|
36
36
|
"@prosekit/pm": "^0.1.20",
|
|
37
37
|
"@prosekit/web": "^0.9.4",
|
|
38
|
+
"hast-util-from-dom": "^5.0.1",
|
|
38
39
|
"hast-util-to-mdast": "^10.1.2",
|
|
39
40
|
"katex": "^0.19.0",
|
|
40
41
|
"lru.min": "^1.1.5",
|
|
@@ -44,7 +45,6 @@
|
|
|
44
45
|
"prosemirror-enter-rules": "^0.1.6",
|
|
45
46
|
"prosemirror-flat-list": "^0.7.3",
|
|
46
47
|
"prosemirror-highlight": "^0.16.0",
|
|
47
|
-
"rehype-parse": "^9.0.1",
|
|
48
48
|
"rehype-remark": "^10.0.1",
|
|
49
49
|
"remark-gfm": "^4.0.1",
|
|
50
50
|
"remark-stringify": "^11.0.0",
|
|
@@ -58,11 +58,11 @@
|
|
|
58
58
|
"@tsdown/css": "^0.23.1",
|
|
59
59
|
"@types/hast": "^3.0.5",
|
|
60
60
|
"@types/mdast": "^4.0.4",
|
|
61
|
-
"@vitest/browser-playwright": "^5.0.
|
|
61
|
+
"@vitest/browser-playwright": "^5.0.5",
|
|
62
62
|
"dedent": "^1.7.2",
|
|
63
63
|
"diffable-html-snapshot": "^0.3.0",
|
|
64
64
|
"tsdown": "^0.23.1",
|
|
65
|
-
"vitest": "^5.0.
|
|
65
|
+
"vitest": "^5.0.5"
|
|
66
66
|
},
|
|
67
67
|
"publishConfig": {
|
|
68
68
|
"access": "public"
|