MIRROR: javascript for ๐Ÿœ's, a tiny runtime with big ambitions
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

multi-line highlighter comment parsing

+40 -8
+8 -5
AGENTS.md
··· 18 18 19 19 ## Fast Path 20 20 21 + - Start here for most changes: `maid preflight` 21 22 - Build from an existing configured tree: `meson compile -C build` 22 23 - Fresh local setup: `maid setup` 23 24 - Run a focused test file: `./build/ant tests/test_<name>.cjs` 24 25 - Run the spec suite: `./build/ant examples/spec/run.js` 25 - - Validate repo knowledge docs: `maid knowledge` 26 - - Validate changed-file boundaries: `maid structure` 27 - - Route the current diff to the right checks: `maid validate_changes` 26 + - Run the individual harness steps when needed: 27 + `maid validate_changes`, `maid structure`, `maid knowledge` 28 28 29 29 ## Codebase Map 30 30 ··· 48 48 ## Change Rules 49 49 50 50 - Prefer changes in `src/`, `include/`, `meson/`, `tests/`, `tools/`, and `.github/agents/`. 51 - - Treat `vendor/`, `build/ as generated or third-party surfaces. 52 - Only edit them when the task explicitly requires it. 51 + - Treat `vendor/` and `build/` as generated or third-party surfaces. Only edit 52 + them when the task explicitly requires it. 53 53 - Keep durable design notes and execution history in versioned markdown under 54 54 `docs/`. Treat `todo/` as scratch space, not the source of truth. 55 55 - Add or update tests when behavior changes. 56 56 - When touching build or runtime invariants, document the reasoning in 57 57 [docs/exec-plans/index.md](docs/exec-plans/index.md) or a linked plan if the 58 58 work spans multiple steps. 59 + - Before finalizing most code changes, run `maid preflight` and then execute any 60 + additional build or spec commands it recommends, or explain why they were not 61 + run. 59 62 60 63 ## Which Doc To Open Next 61 64
+12
examples/demo/highlight.js
··· 1 1 const hl = Ant.highlight; 2 2 const render = hl.render; 3 3 4 + function assertEq(actual, expected, label) { 5 + if (actual !== expected) throw new Error(`${label}: expected ${JSON.stringify(expected)} got ${JSON.stringify(actual)}`); 6 + } 7 + 4 8 console.log(render('<red>Red text</red> and back to normal')); 5 9 console.log(render('<green>Green</green>, <blue>Blue</blue>, <yellow>Yellow</yellow>')); 6 10 ··· 34 38 }`; 35 39 36 40 console.log(hl(code)); 41 + 42 + const lineComment = hl.tags('//hello\nworld'); 43 + assertEq(lineComment, '<#758CA3>//hello</>\nworld', 'line comment stops at newline'); 44 + 45 + const blockComment = hl.tags('/*hello\nworld'); 46 + assertEq(blockComment, '<#758CA3>/*hello\nworld</>', 'block comment continues across newline'); 47 + 48 + console.log('highlight comment specs ok');
+1 -1
maidfile.toml
··· 23 23 [tasks.run] 24 24 script = ["maid build -q", "./build/ant %{arg.1}"] 25 25 26 - [tasks.check] 26 + [tasks.preflight] 27 27 script = "ant .github/agents/check_all.js" 28 28 29 29 [tasks.knowledge]
+8 -2
src/highlight/iter.c
··· 333 333 return is_likely_function_param_paren(input, input_len, open_paren, close_paren); 334 334 } 335 335 336 + static inline bool is_line_comment_terminator(unsigned char c) { 337 + return c == '\n' || c == '\r'; 338 + } 339 + 336 340 bool hl_iter_next(hl_iter *it, hl_span *out) { 337 341 const char *input = it->input; 338 342 size_t input_len = it->input_len; ··· 421 425 422 426 if (c == '/' && i + 1 < input_len && input[i + 1] == '/') { 423 427 it->ctx = HL_CTX_NONE; 424 - *out = (hl_span){ i, input_len - i, HL_COMMENT }; 425 - it->pos = input_len; 428 + size_t start = i; i += 2; 429 + while (i < input_len && !is_line_comment_terminator((unsigned char)input[i])) i++; 430 + *out = (hl_span){ start, i - start, HL_COMMENT }; 431 + it->pos = i; 426 432 return true; 427 433 } 428 434
+11
tests/test_highlight_comments.cjs
··· 1 + function assertEq(actual, expected, label) { 2 + if (actual !== expected) throw new Error(`${label}: expected ${JSON.stringify(expected)} got ${JSON.stringify(actual)}`); 3 + } 4 + 5 + const lineComment = Ant.highlight.tags('//hello\nworld'); 6 + assertEq(lineComment, '<#758CA3>//hello</>\nworld', 'line comment stops at newline'); 7 + 8 + const blockComment = Ant.highlight.tags('/*hello\nworld'); 9 + assertEq(blockComment, '<#758CA3>/*hello\nworld</>', 'block comment continues across newline'); 10 + 11 + console.log('ok');