@astrojs/markdoc 0.10.0 → 0.11.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.
@@ -135,8 +135,7 @@ async function resolvePartials({
135
135
  message: `(Uncaught error) Partial tag requires a 'file' attribute`
136
136
  });
137
137
  }
138
- if (markdocConfig.partials?.[file])
139
- continue;
138
+ if (markdocConfig.partials?.[file]) continue;
140
139
  let partialPath;
141
140
  let partialContents;
142
141
  try {
@@ -147,8 +146,7 @@ async function resolvePartials({
147
146
  "./" + file,
148
147
  fileURLToPath(fileUrl)
149
148
  );
150
- if (!attemptResolveAsRelative?.id)
151
- throw new Error();
149
+ if (!attemptResolveAsRelative?.id) throw new Error();
152
150
  partialId = attemptResolveAsRelative.id;
153
151
  }
154
152
  partialPath = fileURLToPath(new URL(prependForwardSlash(partialId), "file://"));
@@ -161,8 +159,7 @@ async function resolvePartials({
161
159
  ].join("\n")
162
160
  });
163
161
  }
164
- if (pluginContext.meta.watchMode)
165
- pluginContext.addWatchFile(partialPath);
162
+ if (pluginContext.meta.watchMode) pluginContext.addWatchFile(partialPath);
166
163
  let partialTokens = tokenizer.tokenize(partialContents);
167
164
  if (allowHTML) {
168
165
  partialTokens = htmlTokenTransform(tokenizer, partialTokens);
@@ -9,8 +9,7 @@ function getSlug(attributes, children, headingSlugger) {
9
9
  }
10
10
  const textContent = attributes.content ?? getTextContent(children);
11
11
  let slug = headingSlugger.slug(textContent);
12
- if (slug.endsWith("-"))
13
- slug = slug.slice(0, -1);
12
+ if (slug.endsWith("-")) slug = slug.slice(0, -1);
14
13
  return slug;
15
14
  }
16
15
  const heading = {
@@ -29,15 +29,13 @@ function parseInlineStyles(style, options) {
29
29
  if (typeof style !== "string") {
30
30
  throw new TypeError("First argument must be a string");
31
31
  }
32
- if (!style)
33
- return [];
32
+ if (!style) return [];
34
33
  options = options || {};
35
34
  let lineno = 1;
36
35
  let column = 1;
37
36
  function updatePosition(str) {
38
37
  let lines = str.match(NEWLINE_REGEX);
39
- if (lines)
40
- lineno += lines.length;
38
+ if (lines) lineno += lines.length;
41
39
  let i = str.lastIndexOf(NEWLINE);
42
40
  column = ~i ? str.length - i : column + str.length;
43
41
  }
@@ -71,8 +69,7 @@ function parseInlineStyles(style, options) {
71
69
  }
72
70
  function match(re) {
73
71
  const m = re.exec(style);
74
- if (!m)
75
- return;
72
+ if (!m) return;
76
73
  const str = m[0];
77
74
  updatePosition(str);
78
75
  style = style.slice(str.length);
@@ -93,8 +90,7 @@ function parseInlineStyles(style, options) {
93
90
  }
94
91
  function comment() {
95
92
  const pos = position();
96
- if (FORWARD_SLASH != style.charAt(0) || ASTERISK != style.charAt(1))
97
- return;
93
+ if (FORWARD_SLASH != style.charAt(0) || ASTERISK != style.charAt(1)) return;
98
94
  let i = 2;
99
95
  while (EMPTY_STRING != style.charAt(i) && (ASTERISK != style.charAt(i) || FORWARD_SLASH != style.charAt(i + 1))) {
100
96
  ++i;
@@ -116,11 +112,9 @@ function parseInlineStyles(style, options) {
116
112
  function declaration() {
117
113
  const pos = position();
118
114
  const prop = match(PROPERTY_REGEX);
119
- if (!prop)
120
- return;
115
+ if (!prop) return;
121
116
  comment();
122
- if (!match(COLON_REGEX))
123
- return error("property missing ':'");
117
+ if (!match(COLON_REGEX)) return error("property missing ':'");
124
118
  const val = match(VALUE_REGEX);
125
119
  const ret = pos({
126
120
  type: TYPE_DECLARATION,
@@ -12,13 +12,11 @@ async function loadMarkdocConfig(astroConfig) {
12
12
  let markdocConfigUrl;
13
13
  for (const filename of SUPPORTED_MARKDOC_CONFIG_FILES) {
14
14
  const filePath = new URL(filename, astroConfig.root);
15
- if (!fs.existsSync(filePath))
16
- continue;
15
+ if (!fs.existsSync(filePath)) continue;
17
16
  markdocConfigUrl = filePath;
18
17
  break;
19
18
  }
20
- if (!markdocConfigUrl)
21
- return;
19
+ if (!markdocConfigUrl) return;
22
20
  const { code } = await bundleConfigFile({
23
21
  markdocConfigUrl,
24
22
  astroConfig
@@ -65,8 +63,7 @@ async function bundleConfigFile({
65
63
  }
66
64
  ]
67
65
  });
68
- if (markdocError)
69
- throw markdocError;
66
+ if (markdocError) throw markdocError;
70
67
  const { text } = result.outputFiles[0];
71
68
  return {
72
69
  code: text,
@@ -1,5 +1,5 @@
1
- import Markdoc from "@markdoc/markdoc";
2
1
  import { Image } from "astro:assets";
2
+ import Markdoc from "@markdoc/markdoc";
3
3
  const assetsConfig = {
4
4
  nodes: {
5
5
  image: {
package/dist/runtime.js CHANGED
@@ -65,13 +65,11 @@ function mergeConfig(configA, configB) {
65
65
  function resolveComponentImports(markdocConfig, tagComponentMap, nodeComponentMap) {
66
66
  for (const [tag, render] of Object.entries(tagComponentMap)) {
67
67
  const config = markdocConfig.tags[tag];
68
- if (config)
69
- config.render = render;
68
+ if (config) config.render = render;
70
69
  }
71
70
  for (const [node, render] of Object.entries(nodeComponentMap)) {
72
71
  const config = markdocConfig.nodes[node];
73
- if (config)
74
- config.render = render;
72
+ if (config) config.render = render;
75
73
  }
76
74
  return markdocConfig;
77
75
  }
@@ -89,8 +87,7 @@ function getTextContent(childNodes) {
89
87
  const headingLevels = [1, 2, 3, 4, 5, 6];
90
88
  function collectHeadings(children, collectedHeadings) {
91
89
  for (const node of children) {
92
- if (typeof node !== "object" || !Markdoc.Tag.isTag(node))
93
- continue;
90
+ if (typeof node !== "object" || !Markdoc.Tag.isTag(node)) continue;
94
91
  if (node.attributes.__collectHeading === true && typeof node.attributes.level === "number") {
95
92
  collectedHeadings.push({
96
93
  slug: node.attributes.id,
package/dist/utils.js CHANGED
@@ -8,8 +8,7 @@ class MarkdocError extends Error {
8
8
  super(...params);
9
9
  const { title = "MarkdocError", message, stack, location, hint, frame } = props;
10
10
  this.title = title;
11
- if (message)
12
- this.message = message;
11
+ if (message) this.message = message;
13
12
  this.stack = stack ? stack : this.stack;
14
13
  this.loc = location;
15
14
  this.hint = hint;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@astrojs/markdoc",
3
3
  "description": "Add support for Markdoc in your Astro site",
4
- "version": "0.10.0",
4
+ "version": "0.11.1",
5
5
  "type": "module",
6
6
  "types": "./dist/index.d.ts",
7
7
  "author": "withastro",
@@ -56,15 +56,15 @@
56
56
  "template"
57
57
  ],
58
58
  "dependencies": {
59
- "@markdoc/markdoc": "^0.3.5",
60
- "esbuild": "^0.19.6",
59
+ "@markdoc/markdoc": "^0.4.0",
60
+ "esbuild": "^0.21.5",
61
61
  "github-slugger": "^2.0.0",
62
62
  "gray-matter": "^4.0.3",
63
- "htmlparser2": "^9.0.0",
63
+ "htmlparser2": "^9.1.0",
64
64
  "kleur": "^4.1.5",
65
- "zod": "^3.22.4",
66
- "@astrojs/internal-helpers": "0.4.0",
67
- "@astrojs/markdown-remark": "5.1.0",
65
+ "zod": "^3.23.8",
66
+ "@astrojs/internal-helpers": "0.4.1",
67
+ "@astrojs/markdown-remark": "5.1.1",
68
68
  "@astrojs/prism": "3.1.0"
69
69
  },
70
70
  "peerDependencies": {
@@ -72,11 +72,11 @@
72
72
  },
73
73
  "devDependencies": {
74
74
  "@types/html-escaper": "^3.0.2",
75
- "@types/markdown-it": "^13.0.6",
76
- "devalue": "^4.3.2",
77
- "linkedom": "^0.16.4",
78
- "vite": "^5.1.4",
79
- "astro": "4.6.0",
75
+ "@types/markdown-it": "^14.1.1",
76
+ "devalue": "^5.0.0",
77
+ "linkedom": "^0.18.3",
78
+ "vite": "^5.3.1",
79
+ "astro": "4.11.1",
80
80
  "astro-scripts": "0.0.14"
81
81
  },
82
82
  "engines": {