Documentation
¶
Index ¶
- func ChangedLines(file, ref string) (map[int]bool, error)
- func Walk(root Node, fn func(Node) bool)
- type AutoLink
- type BaseNode
- type Blockquote
- type Callout
- type CalloutKind
- type CodeBlock
- type CommitRef
- type ContentSummary
- type Definition
- type DefinitionList
- type DefinitionTerm
- type Delete
- type Document
- type Emoji
- type Emphasis
- type Entity
- type FootnoteDef
- type FootnoteRef
- type Frontmatter
- type FrontmatterFormat
- type HTMLBlock
- type Heading
- type Image
- type InlineCode
- type InlineHTML
- type InlineMath
- type IssueRef
- type LineBreak
- type Link
- type LinkRefDef
- type List
- type ListItem
- type MathBlock
- type Mention
- type Node
- type NodeKind
- type NotableStats
- type Paragraph
- type Reference
- type Section
- type Strong
- type Table
- type TableAlign
- type TableCell
- type TableRow
- type TaskItem
- type Text
- type ThematicBreak
- type WikiEmbed
- type WikiLink
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ChangedLines ¶ added in v0.3.0
ChangedLines returns the set of line numbers in `file` that have been modified since the given git ref. It shells out to `git diff --unified=0` and parses the hunk headers, which in unified-0 mode give exact line ranges in the new (working) file.
If the file isn't tracked by git, the ref doesn't exist, or git isn't available, ChangedLines returns an empty set and a nil error — callers should treat "nothing changed" as the fall-through behavior.
Types ¶
type BaseNode ¶ added in v0.3.0
BaseNode holds fields common to every node and is embedded in each concrete type. Its exported fields let constructors populate state without per-type setters.
type Blockquote ¶ added in v0.3.0
type Blockquote struct {
BaseNode
}
Blockquote is a > quoted block, possibly nested.
type Callout ¶ added in v0.3.0
type Callout struct {
BaseNode
Variant CalloutKind
}
Callout is a GFM alert (> [!NOTE] / [!TIP] / [!IMPORTANT] / [!WARNING] / [!CAUTION]).
type CalloutKind ¶ added in v0.3.0
type CalloutKind string
CalloutKind identifies the variant of a GFM alert (> [!NOTE] etc).
const ( CalloutNote CalloutKind = "note" CalloutTip CalloutKind = "tip" CalloutImportant CalloutKind = "important" CalloutWarning CalloutKind = "warning" CalloutCaution CalloutKind = "caution" )
type ContentSummary ¶ added in v0.3.0
type ContentSummary struct {
Callouts int
Tables int
CodeBlocks int
MathBlocks int
HTMLBlocks int
Footnotes int
DefLists int
LinkRefDefs int
Tasks int
TasksChecked int
WikiLinks int
WikiEmbeds int
Mentions int
IssueRefs int
CommitRefs int
Emojis int
}
ContentSummary is an at-a-glance inventory of notable constructs across an entire Document. Used by the renderer to draw the file header.
type Definition ¶ added in v0.3.0
type Definition struct {
BaseNode
}
Definition is a single definition for a term.
type DefinitionList ¶ added in v0.3.0
type DefinitionList struct {
BaseNode
}
DefinitionList is a Pandoc-style definition list.
type DefinitionTerm ¶ added in v0.3.0
DefinitionTerm is the term being defined.
type Delete ¶ added in v0.3.0
type Delete struct {
BaseNode
}
Delete is ~~text~~ (GFM strikethrough).
type Document ¶
type Document struct {
Filename string
TotalTokens int
Sections []*Section
References []Reference // Links to other .md files
Nodes []Node // Typed AST (populated by the new parser)
}
Document represents a parsed markdown document.
The legacy Sections tree is heading-only and is what the renderer currently consumes. Nodes holds the richer typed AST produced by the new goldmark-based parser (frontmatter, tables, callouts, code blocks, Obsidian wiki links, etc.) once it lands. Both exist side-by-side during the migration so existing callers keep working.
func Parse ¶
Parse parses markdown content into a Document using goldmark (CommonMark + GFM + Obsidian extensions) and derives the legacy Section tree and cross-file Reference list from the resulting typed AST.
func (*Document) GetAllSections ¶
GetAllSections returns a flat list of all sections
func (*Document) GetSection ¶
GetSection finds a section by name (case-insensitive partial match)
func (*Document) Summary ¶ added in v0.3.0
func (d *Document) Summary() ContentSummary
Summary walks the typed AST once and returns inventory counts for every notable construct in the document. Used by the renderer to draw the file header's content summary.
type FootnoteDef ¶ added in v0.3.0
FootnoteDef is a footnote definition ([^id]: content).
type FootnoteRef ¶ added in v0.3.0
FootnoteRef is [^id] in flowing text.
type Frontmatter ¶ added in v0.3.0
type Frontmatter struct {
BaseNode
Format FrontmatterFormat
Raw string
}
Frontmatter is a YAML/TOML/JSON header block at the top of a file.
type FrontmatterFormat ¶ added in v0.3.0
type FrontmatterFormat string
FrontmatterFormat is the serialization format of a frontmatter block.
const ( FrontmatterYAML FrontmatterFormat = "yaml" FrontmatterTOML FrontmatterFormat = "toml" FrontmatterJSON FrontmatterFormat = "json" )
type HTMLBlock ¶ added in v0.3.0
HTMLBlock is a raw HTML block (includes <details>, <div>, comments).
type InlineCode ¶ added in v0.3.0
InlineCode is `text`.
type InlineHTML ¶ added in v0.3.0
InlineHTML is raw inline HTML like <kbd>.
type InlineMath ¶ added in v0.3.0
InlineMath is $...$.
type LinkRefDef ¶ added in v0.3.0
LinkRefDef is a reference link definition ([label]: url "title").
type ListItem ¶ added in v0.3.0
type ListItem struct {
BaseNode
}
ListItem is a regular item inside a list.
type Node ¶ added in v0.3.0
type Node interface {
Kind() NodeKind
LineStart() int
LineEnd() int
Tokens() int
Children() []Node
}
Node is the common interface every markdown construct implements. Concrete types embed BaseNode to satisfy it.
func FindByKind ¶ added in v0.3.0
FindByKind returns every descendant of root whose Kind matches kind.
type NodeKind ¶ added in v0.3.0
type NodeKind string
NodeKind enumerates every markdown construct docmap recognizes. The taxonomy covers CommonMark + GFM + Obsidian wiki links/embeds.
const ( KindFrontmatter NodeKind = "frontmatter" KindHeading NodeKind = "heading" KindParagraph NodeKind = "paragraph" KindBlockquote NodeKind = "blockquote" KindCallout NodeKind = "callout" KindList NodeKind = "list" KindListItem NodeKind = "list_item" KindTaskItem NodeKind = "task_item" KindTable NodeKind = "table" KindTableRow NodeKind = "table_row" KindTableCell NodeKind = "table_cell" KindCodeBlock NodeKind = "code_block" KindMathBlock NodeKind = "math_block" KindThematicBreak NodeKind = "thematic_break" KindHTMLBlock NodeKind = "html_block" KindDefinitionList NodeKind = "definition_list" KindDefTerm NodeKind = "definition_term" KindDefinition NodeKind = "definition" KindFootnoteDef NodeKind = "footnote_def" KindLinkRefDef NodeKind = "link_ref_def" KindText NodeKind = "text" KindEmphasis NodeKind = "emphasis" KindStrong NodeKind = "strong" KindDelete NodeKind = "delete" KindInlineCode NodeKind = "inline_code" KindLink NodeKind = "link" KindAutoLink NodeKind = "autolink" KindImage NodeKind = "image" KindWikiLink NodeKind = "wiki_link" KindWikiEmbed NodeKind = "wiki_embed" KindFootnoteRef NodeKind = "footnote_ref" KindMention NodeKind = "mention" KindIssueRef NodeKind = "issue_ref" KindCommitRef NodeKind = "commit_ref" KindEmoji NodeKind = "emoji" KindLineBreak NodeKind = "line_break" KindEntity NodeKind = "entity" KindInlineMath NodeKind = "inline_math" KindInlineHTML NodeKind = "inline_html" )
type NotableStats ¶ added in v0.3.0
type NotableStats struct {
Tasks int
TasksChecked int
WikiLinks int
WikiEmbeds int
Mentions int
IssueRefs int
CommitRefs int
Emojis int
}
NotableStats aggregates counts of constructs that would be noisy if listed per-instance under a section.
type Paragraph ¶ added in v0.3.0
Paragraph is a block of flowing text. Text is the inline-rendered form (newlines collapsed); Raw preserves the original multi-line source so post-passes (math fences, etc.) can operate on real line boundaries.
type Reference ¶
type Reference struct {
Text string // Link text
Target string // Target file path
Line int // Line number where reference appears
}
Reference represents a link to another markdown file
type Section ¶
type Section struct {
Level int // 1 = #, 2 = ##, etc.
Title string
Content string // raw content (excluding children)
Tokens int // estimated tokens for this section
KeyTerms []string // extracted key concepts
Children []*Section
Parent *Section
LineStart int
LineEnd int
Notables []Node
Stats NotableStats
}
Section represents a heading and the content that follows it up to the next same-or-higher heading.
Notables lists the discoverable block nodes inside this section that an agent might want to jump to directly — callouts, tables, code blocks, math blocks, HTML blocks, footnote definitions, definition lists. It is populated one-per-instance so the renderer can print each as its own line.
Stats aggregates counts of things that would be noisy per-instance (task list items, Obsidian wiki links, Obsidian embeds). They are rendered as a single summary line per section.
type Table ¶ added in v0.3.0
type Table struct {
BaseNode
Headers []string
Aligns []TableAlign
}
Table is a GFM table.
type TableAlign ¶ added in v0.3.0
type TableAlign string
TableAlign specifies a column's alignment in a GFM table.
const ( AlignNone TableAlign = "" AlignLeft TableAlign = "left" AlignCenter TableAlign = "center" AlignRight TableAlign = "right" )
type TableCell ¶ added in v0.3.0
type TableCell struct {
BaseNode
Align TableAlign
}
TableCell is one cell within a row.
type ThematicBreak ¶ added in v0.3.0
type ThematicBreak struct {
BaseNode
}
ThematicBreak is --- / *** / ___.