mdv-live 0.3.4 → 0.3.6
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/package.json +1 -1
- package/src/api/tree.js +2 -2
- package/src/rendering/markdown.js +15 -1
package/package.json
CHANGED
package/src/api/tree.js
CHANGED
|
@@ -7,7 +7,7 @@ import path from 'path';
|
|
|
7
7
|
import { getFileType } from '../utils/fileTypes.js';
|
|
8
8
|
import { getRelativePath, validatePath } from '../utils/path.js';
|
|
9
9
|
|
|
10
|
-
const IGNORED_PATTERNS = new Set(['node_modules', '__pycache__']);
|
|
10
|
+
const IGNORED_PATTERNS = new Set(['node_modules', '__pycache__', '.git']);
|
|
11
11
|
const MAX_INITIAL_DEPTH = 1;
|
|
12
12
|
|
|
13
13
|
/**
|
|
@@ -16,7 +16,7 @@ const MAX_INITIAL_DEPTH = 1;
|
|
|
16
16
|
* @returns {boolean} True if should be ignored
|
|
17
17
|
*/
|
|
18
18
|
function shouldIgnore(name) {
|
|
19
|
-
return
|
|
19
|
+
return IGNORED_PATTERNS.has(name);
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
/**
|
|
@@ -23,9 +23,12 @@ md.use(taskLists, { enabled: true, label: true, labelAfter: true });
|
|
|
23
23
|
// Pattern to detect Marp frontmatter (must be at very start of file, not using 'm' flag)
|
|
24
24
|
const MARP_PATTERN = /^---\s*\n[\s\S]*?marp:\s*true[\s\S]*?\n---/;
|
|
25
25
|
|
|
26
|
-
// Pattern to detect YAML frontmatter
|
|
26
|
+
// Pattern to detect YAML frontmatter at start of file
|
|
27
27
|
const FRONTMATTER_PATTERN = /^---\s*\n([\s\S]*?)\n---\s*(\n|$)/;
|
|
28
28
|
|
|
29
|
+
// Pattern to detect metadata block after h1 heading (Claude Agent format)
|
|
30
|
+
const HEADING_METADATA_PATTERN = /^(#[^\n]+\n+)(---\s*\n)([\s\S]*?)(\n---\s*)(\n|$)/;
|
|
31
|
+
|
|
29
32
|
// Pattern for Mermaid code blocks
|
|
30
33
|
const MERMAID_PATTERN = /```mermaid\s*\n([\s\S]*?)\n```/g;
|
|
31
34
|
|
|
@@ -44,12 +47,23 @@ export function isMarp(content) {
|
|
|
44
47
|
* @returns {string} Content with frontmatter converted
|
|
45
48
|
*/
|
|
46
49
|
function convertFrontmatter(content) {
|
|
50
|
+
// Check for standard frontmatter at start of file
|
|
47
51
|
const match = content.match(FRONTMATTER_PATTERN);
|
|
48
52
|
if (match) {
|
|
49
53
|
const frontmatter = match[1];
|
|
50
54
|
const rest = content.slice(match[0].length);
|
|
51
55
|
return `\`\`\`yaml\n${frontmatter}\n\`\`\`\n${rest}`;
|
|
52
56
|
}
|
|
57
|
+
|
|
58
|
+
// Check for metadata block after h1 heading (Claude Agent format)
|
|
59
|
+
const headingMatch = content.match(HEADING_METADATA_PATTERN);
|
|
60
|
+
if (headingMatch) {
|
|
61
|
+
const heading = headingMatch[1];
|
|
62
|
+
const metadata = headingMatch[3];
|
|
63
|
+
const rest = content.slice(headingMatch[0].length);
|
|
64
|
+
return `${heading}\`\`\`yaml\n${metadata}\n\`\`\`\n${rest}`;
|
|
65
|
+
}
|
|
66
|
+
|
|
53
67
|
return content;
|
|
54
68
|
}
|
|
55
69
|
|