feat(editor): highlight Protocol Buffers in code blocks #841

Merged
raisondetredev merged 1 commit from refs/pull/841/head into main 2026-08-25 07:33:04 +02:00
raisondetredev commented 2026-08-25 07:32:48 +02:00 (Migrated from codeberg.org)

The gRPC deck is 336 cards about a contract-first protocol, and the
contract is always a .proto file. Thirteen of its code blocks hold one,
and every chapter's explanation hangs off the service or message
definition beside it — but protobuf was in neither _grammars nor
kCodeBlockLanguages, so those blocks rendered as unstyled monospace and
the block language menu offered no way to tag them as anything but
text. A field number is easy to lose in grey when it is the whole point
of the line.

The grammar already ships in highlight, so this is one import, one map
entry, and one row in each of the two menu lists — the same three
touchpoints as #840, in the same relative position: beside sql, ahead
of the data formats, since a .proto file is a schema rather than a
general-purpose language.

It is also the cheapest grammar added so far. protobuf.dart is 978
bytes of rule set, against the 31 KB the four Apple-platform and
build-file grammars cost in #840 — the language has a dozen keywords and
no expression syntax to speak of.

code_highlighting_test.dart gains the round-trip check the group
already applies to every other newly registered grammar: the coloured
runs must rejoin to the source character for character, and at least one
must carry a colour, so a silent fallback to plain text fails rather than
passing as "rendered". The fixture is a service with a unary and a
server-streaming method plus a message with numbered and repeated
fields, which is the shape most of the deck's blocks take.

The notebook's own registry in code_editor_config.dart stays untouched,
as with the last batch: those languages are the ones Judge0 can execute,
and there is nothing to execute in an IDL.

The gRPC deck is 336 cards about a contract-first protocol, and the contract is always a `.proto` file. Thirteen of its code blocks hold one, and every chapter's explanation hangs off the service or message definition beside it — but `protobuf` was in neither `_grammars` nor `kCodeBlockLanguages`, so those blocks rendered as unstyled monospace and the block language menu offered no way to tag them as anything but `text`. A field number is easy to lose in grey when it is the whole point of the line. The grammar already ships in `highlight`, so this is one import, one map entry, and one row in each of the two menu lists — the same three touchpoints as #840, in the same relative position: beside `sql`, ahead of the data formats, since a `.proto` file is a schema rather than a general-purpose language. It is also the cheapest grammar added so far. `protobuf.dart` is 978 bytes of rule set, against the 31 KB the four Apple-platform and build-file grammars cost in #840 — the language has a dozen keywords and no expression syntax to speak of. `code_highlighting_test.dart` gains the round-trip check the group already applies to every other newly registered grammar: the coloured runs must rejoin to the source character for character, and at least one must carry a colour, so a silent fallback to plain text fails rather than passing as "rendered". The fixture is a service with a unary and a server-streaming method plus a message with numbered and `repeated` fields, which is the shape most of the deck's blocks take. The notebook's own registry in `code_editor_config.dart` stays untouched, as with the last batch: those languages are the ones Judge0 can execute, and there is nothing to execute in an IDL.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
project-halkyon/halkyon-learn!841
No description provided.