From 8ea1f46ae51f29dce7908a1bde77fee22e6c2e3f Mon Sep 17 00:00:00 2001 From: Roger Parkinson <77937569+Roger-Parkinson-EHP@users.noreply.github.com> Date: Sat, 21 Mar 2026 23:19:31 -0400 Subject: [PATCH] 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) --- gitnexus/src/core/ingestion/markdown-processor.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitnexus/src/core/ingestion/markdown-processor.ts b/gitnexus/src/core/ingestion/markdown-processor.ts index d894cee43..196c0e1e1 100644 --- a/gitnexus/src/core/ingestion/markdown-processor.ts +++ b/gitnexus/src/core/ingestion/markdown-processor.ts @@ -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']);