Handoff — 2026-08-31 — Markdown, JavaScript, HTML and shell colouring
State
Tickets 0009, 0013 and 0014 are done and green, on branch feature/new-syntaxes, uncommitted. Shell was asked for in the same breath and has no ticket.
The editor now colours six languages. Recognition is by extension, falling back to a shebang for a shell script with no extension.
- New scanners:
markdown.go+markdown_inline.go,javascript.go,html.go,bash.go. A sharedscanner.goholdslineScanner,scanLinesand the helpers; the TOML scanner was ported onto it and its 24 tests stayed green throughout. - Five new classes and theme keys —
heading,tag,attribute,emphasis,link— set in all three shipped themes. internal/syntaxat 96.0 % with 180 tests. Whole suite green under-race. Quality gate PASS after one round: 0/0/0, complexity 1389.- Docs: a new
reference/languages.mdper language stating each scanner's exact boundary, plus a rewritten section inexplanation/colouring-and-completion.md. - Verified in a real terminal for all four new languages by rendering the editor through the project's own VT emulator and reading back each run's foreground colour.
Earlier the same day, PR #4 merged the project tree.
In flight
Nothing. Finished through Phase 8.
Next steps
- Commit and open the PR.
feature/new-syntaxesis the branch. - Look at a long real file in each language. The verification used four short files. A 500-line HTML page or a big shell script is where a scanner that is quadratic or that mis-carries state would show.
- Tickets. 0002, 0003, 0007, 0009, 0013 and 0014 are all implemented and all still
state: open.
Open questions / blockers
- The stated omissions are choices, not gaps, and each is documented in
docs/*/reference/languages.md: JavaScript regex literals, shell heredocs, JavaScript inside<script>, and the language of a Markdown fence. Any of them can be added later; all four need something the current design deliberately lacks — either a token of look-behind, or one scanner reaching into another. - Third-party themes lose the five new keys. They fall back to
default, so Markdown is readable but its headings, emphasis and links are not distinct. Nothing warns about it. If that matters, a "theme is missing keys" report would be a small feature. - CSS is not coloured, and
<style>therefore looks like text. It was not asked for; it would be the natural seventh.
Watch out for
emitdrops empty spans, so never derive a span's start from the scanner's position after a helper has moved it. This has now bitten twice, in different shapes: the TOML scanner patchedspans[len-1].Startand corrupted the previous span;finishTemplatecalledrunToBacktick, which ran the position to the end of the line, and then askedtakeRestto colour what was left — nothing. Pass the start in as a parameter.takeTemplateFromandfinishMultilineFromare the shapes to copy.- The theme completeness test only constrains
turbo-classic.turbo-darkandborland-lightboth inherit from it, and inheritance is resolved at parse time into the theme's own map, soDefinesreturns true for an inherited key. I removedsyntax.headingfromturbo-darkto check the test bit, and it passed. Delete the key fromturbo-classicto actually test it. - Colour clashes are invisible to the test suite.
syntax.linkwas set to the same lime assyntax.stringinturbo-classic, making a Markdown link identical to an inlinecodespan. Everything passed. Render the editor throughinternal/terminaland read back the foreground of each run — the throwaway program under/tmp/render/main.goin that session did it, and rebuilding it is a few minutes. - A hyphen must be able to start a word in shell, or every
-euois a minus followed by a command.startsAnOptionhandles it; a "simplification" that drops it breaks every script. - Test names collide across scanner files.
TestAnUnterminatedStringIsColouredToTheEndOfTheLineandTestABackslashDoesNotEscapeInALiteralStringboth existed for TOML already. Prefix new ones with the language. splitLinestrims a trailing\r, so a CRLF file colours the same as an LF one. Do not replace it withstrings.Split(src, "\n").
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
|