diff --git a/utility/export-tokenized-sample-code.mjs b/utility/export-tokenized-sample-code.mjs new file mode 100644 index 000000000..f2c7408be --- /dev/null +++ b/utility/export-tokenized-sample-code.mjs @@ -0,0 +1,22 @@ +import fs from "node:fs"; + +import { ssStrings } from "./generate-samples/templates/package-sample.mjs"; + +export default main; + +async function main(args) { + let out = { tokens: [] }; + for (const line of ssStrings) { + let outLine = []; + for (const [id, token] of line.entries()) { + if (id > 0) { + outLine.push({ text: " ", scopes: [] }); + } + let combined = Array.from(token).join(""); + outLine.push({ text: combined, scopes: ["dim"] }); + } + out.tokens.push(outLine); + } + + await fs.promises.writeFile(args.output, JSON.stringify(out, null, " ")); +} diff --git a/utility/generate-samples/templates/package-sample.mjs b/utility/generate-samples/templates/package-sample.mjs index ad1b61f6b..a7be3d8df 100644 --- a/utility/generate-samples/templates/package-sample.mjs +++ b/utility/generate-samples/templates/package-sample.mjs @@ -1,11 +1,11 @@ import * as themes from "../themes/index.mjs"; // prettier-ignore -const ssStrings = [ +export const ssStrings = [ ["ABC.DEF.GHI.JKL.MNO.PQRS.TUV.WXYZ", "abc.def.ghi.jkl.mno.pqrs.tuv.wxyz"], ["¢ſßðþ ΓΛΔαδιλμξ КУЗЯЖэльфязычникж", "float il1[]={1-2/3.4,5+6=7/8%90};"], ["1234567890 ,._-+= >< ¯-¬_ >~–÷+×<", "{*}[]()<>`+-=$/#_%^@\\&|~?'\" !,.;:"], - ["!iIlL17|¦ coO08BbDQ $5SZ2zsz 96G&", [..."dbqp E3 g9qCGQ vvwVVW ", "<=", " ", "!="," ","==", " ", ">="]] + ["!iIlL17|¦ coO08BbDQ $5SZ2zsz 96G&", [..."E3CGQ g9q¶ uvw ", "__", " ", "<=", " ", "!="," ","==", " ", ">=", " ", "->"]] ]; function* makeSample(lbm, hotChars) { diff --git a/verdafile.mjs b/verdafile.mjs index af1a70d3e..338f35c53 100644 --- a/verdafile.mjs +++ b/verdafile.mjs @@ -856,6 +856,9 @@ const PagesDataExport = task(`pages:data-export`, async t => { BuildCM("iosevka", "iosevka-italic"), BuildCM("iosevka", "iosevka-oblique") ); + await node(`utility/export-tokenized-sample-code.mjs`, { + output: Path.resolve(pagesDir, "shared/tokenized-sample-code/alphabet.txt.json") + }); await node(`utility/export-data/index.mjs`, { charMapPath: cm.full, charMapItalicPath: cmi.full,