Skip to content

Conversation

@Yukaii
Copy link
Contributor

@Yukaii Yukaii commented Aug 23, 2025

スクリーンショット 2025-08-23 夕方4 37 39 スクリーンショット 2025-08-23 夕方4 37 54

Summary by cubic

Adds syntax highlighting for code blocks via a simple codeHighlighter API. This enables real-time, library-agnostic highlighting with examples for Shiki and highlight.js.

  • New Features
    • New codeHighlighter API: set globally (OverType.setCodeHighlighter(fn)) or per instance (codeHighlighter option).
    • Real-time highlighting for fenced code blocks while preserving character alignment.
    • Examples: shiki-integration.html and highlightjs-integration.html.
    • Docs: SYNTAX_HIGHLIGHTING.md with setup and usage.

@MathiasWP
Copy link
Contributor

+1 on this!

@vuthanhtrung2010
Copy link

+1

WebsByTodd added a commit to diffplug/gitcasso that referenced this pull request Sep 4, 2025
Yukaii and others added 3 commits September 8, 2025 16:59
- Merge latest changes from main into feature/support-codeblock-syntax-highlighting
- Preserve both code highlighting functionality and clean HTML export features
- Keep indentation handling improvements from main branch
- Maintain backwards compatibility for all existing features

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Resolved conflict in src/parser.js by adopting the newer sanctuary-based
approach for parsing inline elements from main branch.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@jippi
Copy link

jippi commented Oct 5, 2025

Any plans to land this? ❤️

@panphora
Copy link
Owner

panphora commented Nov 6, 2025

Syntax highlighting is now available in v2.0.1! 🎨

We've implemented a library-agnostic approach that works with Shiki, Highlight.js, Prism, or any custom highlighter:

// Global highlighter
OverType.setCodeHighlighter((code, language) => {
  return highlighter.highlight(code, { language }).value;
});

// Or per-instance
new OverType('#editor', {
  codeHighlighter: myHighlighter
});

Key features:

  • Synchronous highlighters only (Shiki works if you await setup first, then use the highlighter object synchronously)
  • Character-by-character alignment verified with comprehensive tests
  • All three major libraries (Shiki, Highlight.js, Prism) tested and confirmed working
  • See docs/SYNTAX_HIGHLIGHTING.md and examples in website/examples/

Thanks for the initial implementation! We built on your foundation and added alignment verification to ensure OverType's core cursor alignment remains perfect.

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.

5 participants