utils/neomagemd/neomagemd_parser library

NEOMAGE.md file parsing, loading, merging.

Ported from neomage/src/utils/neomagemd.ts (1479 LOC).

Files are loaded in the following order:

  1. Managed memory (eg. /etc/neomage/NEOMAGE.md) - Global instructions for all users
  2. User memory (~/.neomage/NEOMAGE.md) - Private global instructions for all projects
  3. Project memory (NEOMAGE.md, .neomage/NEOMAGE.md, and .neomage/rules/*.md in project roots)
  4. Local memory (NEOMAGE.local.md in project roots) - Private project-specific instructions

Files are loaded in reverse order of priority, i.e. the latest files are highest priority.

Memory @include directive:

  • Memory files can include other files using @ notation
  • Syntax: @path, @./relative/path, @~/home/path, or @/absolute/path
  • Works in leaf text nodes only (not inside code blocks or code strings)
  • Included files are added as separate entries before the including file
  • Circular references are prevented by tracking processed files
  • Non-existent files are silently ignored

Classes

ExternalNeomageMdInclude
External NEOMAGE.md include reference.
MemoryFileInfo
Information about a loaded memory file.
NeomageMdParser
Manages NEOMAGE.md file discovery, parsing, loading, and merging.

Enums

MemoryType
The type of a memory file.

Constants

maxMemoryCharacterCount → const int
Recommended max character count for a memory file.

Functions

stripHtmlComments(String content) → ({String content, bool stripped})
Strip block-level HTML comments from markdown content.