@markdoc/markdoc 0.5.1 → 0.5.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 CHANGED
@@ -7198,8 +7198,13 @@ function* formatNode(n, o = {}) {
7198
7198
  break;
7199
7199
  }
7200
7200
  case "link": {
7201
+ const children = [...formatChildren(n, no)].join("");
7202
+ if (children === n.attributes.href && !n.attributes.title) {
7203
+ yield `<${n.attributes.href}>`;
7204
+ break;
7205
+ }
7201
7206
  yield "[";
7202
- yield* formatChildren(n, no);
7207
+ yield children;
7203
7208
  yield "]";
7204
7209
  yield "(";
7205
7210
  yield* typeof n.attributes.href === "string" ? escapeMarkdownCharacters(n.attributes.href, /[()]/g) : formatValue(n.attributes.href, no);
@@ -7219,7 +7224,7 @@ function* formatNode(n, o = {}) {
7219
7224
  if (o.parent && WRAPPING_TYPES.includes(o.parent.type)) {
7220
7225
  yield* escapeMarkdownCharacters(content, /[*_~]/g);
7221
7226
  } else {
7222
- yield* escapeMarkdownCharacters(content, /^[*>#]/);
7227
+ yield* escapeMarkdownCharacters(content, /^\*|#+\s|>/);
7223
7228
  }
7224
7229
  }
7225
7230
  break;
@@ -7460,6 +7465,22 @@ function format(v, options) {
7460
7465
  return doc.trimStart();
7461
7466
  }
7462
7467
 
7468
+ // src/schema-types/conditional.ts
7469
+ var ConditionalAttributeType = class {
7470
+ validate(value, _config, key) {
7471
+ if (typeof value === "boolean" || value === null || value === void 0 || typeof value === "object") {
7472
+ return [];
7473
+ }
7474
+ return [
7475
+ {
7476
+ id: "attribute-type-invalid",
7477
+ level: "error",
7478
+ message: `Attribute '${key}' must be type 'boolean | object' (null or undefined are also allowed)`
7479
+ }
7480
+ ];
7481
+ }
7482
+ };
7483
+
7463
7484
  // src/tags/conditional.ts
7464
7485
  function truthy(value) {
7465
7486
  return value !== false && value !== void 0 && value !== null;
@@ -7481,7 +7502,7 @@ function renderConditions(node2) {
7481
7502
  }
7482
7503
  var tagIf = {
7483
7504
  attributes: {
7484
- primary: { type: Object, render: false }
7505
+ primary: { type: ConditionalAttributeType, render: false }
7485
7506
  },
7486
7507
  transform(node2, config) {
7487
7508
  const conditions = renderConditions(node2);
@@ -7499,7 +7520,7 @@ var tagIf = {
7499
7520
  var tagElse = {
7500
7521
  selfClosing: true,
7501
7522
  attributes: {
7502
- primary: { type: Object, render: false }
7523
+ primary: { type: ConditionalAttributeType, render: false }
7503
7524
  }
7504
7525
  };
7505
7526
 
@@ -8337,7 +8358,7 @@ function block3(state, startLine, endLine, silent) {
8337
8358
  if (!state.src.startsWith(OPEN2, start))
8338
8359
  return false;
8339
8360
  const close = state.src.indexOf(CLOSE2, start);
8340
- if (!close)
8361
+ if (close === -1)
8341
8362
  return false;
8342
8363
  if (silent)
8343
8364
  return true;
@@ -8353,7 +8374,7 @@ function inline3(state, silent) {
8353
8374
  if (!state.src.startsWith(OPEN2, state.pos))
8354
8375
  return false;
8355
8376
  const close = state.src.indexOf(CLOSE2, state.pos);
8356
- if (!close)
8377
+ if (close === -1)
8357
8378
  return false;
8358
8379
  if (silent)
8359
8380
  return true;