@pretextbook/pretext-html 0.5.0 → 0.6.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/README.md +6 -0
- package/assets/preview-html.xsl +14 -0
- package/dist/{cli-DZsyZERX.js → cli-DF7XOWN7.js} +204 -174
- package/dist/cli.js +1 -1
- package/dist/index.browser.d.ts +1 -0
- package/dist/index.browser.js +348 -325
- package/dist/index.d.ts +1 -0
- package/dist/index.js +17 -16
- package/dist/knowls.d.ts +43 -0
- package/dist/renderer.d.ts +13 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export { detectRenderTarget } from './target.js';
|
|
|
8
8
|
export type { RenderTarget } from './target.js';
|
|
9
9
|
export { injectRevealBridge, isRevealView, revealBridgeScript, } from './reveal.js';
|
|
10
10
|
export type { RevealView, RevealViewOptions } from './reveal.js';
|
|
11
|
+
export { openBornHiddenKnowls } from './knowls.js';
|
|
11
12
|
export { rewriteAssetUrls } from './assets.js';
|
|
12
13
|
export type { AssetKind, AssetUrlResolver } from './assets.js';
|
|
13
14
|
export { describeAsset, missingAssetPlaceholder, missingAssetSvg, } from './missing-asset.js';
|
package/dist/index.js
CHANGED
|
@@ -1,28 +1,29 @@
|
|
|
1
|
-
import { d as r, a as i, f as t, b as a, i as l, r as
|
|
2
|
-
import { injectRevealBridge as
|
|
3
|
-
import { describeAsset as
|
|
4
|
-
import { PREVIEW_THEME_MESSAGE as u, injectThemeBridge as
|
|
1
|
+
import { d as r, a as i, f as t, b as a, i as o, o as l, r as n, m as d, s as m, c, x as p } from "./cli-DF7XOWN7.js";
|
|
2
|
+
import { injectRevealBridge as f, isRevealView as v, revealBridgeScript as A } from "./reveal.js";
|
|
3
|
+
import { describeAsset as S, missingAssetPlaceholder as h, missingAssetSvg as x, rewriteAssetUrls as B } from "./assets.js";
|
|
4
|
+
import { PREVIEW_THEME_MESSAGE as u, injectThemeBridge as w, isPreviewTheme as M, previewThemeMessage as P, themeBridgeScript as R } from "./theme.js";
|
|
5
5
|
export {
|
|
6
6
|
u as PREVIEW_THEME_MESSAGE,
|
|
7
7
|
r as defaultXslDir,
|
|
8
|
-
|
|
8
|
+
S as describeAsset,
|
|
9
9
|
i as detectRenderTarget,
|
|
10
10
|
t as findSourceMapEntry,
|
|
11
11
|
a as forcePortablePublication,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
f as injectRevealBridge,
|
|
13
|
+
w as injectThemeBridge,
|
|
14
|
+
o as isJspiAvailable,
|
|
15
15
|
M as isPreviewTheme,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
v as isRevealView,
|
|
17
|
+
h as missingAssetPlaceholder,
|
|
18
|
+
x as missingAssetSvg,
|
|
19
|
+
l as openBornHiddenKnowls,
|
|
19
20
|
P as previewThemeMessage,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
n as renderHtml,
|
|
22
|
+
A as revealBridgeScript,
|
|
23
|
+
B as rewriteAssetUrls,
|
|
23
24
|
d as runCli,
|
|
24
25
|
m as setAssetsBase,
|
|
25
|
-
|
|
26
|
+
c as setMountReader,
|
|
26
27
|
R as themeBridgeScript,
|
|
27
|
-
|
|
28
|
+
p as xpathStringLiteral
|
|
28
29
|
};
|
package/dist/knowls.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Expand born-hidden knowls in a rendered preview.
|
|
3
|
+
*
|
|
4
|
+
* PreTeXt draws "born-hidden" blocks — solutions, hints, answers, and whatever
|
|
5
|
+
* else the publication file elects to hide — as a native `<details>` with the
|
|
6
|
+
* heading in a clickable `<summary>` and the content collapsed (see
|
|
7
|
+
* `mode="born-hidden"` in pretext-html.xsl). On a built page that is the point:
|
|
8
|
+
* the reader chooses what to reveal.
|
|
9
|
+
*
|
|
10
|
+
* In a live preview it works against the author. Editing a solution re-renders
|
|
11
|
+
* the page, and the fresh HTML has that solution collapsed again — so the one
|
|
12
|
+
* thing the author is looking at is the one thing they cannot see. Opening the
|
|
13
|
+
* knowls up front is what makes edit-and-watch work.
|
|
14
|
+
*
|
|
15
|
+
* Only `.born-hidden-knowl` is touched. The other `<details>` PreTeXt emits —
|
|
16
|
+
* footnotes, image descriptions, diagcess instructions, the print-options panel
|
|
17
|
+
* — are left collapsed, so the preview still reads like the built page.
|
|
18
|
+
*
|
|
19
|
+
* Done on the rendered HTML rather than in the preview stylesheet because a
|
|
20
|
+
* `<details>` is emitted from five separate upstream templates: an XSLT
|
|
21
|
+
* override would mean copying all five into the generated wrapper and keeping
|
|
22
|
+
* every one of them in step with upstream. Matching the class is one rule that
|
|
23
|
+
* cannot drift. Escaped text (a code sample showing `<details>`) is `<` in
|
|
24
|
+
* the output and so cannot match.
|
|
25
|
+
*
|
|
26
|
+
* Safe with upstream's javascript: `SlideRevealer` in pretext-core.js binds a
|
|
27
|
+
* click handler that branches on whether the element already has `@open`, so a
|
|
28
|
+
* pre-opened knowl animates *closed* on the first click, exactly as it would
|
|
29
|
+
* had the reader opened it themselves.
|
|
30
|
+
*/
|
|
31
|
+
/**
|
|
32
|
+
* Add `@open` to every born-hidden knowl in `html`, leaving all other
|
|
33
|
+
* `<details>` alone.
|
|
34
|
+
*
|
|
35
|
+
* The knowl's `<summary>` is marked open too. That mirrors what pretext-core.js
|
|
36
|
+
* does when a reader clicks one (`triggerElement.setAttribute("open", "")`) and
|
|
37
|
+
* is what the theme's `.knowl__link:is(:hover,:focus,[open])` rule keys on for
|
|
38
|
+
* the summary's tinted background — without it a pre-opened knowl would be the
|
|
39
|
+
* only open knowl on the page whose heading is not highlighted. It is not a
|
|
40
|
+
* valid HTML attribute on `<summary>`; it is upstream's convention, matched
|
|
41
|
+
* here so the preview looks like the page a reader opened by hand.
|
|
42
|
+
*/
|
|
43
|
+
export declare function openBornHiddenKnowls(html: string): string;
|
package/dist/renderer.d.ts
CHANGED
|
@@ -137,6 +137,19 @@ export interface RenderOptions {
|
|
|
137
137
|
* sourcemap.ts for the id contract with pretext-assembly.xsl.
|
|
138
138
|
*/
|
|
139
139
|
sourceMap?: boolean;
|
|
140
|
+
/**
|
|
141
|
+
* Expand born-hidden knowls — solutions, hints, answers, and any block the
|
|
142
|
+
* publication file elects to hide — instead of leaving them collapsed.
|
|
143
|
+
* Defaults to **true**, because the pages this package renders are previews:
|
|
144
|
+
* an author editing a solution needs to see it without re-opening it after
|
|
145
|
+
* every re-render.
|
|
146
|
+
*
|
|
147
|
+
* Set it to false for a page meant to be read rather than authored against,
|
|
148
|
+
* which is then collapsed exactly as a real PreTeXt build would be. Other
|
|
149
|
+
* `<details>` (footnotes, image descriptions) are never affected. See
|
|
150
|
+
* knowls.ts.
|
|
151
|
+
*/
|
|
152
|
+
openKnowls?: boolean;
|
|
140
153
|
/**
|
|
141
154
|
* Let the embedding app control the preview's light/dark theme. When set, a
|
|
142
155
|
* small bridge script is injected into the page that applies this value as
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pretextbook/pretext-html",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Convert PreTeXt documents to HTML in pure JavaScript using the official PreTeXt XSLT stylesheets via libxslt-wasm. No Python or PreTeXt installation required.",
|
|
5
5
|
"author": "Oscar Levin",
|
|
6
6
|
"license": "MIT",
|