@writechoice/mint-cli 0.0.1 → 0.0.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/README.md CHANGED
@@ -15,7 +15,7 @@ CLI tool for Mintlify documentation validation and utilities.
15
15
  ### Global Installation
16
16
 
17
17
  ```bash
18
- npm install -g writechoice-mint-cli
18
+ npm install -g @writechoice/mint-cli
19
19
  ```
20
20
 
21
21
  ### Local Development
@@ -122,6 +122,10 @@ The tool extracts internal links from MDX files in the following formats:
122
122
  3. **JSX Card components**: `<Card href="/path/to/page" title="Card Title" />`
123
123
  4. **JSX Button components**: `<Button href="/path/to/page#anchor">Button Text</Button>`
124
124
 
125
+ **Images are automatically ignored:**
126
+ - Markdown images: `![Alt Text](./image.png)`
127
+ - HTML images: `<img src="./image.png" />`
128
+
125
129
  ### Validation Process
126
130
 
127
131
  1. **Local Validation**: First checks if the target MDX file exists locally
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@writechoice/mint-cli",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "CLI tool for Mintlify documentation validation and utilities",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -35,7 +35,9 @@ const DEFAULT_CONCURRENCY = 25;
35
35
  // Link extraction patterns
36
36
  const LINK_PATTERNS = {
37
37
  markdown: /\[([^\]]+?)\]\(([^)]+?)\)/g,
38
+ markdownImage: /!\[([^\]]*?)\]\(([^)]+?)\)/g,
38
39
  htmlAnchor: /<a\s+href=["'](.*?)["'][^>]*?>(.*?)<\/a>/gs,
40
+ htmlImage: /<img[^>]+src=["'](.*?)["'][^>]*?>/gi,
39
41
  jsxCard: /<Card[^>]+?href=["'](.*?)["'][^>]*?(?:title=["'](.*?)["'])?[^>]*?>/g,
40
42
  jsxButton: /<Button[^>]+?href=["'](.*?)["'][^>]*?>(.*?)<\/Button>/gs,
41
43
  };
@@ -213,9 +215,31 @@ function extractLinksFromFile(filePath, baseUrl, repoRoot, verbose = false) {
213
215
  const { cleanedContent } = removeCodeBlocksAndFrontmatter(content);
214
216
  const links = [];
215
217
 
216
- // Extract markdown links [text](url)
218
+ // Collect all image positions to skip them
219
+ const imagePositions = new Set();
220
+
221
+ // Find all markdown images ![alt](url)
222
+ const markdownImages = [...cleanedContent.matchAll(LINK_PATTERNS.markdownImage)];
223
+ for (const match of markdownImages) {
224
+ imagePositions.add(match.index);
225
+ }
226
+
227
+ // Find all HTML images <img src="url">
228
+ const htmlImages = [...cleanedContent.matchAll(LINK_PATTERNS.htmlImage)];
229
+ for (const match of htmlImages) {
230
+ imagePositions.add(match.index);
231
+ }
232
+
233
+ // Extract markdown links [text](url) - skip images
217
234
  const markdownMatches = [...cleanedContent.matchAll(LINK_PATTERNS.markdown)];
218
235
  for (const match of markdownMatches) {
236
+ // Check if this is actually an image by looking at the character before '['
237
+ const charBefore = match.index > 0 ? cleanedContent[match.index - 1] : '';
238
+ if (charBefore === '!') {
239
+ // This is a markdown image ![alt](url), skip it
240
+ continue;
241
+ }
242
+
219
243
  const linkText = match[1];
220
244
  const href = match[2];
221
245