@markdoc/markdoc 0.2.0 → 0.2.2

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 CHANGED
@@ -6678,7 +6678,7 @@ var Tag = class {
6678
6678
  }
6679
6679
  };
6680
6680
  Tag.isTag = (tag) => {
6681
- return "$$mdtype" in tag && tag.$$mdtype === "Tag";
6681
+ return !!(tag?.$$mdtype === "Tag");
6682
6682
  };
6683
6683
 
6684
6684
  // src/schema-types/class.ts
@@ -6986,6 +6986,7 @@ var NL = "\n";
6986
6986
  var OL = "1. ";
6987
6987
  var UL = "- ";
6988
6988
  var MAX_TAG_OPENING_WIDTH = 80;
6989
+ var WRAPPING_TYPES = ["strong", "em", "s"];
6989
6990
  var max = (a, b) => Math.max(a, b);
6990
6991
  var increment = (o, n = 2) => ({
6991
6992
  ...o,
@@ -7007,7 +7008,7 @@ function formatScalar(v) {
7007
7008
  return format(v);
7008
7009
  }
7009
7010
  if (v === null) {
7010
- return "";
7011
+ return "null";
7011
7012
  }
7012
7013
  if (Array.isArray(v)) {
7013
7014
  return "[" + v.map(formatScalar).join(SEP) + "]";
@@ -7135,18 +7136,22 @@ function* formatNode(n, o = {}) {
7135
7136
  }
7136
7137
  case "text": {
7137
7138
  const { content } = n.attributes;
7138
- if (ast_default.isAst(content))
7139
+ if (ast_default.isAst(content)) {
7139
7140
  yield OPEN + SPACE;
7140
- yield* typeof content === "string" ? escapeMarkdownCharacters(content, /[_*~]/g) : formatValue(content, no);
7141
- if (ast_default.isAst(content))
7141
+ yield* formatValue(content, no);
7142
7142
  yield SPACE + CLOSE;
7143
+ } else {
7144
+ if (o.parent && WRAPPING_TYPES.includes(o.parent.type)) {
7145
+ yield* escapeMarkdownCharacters(content, /[*_~]/g);
7146
+ } else {
7147
+ yield* escapeMarkdownCharacters(content, /^[*>#]/);
7148
+ }
7149
+ }
7143
7150
  break;
7144
7151
  }
7145
7152
  case "blockquote": {
7146
- yield NL;
7147
- yield indent;
7148
- yield "> ";
7149
- yield* trimStart(formatChildren(n, no));
7153
+ const prefix = ">" + SPACE;
7154
+ yield n.children.map((child) => format(child, no).trimStart()).map((d) => NL + indent + prefix + d).join(indent + prefix);
7150
7155
  break;
7151
7156
  }
7152
7157
  case "hr": {