@markdoc/markdoc 0.3.0 → 0.3.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.d.ts CHANGED
@@ -41,6 +41,7 @@ export default class Markdoc {
41
41
  functions: Record<string, import("./src/types").ConfigFunction>;
42
42
  partials: Record<string, any>;
43
43
  validation?: {
44
+ parents?: Node[] | undefined;
44
45
  validateFunctions?: boolean | undefined;
45
46
  } | undefined;
46
47
  }>>, string>;
@@ -51,6 +52,7 @@ export default class Markdoc {
51
52
  functions: Record<string, import("./src/types").ConfigFunction>;
52
53
  partials: Record<string, any>;
53
54
  validation?: {
55
+ parents?: Node[] | undefined;
54
56
  validateFunctions?: boolean | undefined;
55
57
  } | undefined;
56
58
  }>>, string>;
@@ -61,6 +63,7 @@ export default class Markdoc {
61
63
  functions: Record<string, import("./src/types").ConfigFunction>;
62
64
  partials: Record<string, any>;
63
65
  validation?: {
66
+ parents?: Node[] | undefined;
64
67
  validateFunctions?: boolean | undefined;
65
68
  } | undefined;
66
69
  }>>, string>;
@@ -71,6 +74,7 @@ export default class Markdoc {
71
74
  functions: Record<string, import("./src/types").ConfigFunction>;
72
75
  partials: Record<string, any>;
73
76
  validation?: {
77
+ parents?: Node[] | undefined;
74
78
  validateFunctions?: boolean | undefined;
75
79
  } | undefined;
76
80
  }>>, string>;
@@ -81,6 +85,7 @@ export default class Markdoc {
81
85
  functions: Record<string, import("./src/types").ConfigFunction>;
82
86
  partials: Record<string, any>;
83
87
  validation?: {
88
+ parents?: Node[] | undefined;
84
89
  validateFunctions?: boolean | undefined;
85
90
  } | undefined;
86
91
  }>>, string>;
@@ -113,6 +118,7 @@ export default class Markdoc {
113
118
  functions: Record<string, import("./src/types").ConfigFunction>;
114
119
  partials: Record<string, any>;
115
120
  validation?: {
121
+ parents?: Node[] | undefined;
116
122
  validateFunctions?: boolean | undefined;
117
123
  } | undefined;
118
124
  }>>): any;
@@ -138,6 +144,7 @@ export default class Markdoc {
138
144
  functions: Record<string, import("./src/types").ConfigFunction>;
139
145
  partials: Record<string, any>;
140
146
  validation?: {
147
+ parents?: Node[] | undefined;
141
148
  validateFunctions?: boolean | undefined;
142
149
  } | undefined;
143
150
  }>>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,WAAW,CAAC;AAC5B,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,SAAS,MAAM,iBAAiB,CAAC;AAExC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,SAAS,MAAM,iBAAiB,CAAC;AACxC,OAAO,GAAG,MAAM,WAAW,CAAC;AAC5B,OAAO,IAAI,MAAM,YAAY,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,SAAS,MAAM,iBAAiB,CAAC;AACxC,OAAO,WAAW,EAAE,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,UAAU,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAa,MAAM,aAAa,CAAC;AACnD,OAAO,SAAS,MAAM,iBAAiB,CAAC;AAExC,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,KAAK,KAAK,MAAM,uBAAuB,CAAC;AAC/C,OAAO,KAAK,EAAE,MAAM,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE7E,cAAc,aAAa,CAAC;AAsB5B,wBAAgB,KAAK,CACnB,OAAO,EAAE,MAAM,GAAG,KAAK,EAAE,EACzB,IAAI,CAAC,EAAE,MAAM,GAAG,UAAU,GACzB,IAAI,CAGN;AAED,wBAAgB,OAAO,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EAC/C,OAAO,EAAE,IAAI,EACb,MAAM,EAAE,CAAC,GACR,IAA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AS,EACT,gBAAgB,EAChB,UAAU,EACV,SAAS,EACT,GAAG,EACH,GAAG,EACH,SAAS,EACT,SAAS,EACT,WAAW,EACX,SAAS,EACT,MAAM,EACN,MAAM,GACP,CAAC;AAEF,MAAM,CAAC,OAAO,OAAO,OAAO;IAC1B,MAAM,CAAC,KAAK,eAAS;IACrB,MAAM,CAAC,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAAQ;IACnB,MAAM,CAAC,SAAS;;;;;;;MAAa;IAC7B,MAAM,CAAC,gBAAgB,oEAAoB;IAC3C,MAAM,CAAC,SAAS;;;;MAAa;IAC7B,MAAM,CAAC,UAAU,oDAAc;IAC/B,MAAM,CAAC,GAAG;;;;;;;;;;;;;;;;;;;;MAAO;IACjB,MAAM,CAAC,GAAG,aAAO;IACjB,MAAM,CAAC,SAAS,mBAAa;IAC7B,MAAM,CAAC,SAAS,mBAAa;IAC7B,MAAM,CAAC,WAAW,oCAAe;IACjC,MAAM,CAAC,SAAS,mBAAa;IAC7B,MAAM,CAAC,KAAK,eAAS;IACrB,MAAM,CAAC,SAAS,mBAAa;IAC7B,MAAM,CAAC,QAAQ,kBAAY;IAC3B,MAAM,CAAC,aAAa,uBAAiB;IACrC,MAAM,CAAC,MAAM,gBAAU;IACvB,MAAM,CAAC,MAAM,gBAAU;IAEvB,MAAM;;;;;;;;;;QAAC;gBACK,MAAM,EAAE,MAAM;IAI1B,KAAK,eAAS;IACd,OAAO,YAAa,WAAW,cAAc,CAAC,CAAC,CAAC,CAAC,YACjB;IAChC,SAAS,YAAa,WAAW,gBAAgB,CAAC,CAAC,CAAC,CAAC,0BACnB;IAClC,QAAQ,YAAa,WAAW,eAAe,CAAC,CAAC,CAAC,CAAC,qBAClB;CAClC"}
package/dist/index.js CHANGED
@@ -6683,14 +6683,14 @@ Tag.isTag = (tag) => {
6683
6683
 
6684
6684
  // src/schema-types/class.ts
6685
6685
  var Class = class {
6686
- validate(value) {
6686
+ validate(value, _config, key) {
6687
6687
  if (typeof value === "string" || typeof value === "object")
6688
6688
  return [];
6689
6689
  return [
6690
6690
  {
6691
6691
  id: "attribute-type-invalid",
6692
6692
  level: "error",
6693
- message: `Attribute 'class' must be type 'string | object'`
6693
+ message: `Attribute '${key}' must be type 'string | object'`
6694
6694
  }
6695
6695
  ];
6696
6696
  }
@@ -6894,6 +6894,8 @@ var transformer_default = {
6894
6894
  }
6895
6895
  if (schema.slots) {
6896
6896
  for (const [key, slot2] of Object.entries(schema.slots)) {
6897
+ if (slot2.render === false)
6898
+ continue;
6897
6899
  const name = typeof slot2.render === "string" ? slot2.render : key;
6898
6900
  if (node2.slots[key])
6899
6901
  output[name] = this.node(node2.slots[key], config);
@@ -7012,6 +7014,9 @@ function* formatTableRow(items) {
7012
7014
  yield `| ${items.join(" | ")} |`;
7013
7015
  }
7014
7016
  function formatScalar(v) {
7017
+ if (v === void 0) {
7018
+ return void 0;
7019
+ }
7015
7020
  if (ast_default.isAst(v)) {
7016
7021
  return format(v);
7017
7022
  }
@@ -7027,13 +7032,16 @@ function formatScalar(v) {
7027
7032
  return JSON.stringify(v);
7028
7033
  }
7029
7034
  function formatAnnotationValue(a) {
7035
+ const formattedValue = formatScalar(a.value);
7036
+ if (formattedValue === void 0)
7037
+ return void 0;
7030
7038
  if (a.name === "primary")
7031
- return formatScalar(a.value);
7039
+ return formattedValue;
7032
7040
  if (a.name === "id" && typeof a.value === "string" && isIdentifier(a.value))
7033
7041
  return "#" + a.value;
7034
7042
  if (a.type === "class" && isIdentifier(a.name))
7035
7043
  return "." + a.name;
7036
- return `${a.name}=${formatScalar(a.value)}`;
7044
+ return `${a.name}=${formattedValue}`;
7037
7045
  }
7038
7046
  function* formatAttributes(n) {
7039
7047
  for (const [key, value] of Object.entries(n.attributes)) {
@@ -7194,7 +7202,8 @@ function* formatNode(n, o = {}) {
7194
7202
  yield indent;
7195
7203
  }
7196
7204
  const open = OPEN + SPACE;
7197
- const tag = [open + n.tag, ...formatAttributes(n)];
7205
+ const attributes = [...formatAttributes(n)].filter((v) => v !== void 0);
7206
+ const tag = [open + n.tag, ...attributes];
7198
7207
  const inlineTag = tag.join(SPACE);
7199
7208
  const isLongTagOpening = inlineTag.length + open.length * 2 > (o.maxTagOpeningWidth || MAX_TAG_OPENING_WIDTH);
7200
7209
  yield (!n.inline && isLongTagOpening ? tag.join(NL + SPACE.repeat(open.length) + indent) : inlineTag) + SPACE + (n.children.length ? "" : "/") + CLOSE;
@@ -7211,9 +7220,13 @@ function* formatNode(n, o = {}) {
7211
7220
  break;
7212
7221
  }
7213
7222
  case "list": {
7223
+ const isLoose = n.children.some((n2) => n2.children.some((c) => c.type === "paragraph"));
7214
7224
  for (let i = 0; i < n.children.length; i++) {
7215
7225
  const prefix = n.attributes.ordered ? `${i === 0 ? n.attributes.start ?? "1" : "1"}${n.attributes.marker ?? OL}` : n.attributes.marker ?? UL;
7216
- const d = format(n.children[i], increment(no, prefix.length + 1)).trim();
7226
+ let d = format(n.children[i], increment(no, prefix.length + 1));
7227
+ if (!isLoose || i === n.children.length - 1) {
7228
+ d = d.trim();
7229
+ }
7217
7230
  yield NL + indent + prefix + " " + d;
7218
7231
  }
7219
7232
  yield NL;
@@ -7506,9 +7519,15 @@ function annotate(node2, attributes) {
7506
7519
  for (const attribute of attributes) {
7507
7520
  node2.annotations.push(attribute);
7508
7521
  const { name, value, type } = attribute;
7509
- if (type === "attribute")
7522
+ if (type === "attribute") {
7523
+ if (node2.attributes[name] !== void 0)
7524
+ node2.errors.push({
7525
+ id: "duplicate-attribute",
7526
+ level: "warning",
7527
+ message: `Attribute '${name}' already set`
7528
+ });
7510
7529
  node2.attributes[name] = value;
7511
- else if (type === "class")
7530
+ } else if (type === "class")
7512
7531
  if (node2.attributes.class)
7513
7532
  node2.attributes.class[name] = value;
7514
7533
  else
@@ -7633,7 +7652,8 @@ function handleToken(token, nodes, file, handleSlots, inlineParent) {
7633
7652
  nodes.push(node2);
7634
7653
  if (!Array.isArray(token.children))
7635
7654
  return;
7636
- inlineParent = parent;
7655
+ if (node2.type === "inline")
7656
+ inlineParent = parent;
7637
7657
  nodes.push(node2);
7638
7658
  const isLeafNode = typeName === "image";
7639
7659
  if (!isLeafNode) {
@@ -7805,16 +7825,18 @@ var td = {
7805
7825
  "hr"
7806
7826
  ],
7807
7827
  attributes: {
7808
- colspan: { type: Number },
7809
- rowspan: { type: Number },
7810
- align: { type: String }
7828
+ align: { type: String },
7829
+ colspan: { type: Number, render: "colSpan" },
7830
+ rowspan: { type: Number, render: "rowSpan" }
7811
7831
  }
7812
7832
  };
7813
7833
  var th = {
7814
7834
  render: "th",
7815
7835
  attributes: {
7816
7836
  width: { type: Number },
7817
- align: { type: String }
7837
+ align: { type: String },
7838
+ colspan: { type: Number, render: "colSpan" },
7839
+ rowspan: { type: Number, render: "rowSpan" }
7818
7840
  }
7819
7841
  };
7820
7842
  var tr = {
@@ -7935,7 +7957,7 @@ function render(node2) {
7935
7957
  return render(children);
7936
7958
  let output = `<${name}`;
7937
7959
  for (const [k, v] of Object.entries(attributes ?? {}))
7938
- output += ` ${k}="${escapeHtml(String(v))}"`;
7960
+ output += ` ${k.toLowerCase()}="${escapeHtml(String(v))}"`;
7939
7961
  output += ">";
7940
7962
  if (voidElements.has(name))
7941
7963
  return output;
@@ -8135,7 +8157,7 @@ function block(state, startLine, endLine, silent) {
8135
8157
  return false;
8136
8158
  const contentStart = start + OPEN.length;
8137
8159
  const content = state.src.slice(contentStart, tagEnd).trim();
8138
- const lines = content.split("\n").length;
8160
+ const lines = state.src.slice(start, tagEnd + CLOSE.length).split("\n").length;
8139
8161
  if (content[0] === "$")
8140
8162
  return false;
8141
8163
  if (silent)
@@ -8288,7 +8310,7 @@ var TypeMappings = {
8288
8310
  Object,
8289
8311
  Boolean
8290
8312
  };
8291
- function validateType(type, value, config) {
8313
+ function validateType(type, value, config, key) {
8292
8314
  if (!type)
8293
8315
  return true;
8294
8316
  if (ast_default.isFunction(value) && config.validation?.validateFunctions) {
@@ -8298,13 +8320,13 @@ function validateType(type, value, config) {
8298
8320
  if (ast_default.isAst(value))
8299
8321
  return true;
8300
8322
  if (Array.isArray(type))
8301
- return type.some((t) => validateType(t, value, config));
8323
+ return type.some((t) => validateType(t, value, config, key));
8302
8324
  if (typeof type === "string")
8303
8325
  type = TypeMappings[type];
8304
8326
  if (typeof type === "function") {
8305
8327
  const instance = new type();
8306
8328
  if (instance.validate) {
8307
- return instance.validate(value, config);
8329
+ return instance.validate(value, config, key);
8308
8330
  }
8309
8331
  }
8310
8332
  return value != null && value.constructor === type;
@@ -8343,7 +8365,7 @@ function validateFunction(fn, config) {
8343
8365
  if (ast_default.isAst(value) && !ast_default.isFunction(value))
8344
8366
  continue;
8345
8367
  if (param.type) {
8346
- const valid = validateType(param.type, value, config);
8368
+ const valid = validateType(param.type, value, config, key);
8347
8369
  if (valid === false) {
8348
8370
  errors.push({
8349
8371
  id: "parameter-type-invalid",
@@ -8443,7 +8465,7 @@ function validator(node2, config) {
8443
8465
  }
8444
8466
  value = value;
8445
8467
  if (type) {
8446
- const valid = validateType(type, value, config);
8468
+ const valid = validateType(type, value, config, key);
8447
8469
  if (valid === false) {
8448
8470
  errors.push({
8449
8471
  id: "attribute-type-invalid",
@@ -8470,7 +8492,7 @@ function validator(node2, config) {
8470
8492
  message: `Attribute '${key}' must match ${matches}. Got '${value}' instead.`
8471
8493
  });
8472
8494
  if (typeof attrib.validate === "function") {
8473
- const attribErrors = attrib.validate(value, config);
8495
+ const attribErrors = attrib.validate(value, config, key);
8474
8496
  if (Array.isArray(attribErrors))
8475
8497
  errors.push(...attribErrors);
8476
8498
  }
@@ -8508,6 +8530,29 @@ function validator(node2, config) {
8508
8530
  }
8509
8531
  return errors;
8510
8532
  }
8533
+ function* walkWithParents(node2, parents = []) {
8534
+ yield [node2, parents];
8535
+ for (const child of [...Object.values(node2.slots), ...node2.children])
8536
+ yield* walkWithParents(child, [...parents, node2]);
8537
+ }
8538
+ function validateTree(content, config) {
8539
+ const output = [...walkWithParents(content)].map(([node2, parents]) => {
8540
+ const { type, lines, location } = node2;
8541
+ const updatedConfig = {
8542
+ ...config,
8543
+ validation: { ...config.validation, parents }
8544
+ };
8545
+ const errors = validator(node2, updatedConfig);
8546
+ if (isPromise(errors)) {
8547
+ return errors.then((e) => e.map((error2) => ({ type, lines, location, error: error2 })));
8548
+ }
8549
+ return errors.map((error2) => ({ type, lines, location, error: error2 }));
8550
+ });
8551
+ if (output.some(isPromise)) {
8552
+ return Promise.all(output).then((o) => o.flat());
8553
+ }
8554
+ return output.flat();
8555
+ }
8511
8556
 
8512
8557
  // index.ts
8513
8558
  var tokenizer = new Tokenizer();
@@ -8547,18 +8592,7 @@ function transform2(nodes, options) {
8547
8592
  }
8548
8593
  function validate(content, options) {
8549
8594
  const config = mergeConfig(options);
8550
- const output = [content, ...content.walk()].map((node2) => {
8551
- const { type, lines, location } = node2;
8552
- const errors = validator(node2, config);
8553
- if (isPromise(errors)) {
8554
- return errors.then((e) => e.map((error2) => ({ type, lines, location, error: error2 })));
8555
- }
8556
- return errors.map((error2) => ({ type, lines, location, error: error2 }));
8557
- });
8558
- if (output.some(isPromise)) {
8559
- return Promise.all(output).then((o) => o.flat());
8560
- }
8561
- return output.flat();
8595
+ return validateTree(content, config);
8562
8596
  }
8563
8597
  function createElement(name, attributes = {}, ...children) {
8564
8598
  return { name, attributes, children };