Skip to content

In the highlighter, add include/extends navigation points#65

Merged
mworrell merged 3 commits intomasterfrom
highlight-nav-point
Mar 25, 2026
Merged

In the highlighter, add include/extends navigation points#65
mworrell merged 3 commits intomasterfrom
highlight-nav-point

Conversation

@mworrell
Copy link
Copy Markdown
Member

This pull request enhances the template compiler's syntax highlighting by adding support for navigation anchors in the rendered HTML. These anchors enable more advanced navigation features in the UI, such as jumping to include, extends, and related template directives. The changes primarily introduce a new navigation event system that tracks and renders navigation points alongside existing debug and annotation features.

Navigation anchor support:

  • Added a build_nav_events/2 function to extract navigation-relevant tokens (like include, extends, etc.) from the raw token stream and associate them with their source positions.
  • Introduced build_nav_event_map/2 to convert navigation events into a map keyed by file offsets, enabling efficient lookup and rendering.
  • Implemented the nav_anchor/2 function to generate HTML <span> elements with data attributes for navigation anchors, including type, line, and column information.

Integration into rendering pipeline:

  • Modified highlight_binary/3 and render_document/5 to compute and pass navigation events through the rendering process, ensuring anchors are included in the output. [1] [2]
  • Updated build_events/4, emit_at/2, and relevant_positions/3 to handle navigation anchors alongside existing annotation and debug events, ensuring correct placement in the rendered HTML. [1] [2]

Copilot AI review requested due to automatic review settings March 25, 2026 11:25
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances template_compiler_highlight HTML output by adding navigation anchor spans for template directives (e.g. include, extends, overrules) and wiring those anchors through the existing event/render pipeline so UI code can jump to directive locations.

Changes:

  • Extend the highlight rendering pipeline to compute and render navigation events alongside existing annotation and debug-point events.
  • Add navigation event extraction (build_nav_events/2) and offset-keyed lookup (build_nav_event_map/2) for efficient insertion during rendering.
  • Emit navigation anchor HTML spans (nav_anchor/2) with type/line/column metadata.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mworrell mworrell merged commit ab0e7a0 into master Mar 25, 2026
7 checks passed
@mworrell mworrell deleted the highlight-nav-point branch March 25, 2026 11:53
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.

2 participants