@markdoc/markdoc 0.3.0 → 0.3.1

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
  }
@@ -7012,6 +7012,9 @@ function* formatTableRow(items) {
7012
7012
  yield `| ${items.join(" | ")} |`;
7013
7013
  }
7014
7014
  function formatScalar(v) {
7015
+ if (v === void 0) {
7016
+ return void 0;
7017
+ }
7015
7018
  if (ast_default.isAst(v)) {
7016
7019
  return format(v);
7017
7020
  }
@@ -7027,13 +7030,16 @@ function formatScalar(v) {
7027
7030
  return JSON.stringify(v);
7028
7031
  }
7029
7032
  function formatAnnotationValue(a) {
7033
+ const formattedValue = formatScalar(a.value);
7034
+ if (formattedValue === void 0)
7035
+ return void 0;
7030
7036
  if (a.name === "primary")
7031
- return formatScalar(a.value);
7037
+ return formattedValue;
7032
7038
  if (a.name === "id" && typeof a.value === "string" && isIdentifier(a.value))
7033
7039
  return "#" + a.value;
7034
7040
  if (a.type === "class" && isIdentifier(a.name))
7035
7041
  return "." + a.name;
7036
- return `${a.name}=${formatScalar(a.value)}`;
7042
+ return `${a.name}=${formattedValue}`;
7037
7043
  }
7038
7044
  function* formatAttributes(n) {
7039
7045
  for (const [key, value] of Object.entries(n.attributes)) {
@@ -7194,7 +7200,8 @@ function* formatNode(n, o = {}) {
7194
7200
  yield indent;
7195
7201
  }
7196
7202
  const open = OPEN + SPACE;
7197
- const tag = [open + n.tag, ...formatAttributes(n)];
7203
+ const attributes = [...formatAttributes(n)].filter((v) => v !== void 0);
7204
+ const tag = [open + n.tag, ...attributes];
7198
7205
  const inlineTag = tag.join(SPACE);
7199
7206
  const isLongTagOpening = inlineTag.length + open.length * 2 > (o.maxTagOpeningWidth || MAX_TAG_OPENING_WIDTH);
7200
7207
  yield (!n.inline && isLongTagOpening ? tag.join(NL + SPACE.repeat(open.length) + indent) : inlineTag) + SPACE + (n.children.length ? "" : "/") + CLOSE;
@@ -7211,9 +7218,13 @@ function* formatNode(n, o = {}) {
7211
7218
  break;
7212
7219
  }
7213
7220
  case "list": {
7221
+ const isLoose = n.children.some((n2) => n2.children.some((c) => c.type === "paragraph"));
7214
7222
  for (let i = 0; i < n.children.length; i++) {
7215
7223
  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();
7224
+ let d = format(n.children[i], increment(no, prefix.length + 1));
7225
+ if (!isLoose || i === n.children.length - 1) {
7226
+ d = d.trim();
7227
+ }
7217
7228
  yield NL + indent + prefix + " " + d;
7218
7229
  }
7219
7230
  yield NL;
@@ -7506,9 +7517,15 @@ function annotate(node2, attributes) {
7506
7517
  for (const attribute of attributes) {
7507
7518
  node2.annotations.push(attribute);
7508
7519
  const { name, value, type } = attribute;
7509
- if (type === "attribute")
7520
+ if (type === "attribute") {
7521
+ if (node2.attributes[name] !== void 0)
7522
+ node2.errors.push({
7523
+ id: "duplicate-attribute",
7524
+ level: "warning",
7525
+ message: `Attribute '${name}' already set`
7526
+ });
7510
7527
  node2.attributes[name] = value;
7511
- else if (type === "class")
7528
+ } else if (type === "class")
7512
7529
  if (node2.attributes.class)
7513
7530
  node2.attributes.class[name] = value;
7514
7531
  else
@@ -7633,7 +7650,8 @@ function handleToken(token, nodes, file, handleSlots, inlineParent) {
7633
7650
  nodes.push(node2);
7634
7651
  if (!Array.isArray(token.children))
7635
7652
  return;
7636
- inlineParent = parent;
7653
+ if (node2.type === "inline")
7654
+ inlineParent = parent;
7637
7655
  nodes.push(node2);
7638
7656
  const isLeafNode = typeName === "image";
7639
7657
  if (!isLeafNode) {
@@ -7805,16 +7823,18 @@ var td = {
7805
7823
  "hr"
7806
7824
  ],
7807
7825
  attributes: {
7808
- colspan: { type: Number },
7809
- rowspan: { type: Number },
7810
- align: { type: String }
7826
+ align: { type: String },
7827
+ colspan: { type: Number, render: "colSpan" },
7828
+ rowspan: { type: Number, render: "rowSpan" }
7811
7829
  }
7812
7830
  };
7813
7831
  var th = {
7814
7832
  render: "th",
7815
7833
  attributes: {
7816
7834
  width: { type: Number },
7817
- align: { type: String }
7835
+ align: { type: String },
7836
+ colspan: { type: Number, render: "colSpan" },
7837
+ rowspan: { type: Number, render: "rowSpan" }
7818
7838
  }
7819
7839
  };
7820
7840
  var tr = {
@@ -7935,7 +7955,7 @@ function render(node2) {
7935
7955
  return render(children);
7936
7956
  let output = `<${name}`;
7937
7957
  for (const [k, v] of Object.entries(attributes ?? {}))
7938
- output += ` ${k}="${escapeHtml(String(v))}"`;
7958
+ output += ` ${k.toLowerCase()}="${escapeHtml(String(v))}"`;
7939
7959
  output += ">";
7940
7960
  if (voidElements.has(name))
7941
7961
  return output;
@@ -8135,7 +8155,7 @@ function block(state, startLine, endLine, silent) {
8135
8155
  return false;
8136
8156
  const contentStart = start + OPEN.length;
8137
8157
  const content = state.src.slice(contentStart, tagEnd).trim();
8138
- const lines = content.split("\n").length;
8158
+ const lines = state.src.slice(start, tagEnd + CLOSE.length).split("\n").length;
8139
8159
  if (content[0] === "$")
8140
8160
  return false;
8141
8161
  if (silent)
@@ -8288,7 +8308,7 @@ var TypeMappings = {
8288
8308
  Object,
8289
8309
  Boolean
8290
8310
  };
8291
- function validateType(type, value, config) {
8311
+ function validateType(type, value, config, key) {
8292
8312
  if (!type)
8293
8313
  return true;
8294
8314
  if (ast_default.isFunction(value) && config.validation?.validateFunctions) {
@@ -8298,13 +8318,13 @@ function validateType(type, value, config) {
8298
8318
  if (ast_default.isAst(value))
8299
8319
  return true;
8300
8320
  if (Array.isArray(type))
8301
- return type.some((t) => validateType(t, value, config));
8321
+ return type.some((t) => validateType(t, value, config, key));
8302
8322
  if (typeof type === "string")
8303
8323
  type = TypeMappings[type];
8304
8324
  if (typeof type === "function") {
8305
8325
  const instance = new type();
8306
8326
  if (instance.validate) {
8307
- return instance.validate(value, config);
8327
+ return instance.validate(value, config, key);
8308
8328
  }
8309
8329
  }
8310
8330
  return value != null && value.constructor === type;
@@ -8343,7 +8363,7 @@ function validateFunction(fn, config) {
8343
8363
  if (ast_default.isAst(value) && !ast_default.isFunction(value))
8344
8364
  continue;
8345
8365
  if (param.type) {
8346
- const valid = validateType(param.type, value, config);
8366
+ const valid = validateType(param.type, value, config, key);
8347
8367
  if (valid === false) {
8348
8368
  errors.push({
8349
8369
  id: "parameter-type-invalid",
@@ -8443,7 +8463,7 @@ function validator(node2, config) {
8443
8463
  }
8444
8464
  value = value;
8445
8465
  if (type) {
8446
- const valid = validateType(type, value, config);
8466
+ const valid = validateType(type, value, config, key);
8447
8467
  if (valid === false) {
8448
8468
  errors.push({
8449
8469
  id: "attribute-type-invalid",
@@ -8470,7 +8490,7 @@ function validator(node2, config) {
8470
8490
  message: `Attribute '${key}' must match ${matches}. Got '${value}' instead.`
8471
8491
  });
8472
8492
  if (typeof attrib.validate === "function") {
8473
- const attribErrors = attrib.validate(value, config);
8493
+ const attribErrors = attrib.validate(value, config, key);
8474
8494
  if (Array.isArray(attribErrors))
8475
8495
  errors.push(...attribErrors);
8476
8496
  }
@@ -8508,6 +8528,29 @@ function validator(node2, config) {
8508
8528
  }
8509
8529
  return errors;
8510
8530
  }
8531
+ function* walkWithParents(node2, parents = []) {
8532
+ yield [node2, parents];
8533
+ for (const child of [...Object.values(node2.slots), ...node2.children])
8534
+ yield* walkWithParents(child, [...parents, node2]);
8535
+ }
8536
+ function validateTree(content, config) {
8537
+ const output = [...walkWithParents(content)].map(([node2, parents]) => {
8538
+ const { type, lines, location } = node2;
8539
+ const updatedConfig = {
8540
+ validation: { ...config.validation, parents },
8541
+ ...config
8542
+ };
8543
+ const errors = validator(node2, updatedConfig);
8544
+ if (isPromise(errors)) {
8545
+ return errors.then((e) => e.map((error2) => ({ type, lines, location, error: error2 })));
8546
+ }
8547
+ return errors.map((error2) => ({ type, lines, location, error: error2 }));
8548
+ });
8549
+ if (output.some(isPromise)) {
8550
+ return Promise.all(output).then((o) => o.flat());
8551
+ }
8552
+ return output.flat();
8553
+ }
8511
8554
 
8512
8555
  // index.ts
8513
8556
  var tokenizer = new Tokenizer();
@@ -8547,18 +8590,7 @@ function transform2(nodes, options) {
8547
8590
  }
8548
8591
  function validate(content, options) {
8549
8592
  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();
8593
+ return validateTree(content, config);
8562
8594
  }
8563
8595
  function createElement(name, attributes = {}, ...children) {
8564
8596
  return { name, attributes, children };