Frontend uudelleenrakennettu: Astro-komponentit, Wasm pääsäikeessä, ei Workeria

Vanha frontend siirretty temp/. Uusi rakenne:
- StatusBar.astro, Terminal.astro, Editor.astro, Guide.astro
- global.css erillinen
- Wasm pääsäikeessä (ei Worker — yksinkertainen, debugattava)
- Tab-completion, dropdown, projektikortti, Monaco, GUIDE.md
- Ei tokenisointia eikä koodilaboratoriota

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jaakko Vanhala
2026-04-09 20:17:39 +03:00
parent e3fdb91ac5
commit a8c4af0975
9617 changed files with 996171 additions and 5349 deletions

View File

@@ -0,0 +1,7 @@
import { type Options } from "retext-smartypants";
import type { Plugin } from "unified";
/**
* remark plugin to implement SmartyPants.
*/
declare const remarkSmartypants: Plugin<[Options?]>;
export default remarkSmartypants;

View File

@@ -0,0 +1,76 @@
import { retext } from "retext";
import { visit } from "unist-util-visit";
import smartypants from "retext-smartypants";
const VISITED_NODES = new Set(["text", "inlineCode", "paragraph"]);
const IGNORED_HTML_ELEMENTS = new Set(["style", "script"]);
const check = (node, index, parent) => {
return (parent &&
(parent.type !== "mdxJsxTextElement" ||
("name" in parent &&
typeof parent.name === "string" &&
!IGNORED_HTML_ELEMENTS.has(parent.name))) &&
VISITED_NODES.has(node.type) &&
(isLiteral(node) || isParagraph(node)));
};
/**
* remark plugin to implement SmartyPants.
*/
const remarkSmartypants = (options) => {
const processor = retext().use(smartypants, {
...options,
// Do not replace ellipses, dashes, backticks because they change string
// length, and we couldn't guarantee right splice of text in second visit of
// tree
ellipses: false,
dashes: false,
backticks: false,
});
const processor2 = retext().use(smartypants, {
...options,
// Do not replace quotes because they are already replaced in the first
// processor
quotes: false,
});
return (tree) => {
let allText = "";
let startIndex = 0;
const nodes = [];
visit(tree, check, (node) => {
if (isLiteral(node)) {
allText +=
node.type === "text" ? node.value : "A".repeat(node.value.length);
}
else if (isParagraph(node)) {
// Inject a "fake" space because otherwise, when concatenated below,
// smartypants will fail to recognize opening quotes at the start of
// paragraphs
allText += " ";
}
nodes.push(node);
});
// Concat all text into one string, to properly replace quotes around links
// and bold text
allText = processor.processSync(allText).toString();
for (const node of nodes) {
if (isLiteral(node)) {
const endIndex = startIndex + node.value.length;
if (node.type === "text") {
const processedText = allText.slice(startIndex, endIndex);
node.value = processor2.processSync(processedText).toString();
}
startIndex = endIndex;
}
else if (isParagraph(node)) {
// Skip over the space we added above
startIndex += 1;
}
}
};
};
function isLiteral(node) {
return "value" in node && typeof node.value === "string";
}
function isParagraph(node) {
return node.type === "paragraph";
}
export default remarkSmartypants;