feat(editor): highlight Swift, Objective-C, Ruby, and Groovy in code blocks #840
No reviewers
Labels
No labels
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority/Critical
Priority/High
Priority/Low
Priority/Medium
Reviewed/Confirmed
Reviewed/Duplicate
Reviewed/Invalid
Reviewed/Won't Fix
Status/Abandoned
Status/Blocked
Status/Need More Info
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
project-halkyon/halkyon-learn!840
Loading…
Reference in a new issue
No description provided.
Delete branch "refs/pull/840/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The block language menu offered nineteen tags and no way to colour Apple
platform code. A card holding a Swift snippet had to be tagged
swiftanyway — the renderer keeps an unknown tag and falls back to unstyled
monospace — so the block rendered grey and the menu labelled it with the
bare lowercase tag, since
kCodeBlockLanguageNameshad no entry either.That became visible with the Rust / Kotlin+Android / Swift+iOS decks:
385 of their 440 Swift and Objective-C blocks rendered as plain text,
while the Rust and Kotlin ones beside them coloured normally.
All four grammars already ship in
highlight, so this is imports plusmap entries. Ruby and Groovy come along because the same decks quote
podspecs and Gradle Groovy build files, which had been falling back to
textfor the same reason.Placement keeps every existing entry in its current relative order and
puts each new one next to its nearest relative — Ruby by Python, Groovy
by Java, Swift by Kotlin, Objective-C ahead of C. The two lists and the
grammar map stay in the lockstep the component test already asserts.
The cost is bundle weight, as the header in
code_highlighting.dartnotes: 31 KB of additional grammar source, against 102 KB already
imported.
code_highlighting_test.dartgains a round-trip check per grammar.highlightedCodeSpansilently returns plain text when a grammar drops orduplicates a character, and a silent fallback is indistinguishable from
the grey rendering this commit removes — so each test asserts both that
the runs rejoin to the source exactly and that at least one run is
coloured. Unregistering a grammar fails them.
The notebook keeps its own smaller registry in
code_editor_config.dart,deliberately untouched: those languages are the ones Judge0 can execute,
and a notebook cell cannot run Swift.
Signed-off-by: Tizian 「ティツィアーン」 raisondetredev@pm.me