Skip to content

feat(code-snippets): add syntax-highlighted reveal and token morph animations - #1

Merged
MemerGamer merged 3 commits into
mainfrom
code-snippets
Nov 16, 2026
Merged

MemerGamer merged 3 commits into
mainfrom
code-snippets

Conversation

@MemerGamer

@MemerGamer MemerGamer commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Code Snippets adds a community clip-source plugin for animated code in AniMathIO 2: syntax coloring for Rust, Python, JavaScript, TypeScript, C/C++, JSON, TeX and Bash; three dark/light themes; line numbers and line emphasis; a padded rounded panel; and a keyframable progress for character/line reveal or token morphing.

This is a behavioral port of Anthony Fu's Shiki Magic Move (MIT), studied at v1.1.0: matching tokens move, removed and entering tokens fade in overlapping windows. The Rust implementation uses bounded token LCS with integer comparisons and one-to-one moved-token matching. No upstream animation code or external grammar is copied. README and NOTICE credit the project and retain its license. Unmodified JetBrains Mono 2.304 is embedded because ABI 1.1's host text import only offers DejaVu Sans; the font's OFL 1.1 license is included in both source and bundle.

Syntect uses the pure Rust fancy-regex backend and nine small original lexical grammars compiled into a dump at build time. Each render derives its scene solely from evaluated params; glyph caches live only within that call. The bundle is 795,124 bytes (777 KiB), with a 2,396,212-byte component. No capabilities or host services are requested. CI builds/tests the plugin alongside the examples, runs the released-host test, and uploads the bundles. The community table links its source and CI.

Validation completed locally:

  • cargo fmt --all --check, native cargo clippy --workspace --all-targets --locked -- -D warnings, WASI clippy, and cargo test --workspace --locked for the standalone plugin workspace: nine unit tests and one generated binding doctest pass.
  • wasm32-wasip2 release build and .amplugin packaging.
  • Downloaded the released AniMathIO 2.1.0 AppImage, verified SHA-256 cce18dd8215aa9c23ba7c5756e6c0785c1931dd027aadf31a7bbbf3b92fac6ec, extracted it with --appimage-extract, and confirmed animathio-cli 2.1.0.
  • smoke.py: reveal and morph at 0/25/50/75/100%, exact endpoints, repeated calls, actual examples in every language, themes/line selection/no-panel variants, and a host-sampled typed progress keyframe at 0.5 seconds. A 256-token-per-side morph and 1,024-character comment also pass with the default sandbox limits. The smoke rejects error placeholder pixels even when the CLI exits successfully.
  • Opened and visually inspected all ten README PNGs; regenerated and inspected the final morph midpoint and completed code after the optimizations. Screenshots: community/code-snippets/screenshots/{reveal,morph}-{000,025,050,075,100}.png.
  • Existing circle and invert native test targets pass; workflow YAML parses; vendored WIT matches the template byte-for-byte; package notices checked; diff/implementation self-review completed.

V1 limits are explicit: lexical highlighting rather than full language parsing (e.g. nested Rust block comments, JS interpolation and shell heredocs are deferred), one cell per Unicode scalar, 1,024 characters / 256 tokens / 80 lines per snippet, and no custom fonts/themes, selection rectangles or multi-step transitions. GUI interaction was not tested; all host checks used the headless released CLI with audio disabled. No desktop windows or audio devices were opened. This PR must not be merged as part of this task.

Review correction: exits fade across 0–60%, retained tokens ease across 15–85%, and entries fade across 40–100%. Read upstream 1.1.0 renderer/CSS defaults (500 ms, stagger 0, full-duration overlapping transitions); README documents the normalized adaptation. All identical token text, including short identifiers and punctuation outside the LCS, is now paired one-to-one. Midpoint alpha and short-token coverage regressions pass. Rust keyword scopes already yield Ocean purple for fn/let/mut/for/in; explicit regression coverage and visually checked endpoint confirm this. Nothing further deferred by this correction.

@MemerGamer

Copy link
Copy Markdown
Member Author

Review (Claude, orchestrator): MERGE after CI. Looked at the re-rendered morph frames (25/50/75/100%): phases now overlap like Shiki Magic Move, matched tokens move instead of fading, no empty mid-frame; reveal frames fine. Licenses: Shiki Magic Move (MIT, behaviour port, credited), JetBrains Mono (OFL, included), syntect (MIT, included). Package 776 KiB.

@MemerGamer
MemerGamer merged commit 596a21e into main Nov 16, 2026
1 check passed
@MemerGamer
MemerGamer deleted the code-snippets branch November 16, 2026 21:07
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