Release RuneStone 0.1.4 with installable plugins and settings

This commit is contained in:
Knotty Wyvern
2026-10-04 15:05:51 -07:00
parent 0268c5c9f0
commit 6b7af0d527
82 changed files with 4150 additions and 212 deletions
+2 -25
View File
@@ -1,7 +1,7 @@
import MarkdownIt from "markdown-it";
import type { Token } from "markdown-it";
import { inlineMathEnd } from "./inlineMath.ts";
import { evaluateTableFormulas, formulaErrors, type FormulaResult } from "../editor/tableFormulas.ts";
import { pluginHost } from "../plugins/registry.ts";
const markdown = new MarkdownIt({ html: false, linkify: true, breaks: false });
export const escapeHtml = markdown.utils.escapeHtml;
@@ -156,31 +156,8 @@ markdown.renderer.rules.image = (tokens, index, _options, env, renderer) => {
markdown.renderer.rules.table_open = () => '<div class="md-table-scroll"><table>\n';
markdown.renderer.rules.table_close = () => '</table></div>\n';
export function tableFormulaHtml(result: FormulaResult): string {
const label = `${result.formula} → ${result.error ? formulaErrors[result.error] : result.text}`;
return `<span class="md-table-formula${result.error ? " is-error" : ""}" title="${escapeHtml(label)}" aria-label="${escapeHtml(label)}">${escapeHtml(result.text)}</span>`;
}
// Work from raw inline content, before Markdown formatting can interpret * or $.
// Each table gets its own reference scope, including in nested lists/callouts.
markdown.core.ruler.after("inline", "table_formulas", state => {
let rows: Token[][] | undefined;
for (const token of state.tokens) {
if (token.type === "table_open") rows = [];
else if (rows && token.type === "tr_open") rows.push([]);
else if (rows && token.type === "inline") rows.at(-1)?.push(token);
else if (rows && token.type === "table_close") {
const results = evaluateTableFormulas(rows.map(row => row.map(cell => cell.content)));
rows.forEach((row, r) => row.forEach((cell, c) => {
const result = results[r][c];
if (!result) return;
const output = new MarkdownIt.Token("html_inline", "", 0);
output.content = tableFormulaHtml(result);
cell.children = [output];
}));
rows = undefined;
}
}
pluginHost.get("tableFormulas")?.renderTableFormulas(state.tokens);
});
function documentParts(contents: string) {