postext 1.80.0 → 1.81.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/dist/__tests__/defaults/captionStyle.test.js +1 -1
- package/dist/__tests__/defaults/captionStyle.test.js.map +1 -1
- package/dist/__tests__/exports.test.js +13 -0
- package/dist/__tests__/exports.test.js.map +1 -1
- package/dist/__tests__/html-backend/htmlBook.test.d.ts +2 -0
- package/dist/__tests__/html-backend/htmlBook.test.d.ts.map +1 -0
- package/dist/__tests__/html-backend/htmlBook.test.js +130 -0
- package/dist/__tests__/html-backend/htmlBook.test.js.map +1 -0
- package/dist/__tests__/hyphenation/exceptionsByLanguage.test.d.ts +2 -0
- package/dist/__tests__/hyphenation/exceptionsByLanguage.test.d.ts.map +1 -0
- package/dist/__tests__/hyphenation/exceptionsByLanguage.test.js +60 -0
- package/dist/__tests__/hyphenation/exceptionsByLanguage.test.js.map +1 -0
- package/dist/__tests__/hyphenation/exceptionsByLanguageBook.test.d.ts +2 -0
- package/dist/__tests__/hyphenation/exceptionsByLanguageBook.test.d.ts.map +1 -0
- package/dist/__tests__/hyphenation/exceptionsByLanguageBook.test.js +87 -0
- package/dist/__tests__/hyphenation/exceptionsByLanguageBook.test.js.map +1 -0
- package/dist/__tests__/hyphenation/exceptionsFile.test.d.ts +2 -0
- package/dist/__tests__/hyphenation/exceptionsFile.test.d.ts.map +1 -0
- package/dist/__tests__/hyphenation/exceptionsFile.test.js +95 -0
- package/dist/__tests__/hyphenation/exceptionsFile.test.js.map +1 -0
- package/dist/__tests__/pipeline/resources/captionHyphenation.test.d.ts +2 -0
- package/dist/__tests__/pipeline/resources/captionHyphenation.test.d.ts.map +1 -0
- package/dist/__tests__/pipeline/resources/captionHyphenation.test.js +252 -0
- package/dist/__tests__/pipeline/resources/captionHyphenation.test.js.map +1 -0
- package/dist/defaults/resources/captionStyle.d.ts.map +1 -1
- package/dist/defaults/resources/captionStyle.js +26 -0
- package/dist/defaults/resources/captionStyle.js.map +1 -1
- package/dist/defaults/resources/tableStyle.d.ts.map +1 -1
- package/dist/defaults/resources/tableStyle.js +6 -0
- package/dist/defaults/resources/tableStyle.js.map +1 -1
- package/dist/defaults/text/bodyText/defaults.d.ts.map +1 -1
- package/dist/defaults/text/bodyText/defaults.js +7 -2
- package/dist/defaults/text/bodyText/defaults.js.map +1 -1
- package/dist/defaults/text/bodyText/resolve.d.ts.map +1 -1
- package/dist/defaults/text/bodyText/resolve.js +3 -1
- package/dist/defaults/text/bodyText/resolve.js.map +1 -1
- package/dist/html-backend/book.d.ts +93 -0
- package/dist/html-backend/book.d.ts.map +1 -0
- package/dist/html-backend/book.js +150 -0
- package/dist/html-backend/book.js.map +1 -0
- package/dist/html-backend/html-backend.d.ts +2 -0
- package/dist/html-backend/html-backend.d.ts.map +1 -1
- package/dist/html-backend/html-backend.js +3 -0
- package/dist/html-backend/html-backend.js.map +1 -1
- package/dist/hyphenation/exceptionsFile.d.ts +76 -0
- package/dist/hyphenation/exceptionsFile.d.ts.map +1 -0
- package/dist/hyphenation/exceptionsFile.js +247 -0
- package/dist/hyphenation/exceptionsFile.js.map +1 -0
- package/dist/hyphenation/hyphenate.d.ts +8 -1
- package/dist/hyphenation/hyphenate.d.ts.map +1 -1
- package/dist/hyphenation/hyphenate.js +28 -13
- package/dist/hyphenation/hyphenate.js.map +1 -1
- package/dist/hyphenation/hyphenationExceptions.d.ts +10 -0
- package/dist/hyphenation/hyphenationExceptions.d.ts.map +1 -1
- package/dist/hyphenation/hyphenationExceptions.js +30 -0
- package/dist/hyphenation/hyphenationExceptions.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/knuthPlass/richAdapter.d.ts +3 -0
- package/dist/knuthPlass/richAdapter.d.ts.map +1 -1
- package/dist/knuthPlass/richAdapter.js +2 -0
- package/dist/knuthPlass/richAdapter.js.map +1 -1
- package/dist/measure/rich/tokenize.js +1 -1
- package/dist/measure/rich/tokenize.js.map +1 -1
- package/dist/pipeline/build/pass/setup/contentSetup.d.ts +1 -0
- package/dist/pipeline/build/pass/setup/contentSetup.d.ts.map +1 -1
- package/dist/pipeline/build/pass.js +2 -1
- package/dist/pipeline/build/pass.js.map +1 -1
- package/dist/pipeline/resources/resourceLayout/captions.d.ts.map +1 -1
- package/dist/pipeline/resources/resourceLayout/captions.js +3 -2
- package/dist/pipeline/resources/resourceLayout/captions.js.map +1 -1
- package/dist/pipeline/resources/resourceLayout/resourceBlock/captionNotes.d.ts.map +1 -1
- package/dist/pipeline/resources/resourceLayout/resourceBlock/captionNotes.js +3 -2
- package/dist/pipeline/resources/resourceLayout/resourceBlock/captionNotes.js.map +1 -1
- package/dist/pipeline/resources/resourceLayout/resourceBlock.js +1 -1
- package/dist/pipeline/resources/resourceLayout/resourceBlock.js.map +1 -1
- package/dist/pipeline/resources/resourceLayout/snippets.d.ts +20 -3
- package/dist/pipeline/resources/resourceLayout/snippets.d.ts.map +1 -1
- package/dist/pipeline/resources/resourceLayout/snippets.js +35 -4
- package/dist/pipeline/resources/resourceLayout/snippets.js.map +1 -1
- package/dist/pipeline/styles.d.ts +4 -0
- package/dist/pipeline/styles.d.ts.map +1 -1
- package/dist/pipeline/styles.js +1 -1
- package/dist/pipeline/styles.js.map +1 -1
- package/dist/types/resources/tableStyles.d.ts +28 -0
- package/dist/types/resources/tableStyles.d.ts.map +1 -1
- package/dist/types/text/locale.d.ts +16 -0
- package/dist/types/text/locale.d.ts.map +1 -1
- package/dist/word/semantic/media/captions.js +1 -1
- package/dist/word/semantic/media/captions.js.map +1 -1
- package/dist/word/semantic/prose/caption.d.ts.map +1 -1
- package/dist/word/semantic/prose/caption.js +4 -3
- package/dist/word/semantic/prose/caption.js.map +1 -1
- package/dist/word/semantic/table/styles.js +2 -2
- package/dist/word/semantic/table/styles.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { presentTag, isUnhyphenatedLanguage, hyphenationLocaleFor } from '../../../hyphenation/locale.js';
|
|
2
2
|
import { colorsEqual, dimensionsEqual, startEndAsLeftRight, compositionRuleOf } from '../../shared.js';
|
|
3
3
|
import { resolveVerseConfig } from '../verse.js';
|
|
4
|
-
import { normalizeHyphenationExceptions } from '../../../hyphenation/hyphenationExceptions.js';
|
|
4
|
+
import { normalizeHyphenationExceptions, normalizeExceptionsByLanguage } from '../../../hyphenation/hyphenationExceptions.js';
|
|
5
5
|
import { withFigureStyle } from '../../../fonts/figureStyle.js';
|
|
6
6
|
import { arabicScript, emphasisAndTashkil, resolveKashida } from './arabic.js';
|
|
7
7
|
import { DEFAULT_HYPHENATION_CONFIG, DEFAULT_BLOCKQUOTE_CONFIG, DEFAULT_BODY_TEXT_CONFIG, shortListMaxItemsOf } from './defaults.js';
|
|
@@ -41,6 +41,7 @@ function resolveHyphenation(partial, documentLocale) {
|
|
|
41
41
|
: partial?.enabled ?? (isUnhyphenatedLanguage(documentLocale) ? false : D.enabled);
|
|
42
42
|
const locale = hyphenationLocaleFor(requested, enabled);
|
|
43
43
|
const exceptions = normalizeHyphenationExceptions(partial?.exceptions);
|
|
44
|
+
const exceptionsByLanguage = normalizeExceptionsByLanguage(partial?.exceptionsByLanguage);
|
|
44
45
|
return {
|
|
45
46
|
enabled,
|
|
46
47
|
locale,
|
|
@@ -49,6 +50,7 @@ function resolveHyphenation(partial, documentLocale) {
|
|
|
49
50
|
zone: partial?.zone ?? D.zone,
|
|
50
51
|
compounds: partial?.compounds ?? D.compounds,
|
|
51
52
|
...(exceptions ? { exceptions } : {}),
|
|
53
|
+
...(exceptionsByLanguage ? { exceptionsByLanguage } : {}),
|
|
52
54
|
...cleanLimits(partial),
|
|
53
55
|
capitalized: partial?.capitalized ?? D.capitalized,
|
|
54
56
|
fewerHyphens: Math.min(10, Math.max(0, Math.round(finite(partial?.fewerHyphens) ?? D.fewerHyphens))),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve.js","sourceRoot":"","sources":["../../../../src/defaults/text/bodyText/resolve.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AAC1G,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACvG,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,8BAA8B,EAAE,MAAM,+CAA+C,CAAC;
|
|
1
|
+
{"version":3,"file":"resolve.js","sourceRoot":"","sources":["../../../../src/defaults/text/bodyText/resolve.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AAC1G,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACvG,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,8BAA8B,EAAE,6BAA6B,EAAE,MAAM,+CAA+C,CAAC;AAC9H,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC/E,OAAO,EAAE,0BAA0B,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACrI,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEvD,sCAAsC;AACtC,MAAM,MAAM,GAAG,CAAC,CAAqB,EAAsB,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAA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K,KAAK,IAAI,OAAO,CAAC,sBAAsB,KAAK,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,sBAAsB,CAAC,CAAC,CAAC,wBAAwB,CAAC,sBAAsB;QACtM,aAAa,EAAE,OAAO,CAAC,aAAa,IAAI,wBAAwB,CAAC,aAAa;QAC9E,yBAAyB,EAAE,OAAO,CAAC,yBAAyB,KAAK,KAAK,IAAI,OAAO,CAAC,yBAAyB,KAAK,UAAU;YACxH,CAAC,CAAC,OAAO,CAAC,yBAAyB;YACnC,CAAC,CAAC,wBAAwB,CAAC,yBAAyB;QACtD,sBAAsB,EAAE,OAAO,CAAC,sBAAsB,KAAK,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,wBAAwB,CAAC,sBAAsB;QACpI,GAAG,kBAAkB,CAAC,OAAO,EAAE,cAAc,CAAC;KAC/C,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { CustomFontFamily, Resource } from '../types.js';
|
|
2
|
+
import type { VDTDocument } from '../vdt.js';
|
|
3
|
+
/** One `@font-face` of the page: the file's URL as the host serves it (a
|
|
4
|
+
* data URI, a path beside the page). */
|
|
5
|
+
export interface HtmlBookFace {
|
|
6
|
+
family: string;
|
|
7
|
+
weight: number | string;
|
|
8
|
+
style: string;
|
|
9
|
+
url: string;
|
|
10
|
+
/** The characters the file holds, when it is one slice of a face. */
|
|
11
|
+
unicodeRange?: string;
|
|
12
|
+
}
|
|
13
|
+
/** A family the book may not hand on (`redistributable: false`, #993):
|
|
14
|
+
* set in the open family it names as `standIn`, under its own name, or,
|
|
15
|
+
* without one, named without its file. */
|
|
16
|
+
export interface HtmlBookFontNote {
|
|
17
|
+
family: string;
|
|
18
|
+
standIn?: string;
|
|
19
|
+
}
|
|
20
|
+
/** What the page could not do as asked: the HTML backend's warnings
|
|
21
|
+
* (`html.missingImage`, `html.svgFontUnavailable`…) and the families
|
|
22
|
+
* left out of it (`fontStoodIn`, `fontWithheld`). */
|
|
23
|
+
export interface HtmlBookWarning {
|
|
24
|
+
kind: string;
|
|
25
|
+
severity: 'info' | 'warning';
|
|
26
|
+
message: string;
|
|
27
|
+
}
|
|
28
|
+
export interface RenderHtmlBookOptions {
|
|
29
|
+
/** The page's `<title>`. */
|
|
30
|
+
title: string;
|
|
31
|
+
/** The page's `lang`. */
|
|
32
|
+
lang: string;
|
|
33
|
+
/** Pages side by side (`multi`, the default) or one under another. */
|
|
34
|
+
mode?: 'single' | 'multi';
|
|
35
|
+
/** The fonts the pages are set in, as `@font-face` rules. */
|
|
36
|
+
faces: readonly HtmlBookFace[];
|
|
37
|
+
/** The families left out ({@link HtmlBookFontNote}), reported first. */
|
|
38
|
+
fontNotes?: readonly HtmlBookFontNote[];
|
|
39
|
+
/** A picture's URL by its `fileId`: the bytes of {@link htmlBookFiles}
|
|
40
|
+
* served by the host. Undefined draws a placeholder. */
|
|
41
|
+
pictureUrl: (fileId: string) => string | undefined;
|
|
42
|
+
/** A self-hosted video's URL by its `fileId`. */
|
|
43
|
+
videoUrl?: (fileId: string) => string | undefined;
|
|
44
|
+
/** Self-hosted videos shown as their posters (a page with no file
|
|
45
|
+
* beside it has no video to play). */
|
|
46
|
+
videoPosters?: boolean;
|
|
47
|
+
onWarning?: (warning: HtmlBookWarning) => void;
|
|
48
|
+
}
|
|
49
|
+
/** What a family left out of the page is reported as. */
|
|
50
|
+
export declare function fontNoteWarning(note: HtmlBookFontNote, output?: string): HtmlBookWarning;
|
|
51
|
+
/** One `@font-face` rule; `unicode-range` only on a slice. */
|
|
52
|
+
export declare function htmlFontFaceRule(face: HtmlBookFace): string;
|
|
53
|
+
/**
|
|
54
|
+
* The book's chapters (one document each, in order, as `buildBundle` or a
|
|
55
|
+
* print chain gives them) as one self-contained HTML page. The pages are
|
|
56
|
+
* the print layout in page pixels (`page.dpi`), shown at 96 dpi as a
|
|
57
|
+
* browser sizes a printed inch; the paper colour fills the window; a
|
|
58
|
+
* reference to a figure another chapter placed links to it; a book with
|
|
59
|
+
* exercises gets the script that makes them answerable.
|
|
60
|
+
*/
|
|
61
|
+
export declare function renderHtmlBook(docs: readonly VDTDocument[], options: RenderHtmlBookOptions): string;
|
|
62
|
+
/** A file the page refers to: a picture (SVGs as the screen shows them,
|
|
63
|
+
* recoloured for single ink) or a self-hosted video. */
|
|
64
|
+
export interface HtmlBookFile {
|
|
65
|
+
fileId: string;
|
|
66
|
+
kind: 'picture' | 'video';
|
|
67
|
+
/** The bytes to serve, or the SVG markup. */
|
|
68
|
+
content: Uint8Array | string;
|
|
69
|
+
}
|
|
70
|
+
/** The pictures (and, with `videos`, the self-hosted videos) the book's
|
|
71
|
+
* resources name and `bytesOf` has, in the order the resources list
|
|
72
|
+
* them, each once. `inkHex`: the single-ink colour (`diagramInkHex`), or
|
|
73
|
+
* null. */
|
|
74
|
+
export declare function htmlBookFiles(resources: readonly Resource[], bytesOf: (fileId: string) => Uint8Array | undefined, options: {
|
|
75
|
+
inkHex: string | null;
|
|
76
|
+
videos?: boolean;
|
|
77
|
+
}): HtmlBookFile[];
|
|
78
|
+
/**
|
|
79
|
+
* The faces a file that leaves the app may carry (#993): every face of
|
|
80
|
+
* `used` but those of a family marked `redistributable: false`, whose
|
|
81
|
+
* place is taken by the faces `standIn` gives for it (the open family it
|
|
82
|
+
* names as its fallback, under its own name), once per family. The notes
|
|
83
|
+
* say which families were stood in or left without a file.
|
|
84
|
+
*/
|
|
85
|
+
export declare function redistributableFaces<F extends {
|
|
86
|
+
family: string;
|
|
87
|
+
}>(used: Iterable<F>, customFonts: readonly Pick<CustomFontFamily, 'name' | 'redistributable'>[] | undefined, standIn: (family: string) => Promise<(F & {
|
|
88
|
+
standsInFor?: string;
|
|
89
|
+
})[]>): Promise<{
|
|
90
|
+
faces: F[];
|
|
91
|
+
notes: HtmlBookFontNote[];
|
|
92
|
+
}>;
|
|
93
|
+
//# sourceMappingURL=book.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"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EAAE,CAAA;CAAE,CAAC,CAsBpD"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
// A whole book as one HTML page (#1544): every chapter's pages, positioned
|
|
2
|
+
// text the browser can select, search and read aloud, with the page's
|
|
3
|
+
// fonts, the exercise script and the links between chapters. The command
|
|
4
|
+
// line's `postext html` and the Sandbox's Library (Download as HTML) both
|
|
5
|
+
// write the page here; each host resolves where pictures, videos and font
|
|
6
|
+
// files live (data URIs, files beside the page) and hands over the URLs.
|
|
7
|
+
// No file system, no DOM: the module runs in Node, Bun, a page or a worker.
|
|
8
|
+
import { applySingleInkToSvg } from '../svg/singleInk.js';
|
|
9
|
+
import { screenSvgColors } from '../svg/spotPaints.js';
|
|
10
|
+
import { exerciseDataOf } from '../exercises/digital.js';
|
|
11
|
+
import { EXERCISE_SCRIPT } from '../exercises/runtime.js';
|
|
12
|
+
import { formatWarning } from '../pipeline/contentWarnings.js';
|
|
13
|
+
import { anchoredResourceIds } from './segmentText.js';
|
|
14
|
+
import { HTML_TEXT_RESET, renderToHtml } from './render.js';
|
|
15
|
+
/** What a family left out of the page is reported as. */
|
|
16
|
+
export function fontNoteWarning(note, output = 'HTML') {
|
|
17
|
+
return note.standIn
|
|
18
|
+
? { kind: 'fontStoodIn', severity: 'info', message: `"${note.family}" may not be copied out of the book: the ${output} sets it in ${note.standIn}, under the same name` }
|
|
19
|
+
: { kind: 'fontWithheld', severity: 'info', message: `"${note.family}" may not be copied out of the book: the ${output} names it without its file` };
|
|
20
|
+
}
|
|
21
|
+
const escapeHtml = (s) => s.replace(/[&<>"]/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"' })[c]);
|
|
22
|
+
/** One `@font-face` rule; `unicode-range` only on a slice. */
|
|
23
|
+
export function htmlFontFaceRule(face) {
|
|
24
|
+
return `@font-face{font-family:${JSON.stringify(face.family)};font-weight:${face.weight};font-style:${face.style};font-display:block;src:url(${JSON.stringify(face.url)})${face.unicodeRange ? `;unicode-range:${face.unicodeRange}` : ''}}`;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The book's chapters (one document each, in order, as `buildBundle` or a
|
|
28
|
+
* print chain gives them) as one self-contained HTML page. The pages are
|
|
29
|
+
* the print layout in page pixels (`page.dpi`), shown at 96 dpi as a
|
|
30
|
+
* browser sizes a printed inch; the paper colour fills the window; a
|
|
31
|
+
* reference to a figure another chapter placed links to it; a book with
|
|
32
|
+
* exercises gets the script that makes them answerable.
|
|
33
|
+
*/
|
|
34
|
+
export function renderHtmlBook(docs, options) {
|
|
35
|
+
const { onWarning } = options;
|
|
36
|
+
for (const note of options.fontNotes ?? [])
|
|
37
|
+
onWarning?.(fontNoteWarning(note));
|
|
38
|
+
const refTargets = new Set(docs.flatMap((d) => [...anchoredResourceIds(d)]));
|
|
39
|
+
// The URLs serve the pictures as the screen shows them (single ink
|
|
40
|
+
// applied by htmlBookFiles): no filter on top.
|
|
41
|
+
const resourceImageUrl = Object.assign((fileId) => options.pictureUrl(fileId), { singleInk: false });
|
|
42
|
+
const renderOptions = {
|
|
43
|
+
mode: options.mode ?? 'multi',
|
|
44
|
+
refTargets,
|
|
45
|
+
resourceImageUrl,
|
|
46
|
+
resourceVideoUrl: (fileId) => options.videoUrl?.(fileId),
|
|
47
|
+
...(options.videoPosters ? { videos: { files: 'poster' } } : {}),
|
|
48
|
+
singleInk: false,
|
|
49
|
+
onWarning: (w) => onWarning?.({ kind: `html.${w.kind}`, severity: 'warning', message: formatWarning(w) }),
|
|
50
|
+
};
|
|
51
|
+
const body = docs.map((d) => renderToHtml(d, renderOptions)).join('\n');
|
|
52
|
+
// Exercises (#1230): the script that makes them answerable, checks
|
|
53
|
+
// them and keeps the answers in the browser, under the file's path.
|
|
54
|
+
const exercises = docs.some((d) => exerciseDataOf(d) !== undefined)
|
|
55
|
+
? `<script>${EXERCISE_SCRIPT.replace(/<\/(script)/gi, '<\\/$1')}</script>`
|
|
56
|
+
: '';
|
|
57
|
+
// The pages are the print layout, in page pixels (page.dpi, 300 by
|
|
58
|
+
// default): shown at 96 dpi, as a browser sizes a printed inch.
|
|
59
|
+
const dpi = docs[0]?.config.page.dpi ?? 96;
|
|
60
|
+
const zoom = Math.round((96 / dpi) * 10000) / 10000;
|
|
61
|
+
// The paper colour fills the window, as in the Sandbox's HTML view
|
|
62
|
+
// (a translucent colour over white).
|
|
63
|
+
const paper = docs[0]?.config.page.backgroundColor?.hex;
|
|
64
|
+
const background = !paper || paper === 'transparent' ? '#ffffff' : `linear-gradient(${paper},${paper}),#ffffff`;
|
|
65
|
+
return [
|
|
66
|
+
'<!doctype html>',
|
|
67
|
+
`<html lang="${escapeHtml(options.lang)}">`,
|
|
68
|
+
'<head>',
|
|
69
|
+
'<meta charset="utf-8">',
|
|
70
|
+
'<meta name="viewport" content="width=device-width, initial-scale=1">',
|
|
71
|
+
`<meta name="generator" content="postext">`,
|
|
72
|
+
`<title>${escapeHtml(options.title)}</title>`,
|
|
73
|
+
'<style>',
|
|
74
|
+
...options.faces.map(htmlFontFaceRule),
|
|
75
|
+
`html,body{margin:0;background:${background}}body{${HTML_TEXT_RESET}}`,
|
|
76
|
+
`.postext-book{zoom:${zoom};padding:24px 0}`,
|
|
77
|
+
'.postext-book .pt-page{margin-left:auto;margin-right:auto}',
|
|
78
|
+
'</style>',
|
|
79
|
+
'</head>',
|
|
80
|
+
'<body>',
|
|
81
|
+
'<main class="postext-book">',
|
|
82
|
+
body,
|
|
83
|
+
'</main>',
|
|
84
|
+
...(exercises ? [exercises] : []),
|
|
85
|
+
'</body>',
|
|
86
|
+
'</html>',
|
|
87
|
+
'',
|
|
88
|
+
].join('\n');
|
|
89
|
+
}
|
|
90
|
+
/** The pictures (and, with `videos`, the self-hosted videos) the book's
|
|
91
|
+
* resources name and `bytesOf` has, in the order the resources list
|
|
92
|
+
* them, each once. `inkHex`: the single-ink colour (`diagramInkHex`), or
|
|
93
|
+
* null. */
|
|
94
|
+
export function htmlBookFiles(resources, bytesOf, options) {
|
|
95
|
+
const out = [];
|
|
96
|
+
const seen = new Set();
|
|
97
|
+
for (const r of resources) {
|
|
98
|
+
const fileId = r.kind === 'svg' ? r.svg?.fileId : r.kind === 'bitmap' ? r.bitmap?.fileId : r.kind === 'video' ? r.video?.poster?.fileId : undefined;
|
|
99
|
+
const bytes = fileId ? bytesOf(fileId) : undefined;
|
|
100
|
+
if (fileId && bytes && !seen.has(fileId)) {
|
|
101
|
+
seen.add(fileId);
|
|
102
|
+
// A spot ink named in a paint is the print PDF's: here, the colour.
|
|
103
|
+
const text = r.kind === 'svg' ? new TextDecoder().decode(bytes) : undefined;
|
|
104
|
+
const svg = text !== undefined ? screenSvgColors(text) : undefined;
|
|
105
|
+
const content = svg !== undefined && (options.inkHex || svg !== text) ? (options.inkHex ? applySingleInkToSvg(svg, options.inkHex) : svg) : bytes;
|
|
106
|
+
out.push({ fileId, kind: 'picture', content });
|
|
107
|
+
}
|
|
108
|
+
// Self-hosted videos go beside the page; embedded, they show their poster.
|
|
109
|
+
const video = r.kind === 'video' ? r.video?.fileId : undefined;
|
|
110
|
+
const videoBytes = video && options.videos ? bytesOf(video) : undefined;
|
|
111
|
+
if (video && videoBytes && !seen.has(video)) {
|
|
112
|
+
seen.add(video);
|
|
113
|
+
out.push({ fileId: video, kind: 'video', content: videoBytes });
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return out;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* The faces a file that leaves the app may carry (#993): every face of
|
|
120
|
+
* `used` but those of a family marked `redistributable: false`, whose
|
|
121
|
+
* place is taken by the faces `standIn` gives for it (the open family it
|
|
122
|
+
* names as its fallback, under its own name), once per family. The notes
|
|
123
|
+
* say which families were stood in or left without a file.
|
|
124
|
+
*/
|
|
125
|
+
export async function redistributableFaces(used, customFonts, standIn) {
|
|
126
|
+
const withheld = new Set((customFonts ?? []).filter((f) => f.redistributable === false).map((f) => f.name.toLowerCase()));
|
|
127
|
+
const faces = [];
|
|
128
|
+
const notes = [];
|
|
129
|
+
const told = new Set();
|
|
130
|
+
for (const f of used) {
|
|
131
|
+
const key = f.family.toLowerCase();
|
|
132
|
+
if (!withheld.has(key)) {
|
|
133
|
+
faces.push(f);
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
if (told.has(key))
|
|
137
|
+
continue;
|
|
138
|
+
told.add(key);
|
|
139
|
+
const stand = await standIn(f.family);
|
|
140
|
+
if (stand.length > 0) {
|
|
141
|
+
notes.push({ family: f.family, standIn: stand[0].standsInFor ?? f.family });
|
|
142
|
+
faces.push(...stand);
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
notes.push({ family: f.family });
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return { faces, notes };
|
|
149
|
+
}
|
|
150
|
+
//# sourceMappingURL=book.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"book.js","sourceRoot":"","sources":["../../src/html-backend/book.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,sEAAsE;AACtE,yEAAyE;AACzE,0EAA0E;AAC1E,0EAA0E;AAC1E,yEAAyE;AACzE,4EAA4E;AAK5E,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,YAAY,EAA0B,MAAM,aAAa,CAAC;AAoDpF,yDAAyD;AACzD,MAAM,UAAU,eAAe,CAAC,IAAsB,EAAE,MAAM,GAAG,MAAM;IACrE,OAAO,IAAI,CAAC,OAAO;QACjB,CAAC,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE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AAC;QACrB,MAAM,GAAG,GAAG,CAAC,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;QACnC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YACvB,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YACd,SAAS;QACX,CAAC;QACD,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;YAAE,SAAS;QAC5B,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACd,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;QACtC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACrB,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,CAAE,CAAC,WAAW,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;YAC7E,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC;QACvB,CAAC;aAAM,CAAC;YACN,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;QACnC,CAAC;IACH,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;AAC1B,CAAC"}
|
|
@@ -2,4 +2,6 @@ export { HTML_TEXT_RESET, renderToHtmlIndexed, renderToHtml } from './render.js'
|
|
|
2
2
|
export type { RenderHtmlOptions, HtmlRenderIndexPage, HtmlRenderIndex } from './render.js';
|
|
3
3
|
export { anchoredResourceIds } from './segmentText.js';
|
|
4
4
|
export { tintHex, tintFilterElement } from './images.js';
|
|
5
|
+
export { renderHtmlBook, htmlBookFiles, htmlFontFaceRule, redistributableFaces, fontNoteWarning } from './book.js';
|
|
6
|
+
export type { RenderHtmlBookOptions, HtmlBookFace, HtmlBookFile, HtmlBookFontNote, HtmlBookWarning } from './book.js';
|
|
5
7
|
//# sourceMappingURL=html-backend.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html-backend.d.ts","sourceRoot":"","sources":["../../src/html-backend/html-backend.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACjF,YAAY,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC3F,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"html-backend.d.ts","sourceRoot":"","sources":["../../src/html-backend/html-backend.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACjF,YAAY,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC3F,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGzD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACnH,YAAY,EAAE,qBAAqB,EAAE,YAAY,EAAE,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export { HTML_TEXT_RESET, renderToHtmlIndexed, renderToHtml } from './render.js';
|
|
2
2
|
export { anchoredResourceIds } from './segmentText.js';
|
|
3
3
|
export { tintHex, tintFilterElement } from './images.js';
|
|
4
|
+
// A whole book as one HTML page (#1544): the CLI's `postext html` and the
|
|
5
|
+
// Sandbox's Library write it here.
|
|
6
|
+
export { renderHtmlBook, htmlBookFiles, htmlFontFaceRule, redistributableFaces, fontNoteWarning } from './book.js';
|
|
4
7
|
//# sourceMappingURL=html-backend.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html-backend.js","sourceRoot":"","sources":["../../src/html-backend/html-backend.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEjF,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"html-backend.js","sourceRoot":"","sources":["../../src/html-backend/html-backend.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEjF,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACzD,0EAA0E;AAC1E,mCAAmC;AACnC,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { HyphenationConfig } from '../types.js';
|
|
2
|
+
/** The key of a JSON exception file that stands for every language: its
|
|
3
|
+
* list goes to `exceptions`. An empty key reads the same. */
|
|
4
|
+
export declare const ALL_LANGUAGES_KEY = "*";
|
|
5
|
+
/** What an exception file holds. */
|
|
6
|
+
export interface HyphenationExceptionsFile {
|
|
7
|
+
/** The words of a list that names no language (plain text, a TeX
|
|
8
|
+
* `\hyphenation{…}` block, a JSON array): the reader decides which list
|
|
9
|
+
* they go to. */
|
|
10
|
+
words: string[];
|
|
11
|
+
/** The lists of a JSON object, by its keys: a language tag, or
|
|
12
|
+
* {@link ALL_LANGUAGES_KEY} for every language. */
|
|
13
|
+
byLanguage: Record<string, string[]>;
|
|
14
|
+
/** Entries read and left out: what the engine cannot hold (digits,
|
|
15
|
+
* punctuation, no letter). */
|
|
16
|
+
dropped: string[];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The lists of an exception file, in any of the shapes such lists come in:
|
|
20
|
+
* words separated by new lines, commas, semicolons or spaces, with `#`, `%`
|
|
21
|
+
* and `//` comment lines; the `\hyphenation{…}` blocks of a TeX file (only
|
|
22
|
+
* those); a JSON array of words; or a JSON object of lists keyed by
|
|
23
|
+
* language tag, `"*"` for every language. A break may be marked with a
|
|
24
|
+
* hyphen, a soft hyphen, a hyphenation point (U+2027), `=` or tildes, and a
|
|
25
|
+
* leading `~` keeps the word whole. A word given twice keeps its last form.
|
|
26
|
+
*/
|
|
27
|
+
export declare function parseHyphenationExceptionsFile(text: string): HyphenationExceptionsFile;
|
|
28
|
+
/** An exception list as a file: two comment lines (whose list it is, how
|
|
29
|
+
* to read it), then one word per line. {@link parseHyphenationExceptionsFile}
|
|
30
|
+
* reads it back as it was. */
|
|
31
|
+
export declare function formatHyphenationExceptionsFile(words: readonly string[], language?: string): string;
|
|
32
|
+
/** What {@link mergeHyphenationExceptions} gives. */
|
|
33
|
+
export interface HyphenationExceptionsMerge {
|
|
34
|
+
/** The merged list, as the engine keeps it (checked, sorted). */
|
|
35
|
+
words: string[];
|
|
36
|
+
/** Words the list did not have. */
|
|
37
|
+
added: number;
|
|
38
|
+
/** Words the list had in another form, now in the new one. */
|
|
39
|
+
replaced: number;
|
|
40
|
+
}
|
|
41
|
+
/** `current` with `incoming` merged in: an incoming entry replaces the
|
|
42
|
+
* entry for the same word (`desa-rro-llo` replaces `de-sa-rro-llo`), the
|
|
43
|
+
* rest is kept. */
|
|
44
|
+
export declare function mergeHyphenationExceptions(current: readonly string[], incoming: readonly string[]): HyphenationExceptionsMerge;
|
|
45
|
+
/** The list a language's text is divided with, as written in `hyphenation`:
|
|
46
|
+
* `exceptions` for every language ({@link ALL_LANGUAGES_KEY} or none), else
|
|
47
|
+
* the `exceptionsByLanguage` lists of every tag that shares its
|
|
48
|
+
* dictionary. */
|
|
49
|
+
export declare function hyphenationExceptionsFor(hyphenation: HyphenationConfig | undefined, language?: string): string[];
|
|
50
|
+
/** `hyphenation` with one list replaced: `exceptions` for every language,
|
|
51
|
+
* else the language's list in `exceptionsByLanguage`, kept under the tag
|
|
52
|
+
* already written for its dictionary (other tags of that dictionary are
|
|
53
|
+
* merged into it). An empty list takes the field out. */
|
|
54
|
+
export declare function withHyphenationExceptions(hyphenation: HyphenationConfig | undefined, words: readonly string[] | undefined, language?: string): HyphenationConfig;
|
|
55
|
+
/** What {@link mergeHyphenationExceptionsFile} gives. */
|
|
56
|
+
export interface HyphenationExceptionsFileMerge {
|
|
57
|
+
hyphenation: HyphenationConfig;
|
|
58
|
+
/** Words the lists did not have. */
|
|
59
|
+
added: number;
|
|
60
|
+
/** Words the lists had in another form. */
|
|
61
|
+
replaced: number;
|
|
62
|
+
/** Entries left out: the file's dropped ones, and the words of a list
|
|
63
|
+
* for a language with no patterns of its own. */
|
|
64
|
+
dropped: number;
|
|
65
|
+
/** The languages of the file with no patterns of their own (`el`, `ar`):
|
|
66
|
+
* their lists are left out. */
|
|
67
|
+
unknownLanguages: string[];
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* `hyphenation` with an exception file merged in: the file's unkeyed words
|
|
71
|
+
* into the list of `language` (`exceptions` when it names none, or
|
|
72
|
+
* {@link ALL_LANGUAGES_KEY}), each keyed list into its own (`"*"` into
|
|
73
|
+
* `exceptions`), an entry replacing the entry for the same word.
|
|
74
|
+
*/
|
|
75
|
+
export declare function mergeHyphenationExceptionsFile(hyphenation: HyphenationConfig | undefined, file: HyphenationExceptionsFile, language?: string): HyphenationExceptionsFileMerge;
|
|
76
|
+
//# sourceMappingURL=exceptionsFile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
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