Documentation
¶
Overview ¶
Package insert places formatted entries into context file content at the correct position based on entry type and section headers.
Index ¶
- func AfterHeader(content, entry, header string) []byte
- func AppendAtEnd(content, entry string) []byte
- func AppendEntry(existing []byte, entry string, fileType string, section string) []byte
- func Decision(content, entry, header string) []byte
- func ExistsInsideHTMLComment(content string, idx int) bool
- func Learning(content, entry string) []byte
- func Task(entry, existingStr, section string) []byte
- func TaskAfterSection(entry, content, section string) []byte
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AfterHeader ¶
AfterHeader finds a header line and inserts content after it.
Skips blank lines and HTML comment blocks (<!-- ... -->) between the header and the insertion point, so new entries land after index tables, format guides, and other comment-wrapped metadata. Falls back to appending at the end if the header is not found.
Parameters:
- content: Existing file content
- entry: Formatted entry to insert
- header: Header line to find (e.g., "# Learnings")
Returns:
- []byte: Modified content with entry inserted
func AppendAtEnd ¶
AppendAtEnd appends an entry at the end of content.
Ensures proper newline separation between existing content and the new entry.
Parameters:
- content: Existing file content
- entry: Formatted entry to append
Returns:
- []byte: Content with entry appended
func AppendEntry ¶
AppendEntry inserts a formatted entry into existing file content.
For tasks, inserts after the target section header. For decisions and learnings, inserts before existing entries (reverse-chronological order). For conventions, appends to the end of the file.
Parameters:
- existing: Current file content as bytes
- entry: Pre-formatted entry text to insert
- fileType: AppendEntry type (e.g., "task", "decision", "learning", "convention")
- section: Target section header for tasks; defaults to "## Next Up" if empty; a "## " prefix is added automatically if missing
Returns:
- []byte: Modified file content with the entry inserted
func Decision ¶
Decision inserts a decision entry before existing entries.
Finds the first "## [" marker that is NOT inside an HTML comment block and inserts before it, maintaining reverse-chronological order. Falls back to AfterHeader if no real entries exist yet.
Parameters:
- content: Existing file content
- entry: Formatted entry to insert
- header: Header line to insert after (e.g., "# Decisions")
Returns:
- []byte: Modified content with entry inserted
func ExistsInsideHTMLComment ¶
ExistsInsideHTMLComment reports whether the position idx in content falls inside an HTML comment block (<!-- ... -->).
Parameters:
- content: String to check
- idx: Position to test
Returns:
- bool: True if idx is between a <!-- and its closing -->
func Learning ¶
Learning inserts a learning entry before existing entries.
Finds the first "## [" marker that is NOT inside an HTML comment block and inserts before it, maintaining reverse-chronological order. Falls back to AfterHeader if no real entries exist yet.
Parameters:
- content: Existing file content
- entry: Formatted entry to insert
Returns:
- []byte: Modified content with entry inserted
func Task ¶
Task inserts a task entry into TASKS.md.
When section is explicitly provided, inserts after that section header. When section is empty (default), finds the first unchecked task and inserts before it, so the new task lands among existing pending work. Falls back to appending at the end if neither is found.
Parameters:
- entry: Formatted task entry to insert
- existingStr: Existing file content
- section: Explicit section name, or empty for auto-placement
Returns:
- []byte: Modified content with task inserted
func TaskAfterSection ¶
TaskAfterSection inserts a task after a named section header.
Normalizes the section name to a Markdown heading, finds it in the content, and inserts the entry immediately after. Falls back to appending at the end if the header is not found.
Parameters:
- entry: Formatted task entry to insert
- content: Existing file content
- section: Section name (e.g., "Phase 1", "Maintenance")
Returns:
- []byte: Modified content with task inserted
Types ¶
This section is empty.