@pretextbook/pretext-html 0.17.0 → 0.18.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/dist/index.d.ts CHANGED
@@ -6,7 +6,7 @@ export type { SourceCacheOptions } from './source-cache.js';
6
6
  export type { SourceReader } from './xinclude.js';
7
7
  export { findSourceMapEntry } from './sourcemap.js';
8
8
  export type { PtxSourceMap, SourceMapEntry } from './sourcemap.js';
9
- export { forcePortablePublication } from './publication.js';
9
+ export { forcePreviewPublication, forcePortablePublication, } from './publication.js';
10
10
  export type { PublicationOverrides } from './publication.js';
11
11
  export { detectRenderTarget } from './target.js';
12
12
  export type { RenderTarget } from './target.js';
package/dist/index.js CHANGED
@@ -1,52 +1,53 @@
1
- import { O as s, P as i, S as t, b as a, d as n, a as o, c, e as l, f as p, g as d, i as P, h as E, m, o as S, p as v, r as u, j as A, k as f, l as g, n as h, s as B, q as _, x as w } from "./cli-C0JwLhuv.js";
2
- import { injectRevealBridge as L, isRevealView as x, revealBridgeScript as T } from "./reveal.js";
3
- import { describeAsset as G, missingAssetPlaceholder as I, missingAssetSvg as M, rewriteAssetUrls as j } from "./assets.js";
4
- import { PREVIEW_THEME_MESSAGE as V, injectThemeBridge as C, isPreviewTheme as D, previewThemeMessage as H, themeBridgeScript as k } from "./theme.js";
5
- import { PRINT_PREVIEW_GLOBAL as W, injectPrintPreview as y, listPrintouts as F, printPreviewBridgeScript as K, rootPrintoutId as X } from "./printout.js";
6
- import { LIVE_PATCH_GLOBAL as J, livePatchScript as U, patchDocument as Y, typesetPatch as z } from "./live-patch.js";
1
+ import { O as i, P as s, S as t, b as a, d as o, a as n, c, e as l, f as p, g as P, h as d, i as E, j as m, m as v, o as S, p as u, r as A, k as f, l as g, n as h, q as B, s as w, t as _, x as R } from "./cli-CddPgMt-.js";
2
+ import { injectRevealBridge as b, isRevealView as x, revealBridgeScript as T } from "./reveal.js";
3
+ import { describeAsset as I, missingAssetPlaceholder as M, missingAssetSvg as j, rewriteAssetUrls as O } from "./assets.js";
4
+ import { PREVIEW_THEME_MESSAGE as C, injectThemeBridge as D, isPreviewTheme as H, previewThemeMessage as k, themeBridgeScript as N } from "./theme.js";
5
+ import { PRINT_PREVIEW_GLOBAL as y, injectPrintPreview as F, listPrintouts as K, printPreviewBridgeScript as X, rootPrintoutId as q } from "./printout.js";
6
+ import { LIVE_PATCH_GLOBAL as U, livePatchScript as Y, patchDocument as z, typesetPatch as Q } from "./live-patch.js";
7
7
  export {
8
- J as LIVE_PATCH_GLOBAL,
9
- s as OFF_PAGE_MESSAGE,
10
- i as PREVIEW_BANNER_STORAGE_KEY,
11
- V as PREVIEW_THEME_MESSAGE,
12
- W as PRINT_PREVIEW_GLOBAL,
8
+ U as LIVE_PATCH_GLOBAL,
9
+ i as OFF_PAGE_MESSAGE,
10
+ s as PREVIEW_BANNER_STORAGE_KEY,
11
+ C as PREVIEW_THEME_MESSAGE,
12
+ y as PRINT_PREVIEW_GLOBAL,
13
13
  t as SourceCache,
14
14
  a as buildSkeleton,
15
- n as defaultSourceCache,
16
- o as defaultXslDir,
17
- G as describeAsset,
15
+ o as defaultSourceCache,
16
+ n as defaultXslDir,
17
+ I as describeAsset,
18
18
  c as detectRenderTarget,
19
19
  l as divisionLevel,
20
20
  p as findSourceMapEntry,
21
- d as forcePortablePublication,
22
- P as injectPreviewBanner,
23
- y as injectPrintPreview,
24
- L as injectRevealBridge,
25
- C as injectThemeBridge,
26
- E as isJspiAvailable,
27
- D as isPreviewTheme,
21
+ P as forcePortablePublication,
22
+ d as forcePreviewPublication,
23
+ E as injectPreviewBanner,
24
+ F as injectPrintPreview,
25
+ b as injectRevealBridge,
26
+ D as injectThemeBridge,
27
+ m as isJspiAvailable,
28
+ H as isPreviewTheme,
28
29
  x as isRevealView,
29
- F as listPrintouts,
30
- U as livePatchScript,
31
- m as measureDocument,
32
- I as missingAssetPlaceholder,
33
- M as missingAssetSvg,
30
+ K as listPrintouts,
31
+ Y as livePatchScript,
32
+ v as measureDocument,
33
+ M as missingAssetPlaceholder,
34
+ j as missingAssetSvg,
34
35
  S as openBornHiddenKnowls,
35
- Y as patchDocument,
36
- v as previewBannerScript,
37
- H as previewThemeMessage,
38
- K as printPreviewBridgeScript,
39
- u as readPublicationLevels,
40
- A as renderHtml,
41
- f as replaceDivision,
36
+ z as patchDocument,
37
+ u as previewBannerScript,
38
+ k as previewThemeMessage,
39
+ X as printPreviewBridgeScript,
40
+ A as readPublicationLevels,
41
+ f as renderHtml,
42
+ g as replaceDivision,
42
43
  T as revealBridgeScript,
43
- j as rewriteAssetUrls,
44
- g as rewriteXrefLinks,
45
- X as rootPrintoutId,
46
- h as runCli,
47
- B as setAssetsBase,
44
+ O as rewriteAssetUrls,
45
+ h as rewriteXrefLinks,
46
+ q as rootPrintoutId,
47
+ B as runCli,
48
+ w as setAssetsBase,
48
49
  _ as setMountReader,
49
- k as themeBridgeScript,
50
- z as typesetPatch,
51
- w as xpathStringLiteral
50
+ N as themeBridgeScript,
51
+ Q as typesetPatch,
52
+ R as xpathStringLiteral
52
53
  };
@@ -1,3 +1,4 @@
1
+ import { Root } from 'xast';
1
2
  import { RenderTarget } from './target.js';
2
3
  /** Optional adjustments layered onto the publication file for a render. */
3
4
  export interface PublicationOverrides {
@@ -19,36 +20,46 @@ export interface PublicationOverrides {
19
20
  target?: RenderTarget;
20
21
  }
21
22
  /**
22
- * Return publication-file XML with `<html><platform portable="yes"/></html>`
23
- * forced, preserving everything else from `publicationXml` when given.
23
+ * Return publication-file XML with the preview's settings forced (see
24
+ * {@link PREVIEW_SETTINGS}), preserving everything else from `publicationXml`
25
+ * when given.
24
26
  *
25
- * Portable mode is forced for slideshows too, even though the reveal.js
26
- * conversion never chunks: it is what sets `$cdn-prefix`, and so what puts the
27
- * PreTeXt-side css and js (sagecell, syntax highlighting, the slide styling)
28
- * on the CDN rather than at a relative path that does not exist.
27
+ * The CDN host is forced for slideshows too: it is what sets `$cdn-prefix`, and
28
+ * so what puts the PreTeXt-side css and js (sagecell, syntax highlighting, the
29
+ * slide styling) on the CDN rather than at a relative path that does not
30
+ * exist.
29
31
  */
30
- export declare function forcePortablePublication(publicationXml?: string, overrides?: PublicationOverrides): string;
32
+ export declare function forcePreviewPublication(publicationXml?: string, overrides?: PublicationOverrides): string;
31
33
  /**
32
- * Where a project's images live, as declared by
33
- * `<source><directories external generated/></source>`.
34
+ * The previous name of {@link forcePreviewPublication}, from when the preview
35
+ * forced PreTeXt's portable HTML mode.
36
+ *
37
+ * @deprecated Use {@link forcePreviewPublication}. The preview no longer uses
38
+ * portable mode, so the name no longer describes what this does.
39
+ */
40
+ export declare const forcePortablePublication: typeof forcePreviewPublication;
41
+ /**
42
+ * Where a project's images live. PreTeXt emits every asset URL under one of
43
+ * two fixed prefixes, `external/` and `generated/`, and these are the
44
+ * directories those prefixes stand for.
34
45
  *
35
46
  * Both paths are relative to the directory of the *main* source file — the one
36
47
  * holding `<pretext>` — not to whichever file is being rendered. See
37
48
  * RenderOptions.mainSourcePath.
38
49
  */
39
50
  export interface AssetDirectories {
40
- /** e.g. "../assets/" — trailing slash, relative to the main source dir. */
51
+ /**
52
+ * e.g. "../assets/" — trailing slash, relative to the main source dir.
53
+ * Undefined when nothing declares one, which upstream reads as "this
54
+ * project has no external assets".
55
+ */
41
56
  external?: string;
42
- /** e.g. "../generated-assets/" — likewise. */
43
- generated?: string;
44
57
  /**
45
- * True when the publication declares both attributes ("managed
46
- * directories"). Only then does PreTeXt emit asset URLs under the fixed
47
- * `external/` and `generated/` prefixes that {@link rewriteAssetUrls} keys
48
- * on; legacy projects emit bare or `images/`-prefixed paths that cannot be
49
- * told apart from anything else, so the preview leaves them alone.
58
+ * e.g. "../generated-assets/" — likewise. Always set: the directory is
59
+ * machine-owned, so an undeclared one defaults to "generated/" beside the
60
+ * source.
50
61
  */
51
- managed: boolean;
62
+ generated: string;
52
63
  }
53
64
  /** The depths a publication file sets numbering and the contents list to. */
54
65
  export interface PublicationLevels {
@@ -72,7 +83,29 @@ export interface PublicationLevels {
72
83
  */
73
84
  export declare function readPublicationLevels(publicationXml?: string): PublicationLevels;
74
85
  /**
75
- * Read the asset directories from a publication file, falling back to the
76
- * defaults baked into MINIMAL_PUBLICATION when none is supplied.
86
+ * Read the asset directories the way PreTeXt resolves them (as of 2026-08,
87
+ * when managed directories became the only scheme):
88
+ *
89
+ * - **external** is a property of the source. The document's
90
+ * `<docinfo><directories external="..."/>` wins; the publication file's
91
+ * `source/directories/@external` is the deprecated fallback; with neither,
92
+ * the project has no external assets.
93
+ * - **generated** is a publication setting, `source/directories/@generated`,
94
+ * and defaults to "generated/" beside the source.
95
+ *
96
+ * `docinfoExternal` is the raw `@external` from the document's docinfo, which
97
+ * the caller reads from the source (see {@link docinfoExternalDirectory}). The
98
+ * publication file falls back to MINIMAL_PUBLICATION when none is supplied.
99
+ */
100
+ export declare function readAssetDirectories(publicationXml?: string, docinfoExternal?: string): AssetDirectories;
101
+ /**
102
+ * The raw `directories/@external` of a document's `<docinfo>`, or undefined
103
+ * when it declares none. `root` is a parsed document (whose `<pretext>` holds
104
+ * the docinfo), or a `<docinfo>` on its own — parsed, or as the XML string a
105
+ * fragment preview is given. Only the docinfo's direct `<directories>` child
106
+ * counts, as upstream's `$version-root/docinfo/directories` does.
107
+ *
108
+ * A string that does not parse declares nothing here; the transform reports
109
+ * the malformed docinfo itself.
77
110
  */
78
- export declare function readAssetDirectories(publicationXml?: string): AssetDirectories;
111
+ export declare function docinfoExternalDirectory(root: Root | string): string | undefined;
@@ -97,8 +97,10 @@ export interface RenderOptions extends SourceOptions {
97
97
  */
98
98
  subtree?: SubtreeOptions;
99
99
  /**
100
- * Path to a publication file. Its settings are respected except
101
- * `<html><platform portable="yes"/></html>`, which the preview forces.
100
+ * Path to a publication file. Its settings are respected except the few a
101
+ * one-page, in-memory build cannot honour, which the preview forces: css/js
102
+ * from the CDN, chunk level 0, cross-references as links rather than knowls,
103
+ * and portable mode off. See publication.ts.
102
104
  */
103
105
  publicationPath?: string;
104
106
  /**
@@ -111,7 +113,7 @@ export interface RenderOptions extends SourceOptions {
111
113
  * ignored, and with no publication file at all it themes the synthesized
112
114
  * minimal one.
113
115
  *
114
- * Portable builds load `theme-<name>.min.css` from the CDN, so an
116
+ * Previews load `theme-<name>.min.css` from the CDN, so an
115
117
  * unrecognised name renders an unstyled page. The themes the vendored
116
118
  * stylesheets know are default-modern (PreTeXt's own default), denver,
117
119
  * tacoma, salem, greeley and boulder; `custom` additionally needs a locally
@@ -378,15 +380,20 @@ export interface RenderResult {
378
380
  rootPrintout?: string;
379
381
  /**
380
382
  * Absolute directories that the `external/` and `generated/` URL prefixes in
381
- * `html` refer to, resolved from the publication file against the main
382
- * source file's directory. Feed these to `rewriteAssetUrls` to point the
383
- * page at assets the host can actually serve (see assets.ts).
383
+ * `html` refer to, resolved against the main source file's directory the way
384
+ * PreTeXt resolves them (see readAssetDirectories). Feed these to
385
+ * `rewriteAssetUrls` to point the page at assets the host can actually
386
+ * serve (see assets.ts). That covers latex-image and PreFigure diagrams
387
+ * too, which the page links like any other image.
384
388
  *
385
- * Absent for legacy projects that declare neither directory: those emit bare
386
- * or `images/`-prefixed URLs that cannot be identified reliably.
387
- */
388
- assetDirs?: {
389
- external: string;
389
+ * `generated` is always known, since an undeclared one defaults to
390
+ * `generated/` beside the source. `external` is absent when neither the
391
+ * docinfo nor the publication file declares it: the project then has no
392
+ * external assets, and any `external/` URL in the page is a dangling
393
+ * reference.
394
+ */
395
+ assetDirs: {
396
+ external?: string;
390
397
  generated: string;
391
398
  };
392
399
  }
package/dist/target.d.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  * Which PreTeXt conversion a render drives.
3
3
  *
4
4
  * The two share almost everything — the same assembly passes, the same
5
- * publication file, the same portable/CDN resource handling — and differ in
5
+ * publication file, the same CDN resource handling — and differ in
6
6
  * the stylesheet they enter through:
7
7
  *
8
8
  * "html" - assets/preview-html.xsl, wrapping pretext-html.xsl.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pretextbook/pretext-html",
3
- "version": "0.17.0",
3
+ "version": "0.18.1",
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",