Skip to content

Restore syntax highlighting in playground editors - #91

Merged
mrjf merged 4 commits into
mainfrom
copilot/restore-syntax-highlighting
Apr 12, 2026
Merged

Restore syntax highlighting in playground editors#91
mrjf merged 4 commits into
mainfrom
copilot/restore-syntax-highlighting

Conversation

Copilot AI commented Apr 10, 2026

Copy link
Copy Markdown
Contributor

Playground code editors lost syntax coloring. This adds a lightweight regex-based TypeScript tokenizer using the transparent-textarea overlay technique — no external dependencies.

Changes

  • playground/playground-runtime.js
    • highlightCode() — single-pass regex tokenizer for keywords, strings, comments, numbers, literals
    • Overlay technique: highlighted <pre> behind a transparent <textarea> (caret stays visible via caret-color)
    • injectHighlightStyles() — dynamic CSS injection so all pages get highlighting with zero per-page changes
    • Contenteditable <pre> editors auto-converted to <textarea> for consistency
    • Scroll sync between textarea and highlight overlay
  • docs/playground.md — removed syntax highlighting from Non-Goals

Color scheme (GitHub Dark)

Token Color
Keywords (import, const, new, …) #ff7b72
Strings #a5d6ff
Comments #8b949e italic
Numbers / literals #79c0ff

Screenshot

Syntax highlighting in the Series playground

Known limitation

Template literals with ${expr} are highlighted as a single string token. Acceptable for tutorial code.

Copilot AI and others added 2 commits April 10, 2026 16:00
Implements a lightweight regex-based TypeScript tokenizer in
playground-runtime.js that highlights keywords, strings, comments,
numbers, and literal values using the transparent-textarea overlay
technique. Contenteditable pre editors are normalized to textareas
for consistent behavior. Highlight styles are injected dynamically
so all playground pages get syntax coloring automatically.

Agent-Logs-Url: https://github.com/githubnext/tsessebe/sessions/8acf129f-eb1b-4d7f-858c-d6e0399628fc

Co-authored-by: mrjf <180956+mrjf@users.noreply.github.com>
Copilot AI changed the title [WIP] Restore syntax highlighting in the pages doc site playground Restore syntax highlighting in playground editors Apr 10, 2026
Copilot AI requested a review from mrjf April 10, 2026 16:05
Copilot finished work on behalf of mrjf April 10, 2026 16:05
@mrjf
mrjf marked this pull request as ready for review April 10, 2026 17:07
@github-actions

Copy link
Copy Markdown
Contributor

Warning

The push_to_pull_request_branch operation failed: Failed to apply patch. The code changes were not applied.

🤖 Evergreen fix applied

Resolved merge conflict in playground/playground-runtime.js by combining both sides:

  • Kept from this PR: textarea normalization, syntax highlight overlay (syncHighlight/syncScroll, highlightCode)
  • Kept from main: Python tab setup (tab bar, tab switching, pythonView), startTime timing in run handler
  • On reset: calls both syncHighlight() and clears timingEl

All three conflict regions resolved cleanly; JS syntax verified with node --check.

Generated by Evergreen — PR Health Keeper · ● 1.8M ·

@mrjf

mrjf commented Apr 10, 2026

Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts in this pull request

…x-highlighting

# Conflicts:
#	playground/playground-runtime.js

Co-authored-by: mrjf <180956+mrjf@users.noreply.github.com>

Copilot AI commented Apr 10, 2026

Copy link
Copy Markdown
Contributor Author

@copilot resolve the merge conflicts in this pull request

Resolved the merge conflicts in playground/playground-runtime.js in commit aecb439. The three conflicts were between our syntax highlighting code and main's new Python tab + timing features — all integrated cleanly. Tab switching now hides/shows the wrapper div (not just the editor) so the highlight overlay toggles correctly with Python tabs.

Copilot finished work on behalf of mrjf April 10, 2026 17:40
@mrjf
mrjf merged commit 09f29f3 into main Apr 12, 2026
3 checks passed
@mrjf
mrjf deleted the copilot/restore-syntax-highlighting branch April 12, 2026 11:34
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.

Syntax highlighting in the pages doc site playground is gone

2 participants