@milkdown/preset-commonmark 7.10.5 → 7.11.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/lib/index.js +4 -2
- package/lib/index.js.map +1 -1
- package/lib/node/code-block.d.ts.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -7
- package/src/node/code-block.ts +9 -3
package/lib/index.js
CHANGED
|
@@ -811,11 +811,13 @@ const codeBlockSchema = $nodeSchema("code_block", (ctx) => {
|
|
|
811
811
|
],
|
|
812
812
|
toDOM: (node) => {
|
|
813
813
|
const attr = ctx.get(codeBlockAttr.key)(node);
|
|
814
|
+
const language = node.attrs.language;
|
|
815
|
+
const languageAttrs = language && language.length > 0 ? { "data-language": language } : void 0;
|
|
814
816
|
return [
|
|
815
817
|
"pre",
|
|
816
818
|
{
|
|
817
819
|
...attr.pre,
|
|
818
|
-
|
|
820
|
+
...languageAttrs
|
|
819
821
|
},
|
|
820
822
|
["code", attr.code, 0]
|
|
821
823
|
];
|
|
@@ -823,7 +825,7 @@ const codeBlockSchema = $nodeSchema("code_block", (ctx) => {
|
|
|
823
825
|
parseMarkdown: {
|
|
824
826
|
match: ({ type }) => type === "code",
|
|
825
827
|
runner: (state, node, type) => {
|
|
826
|
-
const language = node.lang;
|
|
828
|
+
const language = node.lang ?? "";
|
|
827
829
|
const value = node.value;
|
|
828
830
|
state.openNode(type, { language });
|
|
829
831
|
if (value) state.addText(value);
|