The obsidian-markdown/ layer is a pure functional domain for parsing and transforming Obsidian-flavored Markdown. It is architecturally significant because it encodes Obsidian-parity behavior—such as complex link resolution, task metadata extraction, and code-fence awareness—without performing any filesystem I/O or SQLite queries src/vault-mcp/obsidian-markdown/links.ts1-5
By isolating this logic, Vault Cortex ensures that the indexer, the note-patcher, and the link-rewriter all share a single source of truth regarding the structure of a note src/vault-mcp/obsidian-markdown/links.ts3-5
links.ts)The link engine handles the grammar, extraction, and resolution of all Obsidian link formats. It is designed to be "fence-aware," meaning it can ignore links inside backticks or code blocks during extraction src/vault-mcp/obsidian-markdown/links.ts1-11
The parser recognizes three primary categories of links:
[[target]], [[target|alias]], [[target#heading]], and embeds ![[target]] src/vault-mcp/obsidian-markdown/links.ts18-21 It includes specialized handling for Obsidian's table-pipe escaping (\|) where a trailing backslash on a target is stripped and shifted into the alias src/vault-mcp/obsidian-markdown/links.ts151-160<FileRef file-url="https://github.com/aliasunder/vault-cortex/blob/c69495e3/text" undefined file-path="text">Hii</FileRef> or <FileRef file-url="https://github.com/aliasunder/vault-cortex/blob/c69495e3/text" undefined file-path="text">Hii</FileRef>. It specifically filters for .md extensions and excludes external URLs via a URI-scheme lookahead src/vault-mcp/obsidian-markdown/links.ts32-33 src/vault-mcp/obsidian-markdown/links.ts50-55related: [[Note]]), extracted via specialized logic that understands property-block syntax src/vault-mcp/obsidian-markdown/links.ts181-185Resolution follows Obsidian's "New link format" modes, handled by resolveTargetToPath src/vault-mcp/obsidian-markdown/links.ts205-207:
./ or ../ relative to the sourcePath src/vault-mcp/obsidian-markdown/links.ts221-224allPaths lookup src/vault-mcp/obsidian-markdown/links.ts230-235Diagram: Link Extraction Pipeline
Sources: src/vault-mcp/obsidian-markdown/links.ts117-130 src/vault-mcp/obsidian-markdown/lines.ts16-20 src/vault-mcp/obsidian-markdown/links.ts165-170
lines.ts)This module provides the low-level primitives for splitting content and tracking state. It implements the CommonMark §4.5 fenced-code state machine and Obsidian %% %% comment state machine src/vault-mcp/obsidian-markdown/lines.ts5-7
splitIntoLines: Normalizes line endings by stripping trailing \r (CR), ensuring consistent behavior for CRLF (Windows) files across the entire parser layer src/vault-mcp/obsidian-markdown/lines.ts16-20advanceFence: Tracks backtick (`) or tilde (~) fences. It is blockquote-aware, recognizing fences inside callouts (e.g., > ``` ) and handling implicit closure when a blockquote container ends src/vault-mcp/obsidian-markdown/lines.ts101-118advanceComment: Toggles comment state based on %% delimiters at line boundaries. It distinguishes between mid-line text (like 100%%) and actual comment markers src/vault-mcp/obsidian-markdown/lines.ts158-172classifyLines: A higher-level utility that runs the fence and comment state machines over a set of lines to identify regions that should be ignored by other parsers src/vault-mcp/obsidian-markdown/lines.ts203-205Sources: src/vault-mcp/obsidian-markdown/lines.ts1-7 src/vault-mcp/obsidian-markdown/lines.ts101-154 src/vault-mcp/obsidian-markdown/lines.ts186-201
tasks.ts)Vault Cortex provides a faithful reimplementation of the Obsidian Tasks plugin parser. It extracts metadata from checkbox lines using a repeated stripping loop that removes one field at a time from the end of the line src/vault-mcp/obsidian-markdown/tasks.ts5-10
📅 2026-07-04) and Dataview inline fields (e.g., [due:: 2026-07-04]) src/vault-mcp/obsidian-markdown/tasks.ts11-13todo, in_progress, done, or cancelled src/vault-mcp/obsidian-markdown/tasks.ts38-40heading, which represents the lane on a Kanban board src/vault-mcp/obsidian-markdown/tasks.ts80-82Sources: src/vault-mcp/obsidian-markdown/tasks.ts1-22 src/vault-mcp/obsidian-markdown/tasks.ts49-83
headings.ts)The heading parser identifies H1 through H6 sections and determines their spans. This logic is shared by both the vault_read_note tool (for outlines) and the vault_patch_note tool (for surgical edits) src/vault-mcp/obsidian-markdown/headings.ts1-6
findTrailingCommentBlockStart identifies "trailing comment blocks" (e.g., %% kanban:settings %%) so append/replace operations do not clobber plugin metadata src/vault-mcp/obsidian-markdown/headings.ts51-61%% comments are ignored during the single-pass walk src/vault-mcp/obsidian-markdown/headings.ts161-178Sources: src/vault-mcp/obsidian-markdown/headings.ts1-23 src/vault-mcp/obsidian-markdown/headings.ts134-210
memory-entries.ts)The memory layer uses a specialized parser for the "About Me" dated-bullet format (- **YYYY-MM-DD**: text). This module decomposes topic sections into individual, time-stamped entries src/vault-mcp/obsidian-markdown/memory-entries.ts1-7
entryIndex in document order, which is used for content-hash reconciliation in the search index src/vault-mcp/obsidian-markdown/memory-entries.ts38Sources: src/vault-mcp/obsidian-markdown/memory-entries.ts1-12 src/vault-mcp/obsidian-markdown/memory-entries.ts99-173
callouts.ts)The parseLeadingCallout function extracts the first Obsidian callout block (> [!type]) at the top of a note body src/vault-mcp/obsidian-markdown/callouts.ts1-4 It skips at most one H1 title line to find the callout, which is common in structured memory files src/vault-mcp/obsidian-markdown/callouts.ts6-10
frontmatter.ts)Vault Cortex uses gray-matter with a custom yaml engine (YAML 1.2) to prevent the "UTC-Z datetime bug" where timestamp-shaped strings are automatically converted to JS Dates src/vault-mcp/obsidian-markdown/frontmatter.ts5-10
mergeFrontmatter: Merges updates into existing data. Setting a key to null in the updates object triggers explicit deletion of that property src/vault-mcp/obsidian-markdown/frontmatter.ts66-70plaintext.ts)The stripMarkdownSyntax function produces plain text for the embedding pipeline by removing formatting markers while preserving semantic content src/vault-mcp/obsidian-markdown/plaintext.ts1-4 It strips wikilink brackets (keeping display text), comments, and formatting (bold, italics, callout markers) src/vault-mcp/obsidian-markdown/plaintext.ts6-9
Sources: src/vault-mcp/obsidian-markdown/callouts.ts100-156 src/vault-mcp/obsidian-markdown/frontmatter.ts1-15 src/vault-mcp/obsidian-markdown/plaintext.ts1-27
canvas.ts)The canvas.ts module provides a JSON Canvas 1.0 linearizer. It converts the spatial JSON format of Obsidian Canvas files into a reading-order string that AI agents can process as text.
y position, then horizontal x position src/vault-mcp/obsidian-markdown/canvas.ts105-109Sources: src/vault-mcp/obsidian-markdown/canvas.ts1-20 src/vault-mcp/obsidian-markdown/canvas.ts98-145
The following table and diagram map natural language concepts to the specific code entities in the obsidian-markdown/ layer.
| Concept | Code Entity | File |
|---|---|---|
| Fence State | OpenFence | src/vault-mcp/obsidian-markdown/lines.ts72 |
| Line Normalization | splitIntoLines() | src/vault-mcp/obsidian-markdown/lines.ts16 |
| Wikilink Parsing | splitWikilink() | src/vault-mcp/obsidian-markdown/links.ts151 |
| Section Boundary | HeadingInfo | src/vault-mcp/obsidian-markdown/headings.ts18 |
| Task Extraction | ParsedTask | src/vault-mcp/obsidian-markdown/tasks.ts49 |
| Memory Entry | MemoryEntry | src/vault-mcp/obsidian-markdown/memory-entries.ts24 |
| Canvas Linearizer | linearizeCanvas() | src/vault-mcp/obsidian-markdown/canvas.ts98 |
Diagram: System Entity Association
Sources: src/vault-mcp/obsidian-markdown/lines.ts72 src/vault-mcp/obsidian-markdown/links.ts151 src/vault-mcp/obsidian-markdown/headings.ts18 src/vault-mcp/obsidian-markdown/tasks.ts49 src/vault-mcp/obsidian-markdown/memory-entries.ts24 src/vault-mcp/obsidian-markdown/canvas.ts98
Refresh this wiki
This wiki was recently refreshed. Please wait 6 days to refresh again.