mirror of
https://github.com/abhigyanpatwari/GitNexus.git
synced 2026-09-13 23:14:20 +00:00
fix: handle CRLF line endings in markdown heading regex
The HEADING_RE regex used `$` to anchor the end of heading lines,
but on Windows, `String.split('\n')` leaves `\r` at the end of each
line. The `$` anchor does not match before `\r` in JavaScript's
non-multiline mode, causing the regex to silently skip every heading
in CRLF-encoded files.
This resulted in 0 Section nodes being created for markdown files
on Windows, while the same files indexed correctly on macOS/Linux.
Fix: replace `.+$` with `.+?[\r\t ]*$` to consume optional trailing
whitespace and carriage returns before the anchor.
Tested on a 424-file markdown-heavy repo on Windows:
Before: 22 sections (only from LF-encoded files)
After: 8,072 sections (all files)
This commit is contained in:
parent
b75e380bd0
commit
8ea1f46ae5
1 changed files with 1 additions and 1 deletions
|
|
@ -10,7 +10,7 @@ import path from 'node:path';
|
|||
import { generateId } from '../../lib/utils.js';
|
||||
import { KnowledgeGraph, GraphNode, GraphRelationship } from '../graph/types.js';
|
||||
|
||||
const HEADING_RE = /^(#{1,6})\s+(.+)$/;
|
||||
const HEADING_RE = /^(#{1,6})\s+(.+?)[\r\t ]*$/;
|
||||
const LINK_RE = /\[([^\]]*)\]\(([^)]+)\)/g;
|
||||
const MD_EXTENSIONS = new Set(['.md', '.mdx']);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue