wiki-formant 0.83.0 → 0.83.1
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/README.md +1 -2
- package/dist/dom.d.ts +0 -8
- package/dist/dom.js +0 -23
- package/dist/react.d.ts +8 -0
- package/dist/react.js +27 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -693,13 +693,12 @@ export const X = xAccount({ siteName: 'AcuiQ', handle: '@acu_iq', posts: "a name
|
|
|
693
693
|
addCopyButtons(el); // every <pre> gets one, once
|
|
694
694
|
sortTables(el); // every column-headed table sorts by its headers
|
|
695
695
|
hydrateTweetEmbeds(el); // placeholders get a live src
|
|
696
|
-
await renderMath(el); // $$…$$, \\[…\\] and \\(…\\) typeset by KaTeX, loaded only when there is maths
|
|
697
696
|
const off = onTweetResize((h, source) => sizeTweetEmbed(el, h, source));
|
|
698
697
|
```
|
|
699
698
|
|
|
700
699
|
`addCopyButton` was **byte-identical** in two BlockRenderers, down to the SVG path data. Its idempotence guard now lives inside the function rather than in a `pre:not(:has(…))` at the call site, where it can be — and was — retyped.
|
|
701
700
|
|
|
702
|
-
In React, `useArticlePasses(ref, [blocks])` (`wiki-formant/react`) runs them all, the embed pair and
|
|
701
|
+
In React, `useArticlePasses(ref, [blocks])` (`wiki-formant/react`) runs them all, the embed pair included, and typesets maths: `renderMath` (also `wiki-formant/react`, since its stylesheet import cannot sit in a module server code reaches) sets `$$…$$` and `\[…\]` as a display and `\(…\)` inline. KaTeX is an optional peer: an app installs `katex`, and a page with no delimiter never fetches it. There is no single-`$` delimiter, since prose writes $XRD. Three renderers had the effect written out and disagreed on its dependencies: two ran once on mount, so a page swapped in without a remount kept its old tables unsortable.
|
|
703
702
|
|
|
704
703
|
`activateTabGroups` turns stored `[data-tabs]` markup into a working tab group. The editor persists tabs as nested divs, which is the right thing to store — it survives a markdown twin, a plain HTML render and a reader with JavaScript off, all of which show every tab in order. Making one of them pressable is a reader-side job, and it sits beside the other passes rather than inside a component.
|
|
705
704
|
|
package/dist/dom.d.ts
CHANGED
|
@@ -40,14 +40,6 @@ export declare function onTweetResize(resize: (height: number, source: MessageEv
|
|
|
40
40
|
export declare function hydrateTweetEmbeds(root: ParentNode): void;
|
|
41
41
|
/** Apply a posted height to the embed iframe under `root` that posted it, and to no other. */
|
|
42
42
|
export declare function sizeTweetEmbed(root: ParentNode, height: number, source: MessageEventSource | null): void;
|
|
43
|
-
/**
|
|
44
|
-
* Typeset the maths under `root` with KaTeX: `$$…$$` and `\[…\]` as a display,
|
|
45
|
-
* `\(…\)` inline. KaTeX and its stylesheet load only when the text holds a
|
|
46
|
-
* delimiter, so a page with no maths fetches nothing. KaTeX is an optional peer
|
|
47
|
-
* the app installs. Typeset maths carries no delimiter, so a second pass finds
|
|
48
|
-
* nothing to do.
|
|
49
|
-
*/
|
|
50
|
-
export declare function renderMath(root: HTMLElement): Promise<void>;
|
|
51
43
|
export interface TabGroupClassNames {
|
|
52
44
|
list?: string;
|
|
53
45
|
panels?: string;
|
package/dist/dom.js
CHANGED
|
@@ -113,29 +113,6 @@ export function sizeTweetEmbed(root, height, source) {
|
|
|
113
113
|
iframe.style.height = `${height}px`;
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
|
-
// ---- maths ------------------------------------------------------------------
|
|
117
|
-
/** What marks maths in stored prose. No single `$`: prose writes $XRD, and two cashtags in one block would read as a formula. */
|
|
118
|
-
const MATH = /\$\$|\\\(|\\\[/;
|
|
119
|
-
/**
|
|
120
|
-
* Typeset the maths under `root` with KaTeX: `$$…$$` and `\[…\]` as a display,
|
|
121
|
-
* `\(…\)` inline. KaTeX and its stylesheet load only when the text holds a
|
|
122
|
-
* delimiter, so a page with no maths fetches nothing. KaTeX is an optional peer
|
|
123
|
-
* the app installs. Typeset maths carries no delimiter, so a second pass finds
|
|
124
|
-
* nothing to do.
|
|
125
|
-
*/
|
|
126
|
-
export async function renderMath(root) {
|
|
127
|
-
if (!MATH.test(root.textContent ?? ''))
|
|
128
|
-
return;
|
|
129
|
-
const [{ default: render }] = await Promise.all([import('katex/contrib/auto-render'), import('katex/dist/katex.min.css')]);
|
|
130
|
-
render(root, {
|
|
131
|
-
delimiters: [
|
|
132
|
-
{ left: '$$', right: '$$', display: true },
|
|
133
|
-
{ left: '\\(', right: '\\)', display: false },
|
|
134
|
-
{ left: '\\[', right: '\\]', display: true },
|
|
135
|
-
],
|
|
136
|
-
throwOnError: false,
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
116
|
/**
|
|
140
117
|
* Turn stored `[data-tabs]` markup into a working tab group.
|
|
141
118
|
*
|
package/dist/react.d.ts
CHANGED
|
@@ -477,6 +477,14 @@ export declare function RailShell({ children, prefix, label, className }: RailSh
|
|
|
477
477
|
*/
|
|
478
478
|
export declare function isRailLinkActive(activePath: string, href: string, tree?: boolean): boolean;
|
|
479
479
|
export type { WikiLinkComponent, WikiLinkProps } from './react-server.js';
|
|
480
|
+
/**
|
|
481
|
+
* Typeset the maths under `root` with KaTeX: `$$…$$` and `\[…\]` as a display,
|
|
482
|
+
* `\(…\)` inline. KaTeX and its stylesheet load only when the text holds a
|
|
483
|
+
* delimiter, so a page with no maths fetches nothing. KaTeX is an optional peer
|
|
484
|
+
* the app installs. Typeset maths carries no delimiter, so a second pass finds
|
|
485
|
+
* nothing to do.
|
|
486
|
+
*/
|
|
487
|
+
export declare function renderMath(root: HTMLElement): Promise<void>;
|
|
480
488
|
/**
|
|
481
489
|
* The `wiki-formant/dom` passes over a rendered article: tab groups, copy
|
|
482
490
|
* buttons, sortable tables, maths typeset, and each post on X hydrated and kept
|
package/dist/react.js
CHANGED
|
@@ -26,7 +26,7 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
|
|
|
26
26
|
// state on <html> before first paint. The hook keeps that attribute in
|
|
27
27
|
// sync afterwards, so CSS has one source of truth either side of hydration.
|
|
28
28
|
import { railBreakpointMismatch, readRailFloating, resolveSidebarOpen, SIDEBAR_ATTRIBUTE, } from './sidebar.js';
|
|
29
|
-
import { activateTabGroups, addCopyButtons, hydrateTweetEmbeds, onTweetResize,
|
|
29
|
+
import { activateTabGroups, addCopyButtons, hydrateTweetEmbeds, onTweetResize, sizeTweetEmbed, sortTables, startBeacon } from './dom.js';
|
|
30
30
|
import { comboboxAria } from './combobox.js';
|
|
31
31
|
import { Component, createContext, createElement, useCallback, useContext, useEffect, useId, useMemo, useRef, useState, } from 'react';
|
|
32
32
|
const readStored = (key) => {
|
|
@@ -880,6 +880,32 @@ const decodePath = (path) => {
|
|
|
880
880
|
return path;
|
|
881
881
|
}
|
|
882
882
|
};
|
|
883
|
+
// ---- maths ------------------------------------------------------------------
|
|
884
|
+
// Here rather than in `dom.ts` because of its stylesheet import: `dom.ts` is
|
|
885
|
+
// reached from server modules (`headings.ts`), and a bundler cannot chunk a
|
|
886
|
+
// CSS import from plain server code. This module is a client one.
|
|
887
|
+
/** What marks maths in stored prose. No single `$`: prose writes $XRD, and two cashtags in one block would read as a formula. */
|
|
888
|
+
const MATH = /\$\$|\\\(|\\\[/;
|
|
889
|
+
/**
|
|
890
|
+
* Typeset the maths under `root` with KaTeX: `$$…$$` and `\[…\]` as a display,
|
|
891
|
+
* `\(…\)` inline. KaTeX and its stylesheet load only when the text holds a
|
|
892
|
+
* delimiter, so a page with no maths fetches nothing. KaTeX is an optional peer
|
|
893
|
+
* the app installs. Typeset maths carries no delimiter, so a second pass finds
|
|
894
|
+
* nothing to do.
|
|
895
|
+
*/
|
|
896
|
+
export async function renderMath(root) {
|
|
897
|
+
if (!MATH.test(root.textContent ?? ''))
|
|
898
|
+
return;
|
|
899
|
+
const [{ default: render }] = await Promise.all([import('katex/contrib/auto-render'), import('katex/dist/katex.min.css')]);
|
|
900
|
+
render(root, {
|
|
901
|
+
delimiters: [
|
|
902
|
+
{ left: '$$', right: '$$', display: true },
|
|
903
|
+
{ left: '\\(', right: '\\)', display: false },
|
|
904
|
+
{ left: '\\[', right: '\\]', display: true },
|
|
905
|
+
],
|
|
906
|
+
throwOnError: false,
|
|
907
|
+
});
|
|
908
|
+
}
|
|
883
909
|
// ---- rendered-article passes --------------------------------------------------
|
|
884
910
|
/**
|
|
885
911
|
* The `wiki-formant/dom` passes over a rendered article: tab groups, copy
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wiki-formant",
|
|
3
|
-
"version": "0.83.
|
|
3
|
+
"version": "0.83.1",
|
|
4
4
|
"description": "The portable half of a wiki: derived taxonomy and facet controls, a version-negotiating MCP transport, markdown twins, block rendering, a rich-text editor engine, conditional-GET plumbing, and the headers and CSP every origin sends.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|