buninu 0.5.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +47 -0
- package/apps/jsgotty/LICENSES/MIT-jsmdcui.txt +22 -0
- package/apps/jsgotty/NOTICE +5 -0
- package/apps/jsgotty/README.en.md +21 -0
- package/apps/jsgotty/README.md +21 -0
- package/apps/jsgotty/client-modes.mjs +117 -0
- package/apps/jsgotty/client.mjs +100 -10
- package/apps/jsgotty/clipboard-powershell.js +18 -0
- package/apps/jsgotty/clipboard.js +148 -0
- package/apps/jsgotty/gotty.js +13 -0
- package/apps/jsgotty/package-lock.json +2 -2
- package/apps/jsgotty/package.json +1 -1
- package/apps/jsgotty/static/css/index.css +14 -1
- package/apps/jsgotty/static/js/gotty.js +107 -8
- package/apps/jsgotty/static/js/kitty.js +115 -7
- package/apps/jsgotty/terminal-modes.js +332 -0
- package/apps/jsgotty/tests/client-exit.test.mjs +45 -0
- package/apps/jsgotty/tests/client-modes.test.mjs +105 -0
- package/apps/jsgotty/tests/clipboard-browser.test.js +81 -0
- package/apps/jsgotty/tests/clipboard.test.js +75 -0
- package/apps/jsgotty/tests/manual/zoom-collector.cjs +55 -0
- package/apps/jsgotty/tests/manual/zoom-debug.js +39 -0
- package/apps/jsgotty/tests/manual-touch-diagnostics.js +33 -0
- package/apps/jsgotty/tests/manual-touch-diagnostics.mjs +22 -0
- package/apps/jsgotty/tests/nested-cli-pty.test.mjs +116 -0
- package/apps/jsgotty/tests/reconnect-modes-browser.test.js +144 -0
- package/apps/jsgotty/tests/reconnect-modes.md +44 -0
- package/apps/jsgotty/tests/reconnect-modes.test.js +166 -0
- package/apps/jsgotty/tests/touch-drag-browser.test.js +106 -0
- package/apps/jsgotty/tests/wheel-browser.test.js +60 -0
- package/apps/jsmdcui/CHANGELOG.md +44 -0
- package/apps/jsmdcui/package.json +1 -1
- package/apps/jsmdcui/src/highlight/go-regexp.js +83 -0
- package/apps/jsmdcui/src/highlight/highlighter.js +49 -62
- package/apps/jsmdcui/src/highlight/parser.js +8 -5
- package/apps/jsmdcui/tests/go-regexp.test.js +98 -0
- package/apps/jsmdcui/tests/heading-ids.test.js +21 -16
- package/apps/jsmdcui/tests/highlight-regions.test.js +73 -0
- package/apps/jsmdcui/tests/id-collision.test.js +32 -9
- package/apps/jsmdcui/tests/markdown-behavior.mjs +9 -0
- package/apps/jsmdcui/tests/syntax-parity/NORMAL-HTML.md +46 -0
- package/apps/jsmdcui/tests/syntax-parity/README.md +85 -0
- package/apps/jsmdcui/tests/syntax-parity/REPORT.md +328 -0
- package/apps/jsmdcui/tests/syntax-parity/compare.mjs +75 -0
- package/apps/jsmdcui/tests/syntax-parity/go.mod +5 -0
- package/apps/jsmdcui/tests/syntax-parity/normal-html-report.json +619 -0
- package/apps/jsmdcui/tests/syntax-parity/normal-html.html +9 -0
- package/apps/jsmdcui/tests/syntax-parity/oracle.go +49 -0
- package/apps/jsmdcui/tests/syntax-parity/report.json +2174 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/PowerShell.txt +39 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/ada.txt +25 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/apacheconf.txt +49 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/arduino.txt +38 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/asciidoc.txt +33 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/asm.txt +77 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/ats.txt +48 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/awk.txt +28 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/b.txt +27 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/bat.txt +39 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/c.txt +34 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/caddyfile.txt +14 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/cake.txt +7 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/clojure.txt +18 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/cmake.txt +20 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/coffeescript.txt +32 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/colortest.txt +19 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/conky.txt +12 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/cpp.txt +46 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/crontab.txt +16 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/crystal.txt +28 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/csharp.txt +28 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/css.txt +19 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/csx.txt +7 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/cuda.txt +37 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/cython.txt +22 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/d.txt +52 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/dart.txt +27 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/default.txt +8 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/dockerfile.txt +10 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/dot.txt +15 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/elixir.txt +23 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/elm.txt +20 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/erb.txt +32 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/erlang.txt +23 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/fish.txt +20 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/forth.txt +17 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/fortran.txt +40 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/freebsd-kernel.txt +10 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/fsharp.txt +27 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/gdscript.txt +26 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/gemini.txt +11 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/gentoo-ebuild.txt +28 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/gentoo-etc-portage.txt +14 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/git-commit.txt +19 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/git-config.txt +11 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/git-rebase-todo.txt +10 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/gleam.txt +44 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/glsl.txt +18 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/gnuplot.txt +11 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/go.txt +33 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/godoc.txt +9 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/golo.txt +50 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/gomod.txt +16 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/graphql.txt +20 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/groff.txt +18 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/groovy.txt +42 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/haml.txt +16 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/hare.txt +31 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/haskell.txt +26 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/hc.txt +28 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/html.txt +26 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/html4.txt +20 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/html5.txt +20 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/ini.txt +16 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/inputrc.txt +14 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/java.txt +18 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/javascript.txt +41 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/jinja2.txt +13 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/json.txt +21 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/jsonnet.txt +28 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/julia.txt +24 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/justfile.txt +26 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/keymap.txt +15 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/kickstart.txt +16 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/kotlin.txt +30 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/kvlang.txt +37 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/ledger.txt +13 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/lfe.txt +17 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/lilypond.txt +15 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/lisp.txt +17 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/log.txt +45 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/lua.txt +48 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/mail.txt +17 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/makefile.txt +25 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/man.txt +12 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/markdown.txt +21 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/mc.txt +11 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/meson.txt +29 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/micro.txt +25 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/mpdconf.txt +13 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/msbuild.txt +7 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/nanorc.txt +16 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/nftables.txt +22 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/nginx.txt +17 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/nim.txt +23 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/nix.txt +15 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/nu.txt +92 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/objc.txt +36 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/ocaml.txt +25 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/octave.txt +35 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/odin.txt +35 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/pascal.txt +22 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/patch.txt +13 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/peg.txt +16 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/perl.txt +27 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/php.txt +44 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/pkg-config.txt +12 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/po.txt +12 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/pony.txt +29 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/pov.txt +17 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/privoxy-action.txt +14 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/privoxy-config.txt +10 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/privoxy-filter.txt +12 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/proto.txt +22 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/prql.txt +42 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/puppet.txt +22 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/python2.txt +24 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/python3.txt +28 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/r.txt +16 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/raku.txt +19 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/reST.txt +18 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/renpy.txt +11 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/rpmspec.txt +31 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/ruby.txt +34 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/rust.txt +27 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/sage.txt +24 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/scad.txt +23 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/scala.txt +16 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/sed.txt +12 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/sh.txt +20 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/sls.txt +15 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/smalltalk.txt +28 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/solidity.txt +26 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/sql.txt +35 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/stata.txt +32 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/svelte.txt +10 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/swift.txt +53 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/systemd.txt +15 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/tcl.txt +17 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/terraform.txt +28 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/tex.txt +15 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/toml.txt +31 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/twig.txt +29 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/typescript.txt +32 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/v.txt +47 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/vala.txt +22 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/verilog.txt +37 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/vhdl.txt +37 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/vi.txt +17 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/vue.txt +29 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/xml.txt +14 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/xresources.txt +14 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/yaml.txt +19 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/yum.txt +12 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/zig.txt +24 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/zscript.txt +31 -0
- package/apps/jsmdcui/tests/syntax-parity/samples/zsh.txt +21 -0
- package/package.json +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { expect, test } from "bun:test";
|
|
2
|
+
import { escapesSlashTags } from "./markdown-behavior.mjs";
|
|
2
3
|
import { mkdtemp, rm } from "node:fs/promises";
|
|
3
4
|
import { tmpdir } from "node:os";
|
|
4
5
|
import { join } from "node:path";
|
|
@@ -347,23 +348,27 @@ test("raw heading markers do not change quoted attribute parsing", () => {
|
|
|
347
348
|
expect(rendered.html).toContain('<h1 id="中文-1">中文</h1>');
|
|
348
349
|
});
|
|
349
350
|
|
|
350
|
-
test("raw heading markers
|
|
351
|
-
const markdown =
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
`;
|
|
355
|
-
expect(collectRawHtmlHeadingDeclarations(markdown)).toEqual([
|
|
356
|
-
{
|
|
357
|
-
id: "中文",
|
|
358
|
-
kind: "raw HTML heading",
|
|
359
|
-
line: 1,
|
|
360
|
-
source: "<h1/id=中文>Raw</h1>",
|
|
361
|
-
},
|
|
351
|
+
test("raw heading markers follow Bun's slash-separated HTML behavior", () => {
|
|
352
|
+
const markdown = "<h1/id=中文>Raw</h1>\n\n# 中文\n";
|
|
353
|
+
expect(collectRawHtmlHeadingDeclarations(markdown)).toEqual(escapesSlashTags ? [] : [
|
|
354
|
+
{ id: "中文", kind: "raw HTML heading", line: 1, source: "<h1/id=中文>Raw</h1>" },
|
|
362
355
|
]);
|
|
363
356
|
const rendered = renderMarkdownWithHeadingIds(markdown);
|
|
364
|
-
|
|
365
|
-
expect(rendered.
|
|
366
|
-
expect(rendered.
|
|
357
|
+
const id = escapesSlashTags ? "中文" : "中文-1";
|
|
358
|
+
expect(rendered.normalized).toBe(true);
|
|
359
|
+
expect(rendered.headings.map(heading => heading.id)).toEqual([id]);
|
|
360
|
+
expect(rendered.html).toContain(escapesSlashTags
|
|
361
|
+
? "<p><h1/id=中文>Raw</h1></p>"
|
|
362
|
+
: "<h1/id=中文>Raw</h1>");
|
|
363
|
+
expect(rendered.html).toContain(`<h1 id="${id}">中文</h1>`);
|
|
364
|
+
});
|
|
365
|
+
|
|
366
|
+
test("slash-tag ambiguity follows Bun's actual Markdown output", () => {
|
|
367
|
+
const rendered = renderMarkdownWithHeadingIds('<div/a< x=">TAIL\n\n# 中文\n');
|
|
368
|
+
expect(rendered.normalized).toBe(escapesSlashTags);
|
|
369
|
+
expect(rendered.headings.map(heading => heading.id)).toEqual(escapesSlashTags ? ["中文"] : []);
|
|
370
|
+
expect(rendered.html).toContain(escapesSlashTags
|
|
371
|
+
? '<h1 id="中文">中文</h1>' : '<h1 id="">中文</h1>');
|
|
367
372
|
});
|
|
368
373
|
|
|
369
374
|
test("self-closing inline headings cannot suppress other raw collisions", () => {
|
|
@@ -511,7 +516,7 @@ test("quoted tag delimiters preserve raw IDs and Markdown heading metadata", ()
|
|
|
511
516
|
});
|
|
512
517
|
|
|
513
518
|
test("browser alignment failures never fall back to lexical heading rewrites", () => {
|
|
514
|
-
const markdown = '<div
|
|
519
|
+
const markdown = '<div x=">TAIL\n\n# 中文\n';
|
|
515
520
|
const rendered = renderMarkdownWithHeadingIds(markdown);
|
|
516
521
|
expect(rendered.normalized).toBe(false);
|
|
517
522
|
expect(rendered.headings).toEqual([]);
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import {test,expect} from 'bun:test';
|
|
2
|
+
import {SyntaxDefinition,parseHeaderYaml} from '../src/highlight/parser.js';
|
|
3
|
+
import {Highlighter} from '../src/highlight/highlighter.js';
|
|
4
|
+
async function highlighter(name){
|
|
5
|
+
const source=Bun.YAML.parse(await Bun.file(new URL('../runtime/syntax/'+name+'.yaml',import.meta.url)).text());
|
|
6
|
+
return new Highlighter(new SyntaxDefinition(parseHeaderYaml(source),source));
|
|
7
|
+
}
|
|
8
|
+
function groupAt(result,index){let group='default';for(const [pos,value]of result.changes){if(pos>index)break;group=value;}return group;}
|
|
9
|
+
for(const [syntax,first]of [['html','<div class="hello">Hello</div>'],['xml','<Project Sdk="Microsoft.NET.Sdk">']]){
|
|
10
|
+
test(syntax+' nested attribute returns to outer tag and does not leak to next line',async()=>{
|
|
11
|
+
const h=await highlighter(syntax),r=h.highlightLine(first);
|
|
12
|
+
expect(r.state).toBeNull();
|
|
13
|
+
expect(groupAt(r,first.indexOf('>'))).toBe('symbol.tag');
|
|
14
|
+
const next=h.highlightLine('<p>Next line</p>',r.state);
|
|
15
|
+
expect(groupAt(next,3)).toBe('default');
|
|
16
|
+
expect(next.state).toBeNull();
|
|
17
|
+
expect([...r.changes.keys()].every(p=>p<=first.length)).toBe(true);
|
|
18
|
+
});
|
|
19
|
+
test(syntax+' retains an unfinished attribute across lines then exits it',async()=>{
|
|
20
|
+
const h=await highlighter(syntax);
|
|
21
|
+
const a=h.highlightLine('<div title="first');expect(a.state?.group).toBe('constant.string');
|
|
22
|
+
const b=h.highlightLine('second">Text</div>',a.state);
|
|
23
|
+
expect(groupAt(b,0)).toBe('constant.string');
|
|
24
|
+
expect(groupAt(b,8)).toBe('default');expect(b.state).toBeNull();
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
test('HTML multiple attributes, adjacent tags and nested escaped quotes',async()=>{
|
|
28
|
+
const h=await highlighter('html');
|
|
29
|
+
const line='<a href="/path" title="say \\"hi\\"">Link</a><b>next</b>';
|
|
30
|
+
const r=h.highlightLine(line);
|
|
31
|
+
expect(r.state).toBeNull();expect(groupAt(r,line.indexOf('Link'))).toBe('default');
|
|
32
|
+
expect(groupAt(r,line.indexOf('next'))).toBe('default');
|
|
33
|
+
});
|
|
34
|
+
test('zero-width child/parent loop steps forward and keeps highlighting the line',()=>{
|
|
35
|
+
const h=new Highlighter({rules:[{type:'region',group:'outer',start:/</u,end:/>/u,rules:[{type:'region',group:'inner',start:/(?=x)/u,end:/(?=x)/u,rules:[]}]},{type:'pattern',group:'keyword',regex:/END/u}]});
|
|
36
|
+
let calls=0;const line='<x>END';const r=h.highlightLine(line,null,()=>{if(++calls>100)throw Error('loop');});
|
|
37
|
+
expect(r.state).toBeNull();expect(calls).toBeLessThan(100);
|
|
38
|
+
expect(groupAt(r,1)).toBe('outer');expect(groupAt(r,line.indexOf('END'))).toBe('keyword');
|
|
39
|
+
});
|
|
40
|
+
test('empty pattern matches advance past full Unicode characters, with or without progress',()=>{
|
|
41
|
+
const h=new Highlighter({rules:[{type:'pattern',group:'empty',regex:/(?=.)/u},{type:'pattern',group:'number',regex:/42/u}]});
|
|
42
|
+
for(const progress of [null,()=>{}]){
|
|
43
|
+
const r=h.highlightLine('😀\0\ud80042',null,progress);
|
|
44
|
+
expect(groupAt(r,4)).toBe('number');expect(r.state).toBeNull();
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
test('NUL and isolated surrogate units inside HTML do not leak state',async()=>{
|
|
48
|
+
const h=await highlighter('html');
|
|
49
|
+
const r=h.highlightLine('<a title="\0😀\ud800">hello\0\udc00</a>');
|
|
50
|
+
expect(r.state).toBeNull();
|
|
51
|
+
expect(h.highlightLine('\0'.repeat(10000)).state).toBeNull();
|
|
52
|
+
});
|
|
53
|
+
test('long lines finish at their final token without recursion or truncation',()=>{
|
|
54
|
+
const h=new Highlighter({rules:[{type:'region',group:'string',start:/"/u,end:/"/u,rules:[]},{type:'pattern',group:'keyword',regex:/END/u}]});
|
|
55
|
+
const line='"x";'.repeat(50000)+'END';
|
|
56
|
+
const r=h.highlightLine(line);
|
|
57
|
+
expect(r.state).toBeNull();expect(groupAt(r,line.length-1)).toBe('keyword');
|
|
58
|
+
expect([...r.changes.keys()].at(-1)).toBe(line.length);
|
|
59
|
+
},30000);
|
|
60
|
+
test('cyclic incoming state and cyclic syntax trees cannot recurse forever',()=>{
|
|
61
|
+
const region={type:'region',group:'cycle',start:/</u,end:/>/u,rules:[]};region.rules.push(region);
|
|
62
|
+
const h=new Highlighter({rules:[region]});
|
|
63
|
+
expect(h.highlightLine('plain').state).toBeNull();
|
|
64
|
+
const state={group:'cycle',rules:[]};state.parent=state;
|
|
65
|
+
expect(h.highlightLine('plain',state).state).toBeNull();
|
|
66
|
+
});
|
|
67
|
+
test('externally supplied zero-width recursive state has a no-progress bound',()=>{
|
|
68
|
+
const child={type:'region',group:'inner',start:/(?=x)/u,end:/$/u,rules:[]};child.rules.push(child);
|
|
69
|
+
const state={group:'outer',end:/$/u,rules:[child]};
|
|
70
|
+
const h=new Highlighter({rules:[]});let calls=0;
|
|
71
|
+
const r=h.highlightLine('x',state,()=>{if(++calls>5000)throw Error('loop');});
|
|
72
|
+
expect(r.state).toBeNull();expect(calls).toBeLessThan(5000);
|
|
73
|
+
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { expect, test } from "bun:test";
|
|
2
|
+
import { escapesSlashTags } from "./markdown-behavior.mjs";
|
|
2
3
|
import { mkdtemp, rm, writeFile } from "node:fs/promises";
|
|
3
4
|
import { tmpdir } from "node:os";
|
|
4
5
|
import { join } from "node:path";
|
|
@@ -39,7 +40,7 @@ test("--check exits 0 and reports unique IDs", async () => {
|
|
|
39
40
|
});
|
|
40
41
|
|
|
41
42
|
test("--check fails closed when browser heading parsing is ambiguous", async () => {
|
|
42
|
-
const result = await runCheck('<div
|
|
43
|
+
const result = await runCheck('<div x=">TAIL\n\n# 中文\n');
|
|
43
44
|
expect(result.exitCode).toBe(2);
|
|
44
45
|
expect(result.stderr.toString()).toContain(
|
|
45
46
|
"Markdown headings could not be classified safely",
|
|
@@ -359,15 +360,37 @@ test("--check ignores heading-looking text inside raw attributes", async () => {
|
|
|
359
360
|
expect(output).toContain("FAILED");
|
|
360
361
|
});
|
|
361
362
|
|
|
362
|
-
test("--check
|
|
363
|
+
test("--check follows Bun's slash-separated raw heading behavior", async () => {
|
|
363
364
|
const result = await runCheck("<h1/id=中文>Raw</h1>\n\n# 中文\n");
|
|
364
365
|
const output = Bun.stripANSI(result.stdout.toString());
|
|
365
|
-
expect(result.exitCode).toBe(1);
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
}
|
|
366
|
+
expect(result.exitCode).toBe(escapesSlashTags ? 0 : 1);
|
|
367
|
+
if (escapesSlashTags) {
|
|
368
|
+
expect(output).toContain("Selectable IDs: 1");
|
|
369
|
+
expect(output).toContain("PASSED");
|
|
370
|
+
expect(output).not.toContain("Type: raw HTML heading");
|
|
371
|
+
} else {
|
|
372
|
+
expect(output).toContain("ID #中文");
|
|
373
|
+
expect(output).toContain("Type: raw HTML heading");
|
|
374
|
+
expect(output).toContain("Type: heading");
|
|
375
|
+
expect(output).toContain("FAILED");
|
|
376
|
+
}
|
|
377
|
+
});
|
|
378
|
+
|
|
379
|
+
for (const [command, run] of [["--check", runCheck], ["--outline", runOutline]]) {
|
|
380
|
+
test(`${command} follows Bun's slash-tag ambiguity behavior`, async () => {
|
|
381
|
+
const result = await run('<div/a< x=">TAIL\n\n# 中文\n');
|
|
382
|
+
expect(result.exitCode).toBe(escapesSlashTags ? 0 : 2);
|
|
383
|
+
if (escapesSlashTags) {
|
|
384
|
+
expect(result.stderr.toString()).toBe("");
|
|
385
|
+
if (command === "--check") expect(result.stdout.toString()).toContain("PASSED");
|
|
386
|
+
else expect(result.stdout.toString()).toContain("中文");
|
|
387
|
+
} else {
|
|
388
|
+
expect(result.stderr.toString()).toContain("Markdown headings could not be classified safely");
|
|
389
|
+
expect(result.stdout.toString()).not.toContain("PASSED");
|
|
390
|
+
if (command === "--outline") expect(result.stdout.toString()).toBe("");
|
|
391
|
+
}
|
|
392
|
+
});
|
|
393
|
+
}
|
|
371
394
|
|
|
372
395
|
test("--check ignores heading-like custom tag names", async () => {
|
|
373
396
|
const result = await runCheck(
|
|
@@ -494,7 +517,7 @@ value
|
|
|
494
517
|
});
|
|
495
518
|
|
|
496
519
|
test("--outline fails closed when browser heading parsing is ambiguous", async () => {
|
|
497
|
-
const result = await runOutline('<div
|
|
520
|
+
const result = await runOutline('<div x=">TAIL\n\n# 中文\n');
|
|
498
521
|
expect(result.exitCode).toBe(2);
|
|
499
522
|
expect(result.stderr.toString()).toContain(
|
|
500
523
|
"Markdown headings could not be classified safely",
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Probe the parser, not Bun.version: canaries and backports can differ.
|
|
2
|
+
// CommonMark allows `/` after a block tag name only as part of `/>`.
|
|
3
|
+
const probe = Bun.markdown.html("<h1/id=x>Raw</h1>\n");
|
|
4
|
+
const raw = "<h1/id=x>Raw</h1>\n";
|
|
5
|
+
const escaped = "<p><h1/id=x>Raw</h1></p>\n";
|
|
6
|
+
if (probe !== raw && probe !== escaped) {
|
|
7
|
+
throw new Error(`Unexpected Bun Markdown slash-tag behavior: ${JSON.stringify(probe)}`);
|
|
8
|
+
}
|
|
9
|
+
export const escapesSlashTags = probe === escaped;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Normal HTML follow-up
|
|
2
|
+
|
|
3
|
+
Tested with the same unmodified micro highlighter oracle and upstream YAML as
|
|
4
|
+
REPORT.md. See normal-html-report.json for counts and first differing positions.
|
|
5
|
+
The full comparison.html was also passed to both engines as input, unchanged.
|
|
6
|
+
|
|
7
|
+
The minimal reproduction is ordinary valid HTML:
|
|
8
|
+
|
|
9
|
+
```html
|
|
10
|
+
<div class="hello">Hello</div>
|
|
11
|
+
<p>Next line</p>
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
With html.yaml (the definition selected by the .html filename), jmi ends the
|
|
15
|
+
first line with a constant.string state and colors the entire second line as a
|
|
16
|
+
string. This is a real nested-region state bug, not just a malformed generated
|
|
17
|
+
sample. normal-html.html contains a complete document for manual reproduction.
|
|
18
|
+
|
|
19
|
+
For the generated comparison.html, html.yaml produced 731354 differing character
|
|
20
|
+
groups, including 438494 characters marked as strings only by jmi. This large
|
|
21
|
+
one-line file amplifies the state issue; it is not a typical per-file error rate.
|
|
22
|
+
The same full file matched with explicitly selected html4.yaml and html5.yaml,
|
|
23
|
+
which have different rules and are not the default .html filename match.
|
|
24
|
+
|
|
25
|
+
This check did not modify the highlighter or the syntax files.
|
|
26
|
+
|
|
27
|
+
## After the nested-region fix
|
|
28
|
+
|
|
29
|
+
The historical reproduction above is now covered by highlight-regions.test.js.
|
|
30
|
+
The child scanner already resumes its parent and processes the rest of the line;
|
|
31
|
+
returning that result directly avoids rescanning closing quotes as new openings.
|
|
32
|
+
Both HTML and XML now return to the correct outer state, including when an
|
|
33
|
+
attribute legitimately spans multiple lines. Original syntax YAML is unchanged.
|
|
34
|
+
|
|
35
|
+
The current normal-html-report.json records the follow-up: simple HTML,
|
|
36
|
+
two-attribute HTML and a complete normal document have no extra string-colored
|
|
37
|
+
characters. Their remaining differences are local token groups, such as micro
|
|
38
|
+
using symbol.tag where jmi recognizes an attribute as identifier. The current
|
|
39
|
+
comparison.html still has local group differences and is not fully identical.
|
|
40
|
+
It is regenerated from the latest results, so its total size differs from the
|
|
41
|
+
historical input above; raw differing-character totals are not a fixed-corpus
|
|
42
|
+
before/after benchmark.
|
|
43
|
+
|
|
44
|
+
The 158-syntax corpus now has 130 identical samples and 28 with differences.
|
|
45
|
+
XML and MSBuild samples match completely. Mixed POSIX character classes are
|
|
46
|
+
also translated; default/email, mail and privoxy-action samples now match.
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# micro syntax parity fixtures
|
|
2
|
+
|
|
3
|
+
This directory contains one lexical sample for each of **158 syntax definitions**.
|
|
4
|
+
The current report uses upstream micro YAML for both engines, including
|
|
5
|
+
JavaScript, Python and Markdown. For the first run those three local files were
|
|
6
|
+
backed up, temporarily replaced and restored byte-for-byte after comparison.
|
|
7
|
+
`--upstream-syntax` reproduces that comparison without modifying any syntax files.
|
|
8
|
+
Without this flag, the comparator tests only byte-identical local definitions
|
|
9
|
+
and excludes JavaScript, Python and Markdown; included definitions then come
|
|
10
|
+
from each engine's own tree.
|
|
11
|
+
|
|
12
|
+
- [REPORT.md](REPORT.md): counts and first differences, with sample links.
|
|
13
|
+
- `comparison.html` (generated locally, not included): side-by-side colors using
|
|
14
|
+
the same Monokai palette; hover over a span for its exact group. No external
|
|
15
|
+
assets required.
|
|
16
|
+
- [report.json](report.json): machine-readable per-language results.
|
|
17
|
+
- `samples/*.txt`: generated rule witnesses, with hand-written Dockerfile and
|
|
18
|
+
MSBuild examples. They are lexical test fragments, **not generally valid
|
|
19
|
+
programs**. Region boundaries, escaping, and overlapping patterns are included.
|
|
20
|
+
|
|
21
|
+
The oracle invokes the actual, unmodified upstream `pkg/highlight` Go package,
|
|
22
|
+
including its YAML parser and include resolution. No Go regex approximation is
|
|
23
|
+
used for the reference results. This is a highlighter comparison, not a terminal
|
|
24
|
+
screenshot comparison or a test of automatic filetype detection. The sample
|
|
25
|
+
filenames deliberately do not guess extensions: select the filetype shown in
|
|
26
|
+
the report when opening them in an editor (`set filetype dockerfile`, for example).
|
|
27
|
+
|
|
28
|
+
All samples have non-default groups in both engines. Equal results mean equal
|
|
29
|
+
per-character syntax groups **for these samples only**, not full language parity.
|
|
30
|
+
The HTML is a viewing aid, not a substitute for the group-level comparison.
|
|
31
|
+
|
|
32
|
+
## Generate the comparison HTML and reports
|
|
33
|
+
|
|
34
|
+
Install Go 1.24 or newer and Bun with scoped RegExp modifier support. Start in
|
|
35
|
+
this directory. Point `MICRO_SOURCE` at an existing upstream micro checkout:
|
|
36
|
+
|
|
37
|
+
```sh
|
|
38
|
+
export MICRO_SOURCE=/absolute/path/to/go-micro
|
|
39
|
+
export PARITY_BUILD_DIR="$(mktemp -d)"
|
|
40
|
+
cp go.mod "$PARITY_BUILD_DIR/oracle.mod"
|
|
41
|
+
go mod edit -modfile="$PARITY_BUILD_DIR/oracle.mod" \
|
|
42
|
+
-replace="github.com/micro-editor/micro/v2=$MICRO_SOURCE"
|
|
43
|
+
go build -mod=mod -modfile="$PARITY_BUILD_DIR/oracle.mod" \
|
|
44
|
+
-o "$PARITY_BUILD_DIR/oracle" oracle.go
|
|
45
|
+
bun compare.mjs "$MICRO_SOURCE" "$PARITY_BUILD_DIR/oracle" --upstream-syntax
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
The final `bun compare.mjs` command writes `comparison.html`, `REPORT.md` and
|
|
49
|
+
`report.json` into this directory. Open `comparison.html` in a browser and expand
|
|
50
|
+
a language to compare micro (left) with jmi (right). Once the oracle executable
|
|
51
|
+
has been built, rerun just that final command to regenerate the page. The HTML
|
|
52
|
+
is intentionally not checked in and has no Git ignore rule; remove it after
|
|
53
|
+
viewing if you do not want it included in a later commit.
|
|
54
|
+
|
|
55
|
+
Go downloads test-only dependencies to its module cache. It is not a jsmdcui
|
|
56
|
+
runtime dependency; the checkout's module file and upstream sources remain
|
|
57
|
+
unchanged. The reference commit is recorded in the report. Re-running rewrites
|
|
58
|
+
only the reports; it keeps the checked-in samples. `--generate` regenerates
|
|
59
|
+
lexical witnesses and overwrites hand-written samples, so normal comparisons
|
|
60
|
+
should omit it.
|
|
61
|
+
|
|
62
|
+
Differences are reported rather than hidden or automatically fixed. In
|
|
63
|
+
particular, a regex compiling successfully does not establish equivalence of
|
|
64
|
+
nested region handling, skip masking, or rule ordering.
|
|
65
|
+
|
|
66
|
+
## Scanner safety checks
|
|
67
|
+
|
|
68
|
+
Run `bun test tests/highlight-regions.test.js tests/go-regexp.test.js` from the
|
|
69
|
+
jsmdcui root. These cover zero-width cycles, Unicode empty matches, NUL, isolated
|
|
70
|
+
surrogates, cyclic definitions/state, and a 200,003-character line whose final
|
|
71
|
+
keyword must still be highlighted. Region transitions are iterative; there is
|
|
72
|
+
no input line-length cutoff. Malformed definitions are limited to 128 nested
|
|
73
|
+
rule levels. A repeated state at the same position advances by one Unicode
|
|
74
|
+
character and continues highlighting. If malformed states keep creating fresh
|
|
75
|
+
objects, 256 transitions without advancing reset the unfinished region for that
|
|
76
|
+
line instead of carrying it forward.
|
|
77
|
+
|
|
78
|
+
A manual stability run also processed Vue 3.5.13's `vue.global.prod.js`
|
|
79
|
+
(157,924 bytes, longest line 141,082 UTF-16 units) in about 87 ms on the test
|
|
80
|
+
host, without a stack overflow or truncation. This is not proof of exact Vue
|
|
81
|
+
syntax parity. No downloaded Vue bundle is included in the repository.
|
|
82
|
+
|
|
83
|
+
These guards prevent scanner loops and stack exhaustion. They cannot interrupt
|
|
84
|
+
a single pathological native JavaScript RegExp execution; arbitrary untrusted
|
|
85
|
+
regexes would need worker/process isolation for a hard execution-time limit.
|