Skip to content

Conversation

Copy link

Copilot AI commented Oct 17, 2025

Overview

This PR adds YAML frontmatter syntax highlighting support to .sudo.md files, bringing them to parity with standard .md files in VSCode.

Problem

Previously, YAML frontmatter in .sudo.md files was rendered as plain text without any syntax highlighting, making it difficult to distinguish between keys, values, and different data types:

Before: No syntax highlighting

In contrast, standard .md files have proper YAML frontmatter highlighting:

Expected: Proper syntax highlighting

Solution

Added frontmatter support to the TextMate grammar by:

  1. Creating a new frontmatter pattern that matches YAML blocks delimited by --- at the beginning of files
  2. Embedding VSCode's built-in source.yaml grammar for consistent YAML syntax highlighting
  3. Positioning the pattern as the first in the grammar to ensure it captures frontmatter before other patterns

Technical Implementation

The frontmatter pattern:

  • Uses \A anchor to match only at the very beginning of the file
  • Ends at the next --- or ... delimiter on its own line
  • Delegates syntax highlighting to source.yaml for consistency with standard markdown files

This ensures that:

  • Keys (e.g., number:, status:) display in blue
  • Literals (e.g., 3, true, false) display in green
  • Quoted strings (e.g., "blocked") display in brown/orange
  • Delimiters (---) display as punctuation

Example

---
number: 3
status: "blocked"
tags:
  - documentation
  - feature
enabled: true
---

# My SudoLang Program

...

All YAML elements in the frontmatter now have proper syntax highlighting matching standard markdown behavior.

Testing

  • ✅ Grammar validates as valid JSON
  • ✅ Extension compiles successfully
  • ✅ Extension packages successfully
  • ✅ All existing patterns preserved and functional
  • ✅ Frontmatter pattern correctly positioned to match from file start

Fixes issue regarding frontmatter YAML syntax highlighting in .sudo.md files.

Original prompt

This section details on the original issue you should resolve

<issue_title>[VSCode] Frontmatter yaml</issue_title>
<issue_description>I'd like to have the same frontmatter support as original markdown files:

With standard .md files

Image

With .sudo.md files

Image</issue_description>

<agent_instructions>Can we get frontmatter to syntax highlight like standard .md file syntax highlights?

e.g.

key: value
key2: "quoted value"

  • Keys typically display in blue in VS Code by default, I believe
  • Literal values in green
  • Quoted values in brown

Of course we don't assign literal colors to these things, but each of these things gets a different role which allows the syntax highlighter to differentiate them.</agent_instructions>

Comments on the Issue (you are @copilot in this section)

Fixes #37


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits October 17, 2025 00:25
Co-authored-by: ericelliott <364727+ericelliott@users.noreply.github.com>
Co-authored-by: ericelliott <364727+ericelliott@users.noreply.github.com>
Co-authored-by: ericelliott <364727+ericelliott@users.noreply.github.com>
Copilot AI changed the title [WIP] Add frontmatter yaml support for .sudo.md files Add YAML frontmatter syntax highlighting for .sudo.md files Oct 17, 2025
Copilot AI requested a review from ericelliott October 17, 2025 00:30
Copilot finished work on behalf of ericelliott October 17, 2025 00:30
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.

[VSCode] Frontmatter yaml

2 participants