@markdoc/markdoc 0.3.2 → 0.3.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
@@ -7562,7 +7562,7 @@ function handleAttrs(token, type) {
7562
7562
  return {};
7563
7563
  }
7564
7564
  }
7565
- function handleToken(token, nodes, file, handleSlots, inlineParent) {
7565
+ function handleToken(token, nodes, file, handleSlots, addLocation, inlineParent) {
7566
7566
  if (token.type === "frontmatter") {
7567
7567
  nodes[0].attributes.frontmatter = token.content;
7568
7568
  return;
@@ -7604,18 +7604,20 @@ function handleToken(token, nodes, file, handleSlots, inlineParent) {
7604
7604
  const node2 = new Node(typeName, attrs, void 0, tag || void 0);
7605
7605
  const { position = {} } = token;
7606
7606
  node2.errors = errors;
7607
- node2.lines = token.map || parent.lines || [];
7608
- node2.location = {
7609
- file,
7610
- start: {
7611
- line: node2.lines[0],
7612
- character: position.start
7613
- },
7614
- end: {
7615
- line: node2.lines[1],
7616
- character: position.end
7617
- }
7618
- };
7607
+ if (addLocation !== false) {
7608
+ node2.lines = token.map || parent.lines || [];
7609
+ node2.location = {
7610
+ file,
7611
+ start: {
7612
+ line: node2.lines[0],
7613
+ character: position.start
7614
+ },
7615
+ end: {
7616
+ line: node2.lines[1],
7617
+ character: position.end
7618
+ }
7619
+ };
7620
+ }
7619
7621
  if (inlineParent)
7620
7622
  node2.inline = true;
7621
7623
  if (attributes && ["tag", "fence", "image"].includes(typeName))
@@ -7634,7 +7636,7 @@ function handleToken(token, nodes, file, handleSlots, inlineParent) {
7634
7636
  const isLeafNode = typeName === "image";
7635
7637
  if (!isLeafNode) {
7636
7638
  for (const child of token.children)
7637
- handleToken(child, nodes, file, handleSlots, inlineParent);
7639
+ handleToken(child, nodes, file, handleSlots, addLocation, inlineParent);
7638
7640
  }
7639
7641
  nodes.pop();
7640
7642
  }
@@ -7644,7 +7646,7 @@ function parser(tokens, args) {
7644
7646
  if (typeof args === "string")
7645
7647
  args = { file: args };
7646
7648
  for (const token of tokens)
7647
- handleToken(token, nodes, args?.file, args?.slots);
7649
+ handleToken(token, nodes, args?.file, args?.slots, args?.location);
7648
7650
  if (nodes.length > 1)
7649
7651
  for (const node2 of nodes.slice(1))
7650
7652
  node2.errors.push({