@milkdown/preset-commonmark 7.10.4 → 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 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
- "data-language": node.attrs.language
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);