@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.mjs CHANGED
@@ -7173,8 +7173,13 @@ function* formatNode(n, o = {}) {
7173
7173
  break;
7174
7174
  }
7175
7175
  case "link": {
7176
+ const children = [...formatChildren(n, no)].join("");
7177
+ if (children === n.attributes.href && !n.attributes.title) {
7178
+ yield `<${n.attributes.href}>`;
7179
+ break;
7180
+ }
7176
7181
  yield "[";
7177
- yield* formatChildren(n, no);
7182
+ yield children;
7178
7183
  yield "]";
7179
7184
  yield "(";
7180
7185
  yield* typeof n.attributes.href === "string" ? escapeMarkdownCharacters(n.attributes.href, /[()]/g) : formatValue(n.attributes.href, no);
@@ -7194,7 +7199,7 @@ function* formatNode(n, o = {}) {
7194
7199
  if (o.parent && WRAPPING_TYPES.includes(o.parent.type)) {
7195
7200
  yield* escapeMarkdownCharacters(content, /[*_~]/g);
7196
7201
  } else {
7197
- yield* escapeMarkdownCharacters(content, /^[*>#]/);
7202
+ yield* escapeMarkdownCharacters(content, /^\*|#+\s|>/);
7198
7203
  }
7199
7204
  }
7200
7205
  break;
@@ -7435,6 +7440,22 @@ function format(v, options) {
7435
7440
  return doc.trimStart();
7436
7441
  }
7437
7442
 
7443
+ // src/schema-types/conditional.ts
7444
+ var ConditionalAttributeType = class {
7445
+ validate(value, _config, key) {
7446
+ if (typeof value === "boolean" || value === null || value === void 0 || typeof value === "object") {
7447
+ return [];
7448
+ }
7449
+ return [
7450
+ {
7451
+ id: "attribute-type-invalid",
7452
+ level: "error",
7453
+ message: `Attribute '${key}' must be type 'boolean | object' (null or undefined are also allowed)`
7454
+ }
7455
+ ];
7456
+ }
7457
+ };
7458
+
7438
7459
  // src/tags/conditional.ts
7439
7460
  function truthy(value) {
7440
7461
  return value !== false && value !== void 0 && value !== null;
@@ -7456,7 +7477,7 @@ function renderConditions(node2) {
7456
7477
  }
7457
7478
  var tagIf = {
7458
7479
  attributes: {
7459
- primary: { type: Object, render: false }
7480
+ primary: { type: ConditionalAttributeType, render: false }
7460
7481
  },
7461
7482
  transform(node2, config) {
7462
7483
  const conditions = renderConditions(node2);
@@ -7474,7 +7495,7 @@ var tagIf = {
7474
7495
  var tagElse = {
7475
7496
  selfClosing: true,
7476
7497
  attributes: {
7477
- primary: { type: Object, render: false }
7498
+ primary: { type: ConditionalAttributeType, render: false }
7478
7499
  }
7479
7500
  };
7480
7501
 
@@ -8312,7 +8333,7 @@ function block3(state, startLine, endLine, silent) {
8312
8333
  if (!state.src.startsWith(OPEN2, start))
8313
8334
  return false;
8314
8335
  const close = state.src.indexOf(CLOSE2, start);
8315
- if (!close)
8336
+ if (close === -1)
8316
8337
  return false;
8317
8338
  if (silent)
8318
8339
  return true;
@@ -8328,7 +8349,7 @@ function inline3(state, silent) {
8328
8349
  if (!state.src.startsWith(OPEN2, state.pos))
8329
8350
  return false;
8330
8351
  const close = state.src.indexOf(CLOSE2, state.pos);
8331
- if (!close)
8352
+ if (close === -1)
8332
8353
  return false;
8333
8354
  if (silent)
8334
8355
  return true;