Skip to content

feat: add hierarchy levels for custom anchor nesting#240

Open
vmikk wants to merge 6 commits intoStarlaneStudios:masterfrom
vmikk:hierarchy_levels
Open

feat: add hierarchy levels for custom anchor nesting#240
vmikk wants to merge 6 commits intoStarlaneStudios:masterfrom
vmikk:hierarchy_levels

Conversation

@vmikk
Copy link

@vmikk vmikk commented Jan 16, 2026

This PR adds support for explicit hierarchy levels in anchor tags, allowing users to create structured TOC-like hierarchies. Previously, only region tags (like SECTION) supported hierarchical nesting through their start/end pairs. Non-region anchors could only exist at the root level, which make impossible to create multi-level TOC structures with custom tags.

To specify hierarchy level for a particular anchor, user should add hierarchyLevel property to tag configuration. By default, non-region tags have hierarchyLevel of 1, and region tags maintain existing behavior.

Configuration example:

{
  "commentAnchors.tags.anchors": {
    "L1": {
      "scope": "workspace",
      "highlightColor": "#FF6B6B", 
      "behavior": "anchor",
      "hierarchyLevel": 1
    },
    "L2": {
      "scope": "workspace",
      "highlightColor": "#4ECDC4",
      "behavior": "anchor", 
      "hierarchyLevel": 2
    },
}

Test data:

// L1 First level header
function someFunction() {
    // L2 Nested under L1
    // L2 Another item under L1

}

// L1 Another first level header  
function anotherFunction() {
    // L2 Item under second L1
    // L2 Something nested
}

Which should results into:
Hierarchy level example screenshot

No breaking changes were made to existing API or behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant