epub-codec 1.2.3 → 1.2.5
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 +3 -2
- package/dist/codec.d.cts +24 -24
- package/dist/codec.d.ts +24 -24
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/xhtml/inline.cjs +13 -3
- package/dist/xhtml/inline.d.cts +2 -1
- package/dist/xhtml/inline.d.ts +2 -1
- package/dist/xhtml/inline.js +13 -4
- package/dist/xhtml/read.cjs +23 -43
- package/dist/xhtml/read.js +24 -44
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -132,8 +132,9 @@ Every construct this package's XHTML mapping cannot represent losslessly is a do
|
|
|
132
132
|
- **`epub/style-residue`** — a document's own `<head>` style declarations (`<link rel="stylesheet">`, `<style>`) are quarantined verbatim as `SourceResidue` on the owning `ContentSection`, never interpreted: CSS is residue, not content. `writeEpubContent` re-emits it into the written `<head>` on a same-format write (this family's standard restorable-fidelity re-emission contract).
|
|
133
133
|
- **An empty or whitespace-only paragraph (`<p></p>`, `<p> </p>`, or bare whitespace text between two block-level siblings — the common case in any pretty-printed real EPUB) is dropped entirely on read**, matching the same "anonymous block box" rule a browser's own HTML block-formatting context already applies to inter-block whitespace, rather than becoming a bogus empty `ContentParagraph`.
|
|
134
134
|
- **List marker type (bullet vs. ordered, and an `<ol>`'s own non-default `start`) is packed into the opaque `numId`** (`epub{N}:{bullet|ordered}[@{start}]`, `src/xhtml/list-id.ts`), since `ContentListMembership` carries no field of its own for it — the identical mechanism `markdown-codec`'s own `src/shared/list-id.ts` uses for its GFM bullet/ordered distinction, hand-mirrored rather than shared. A numId outside this grammar (odf.js's bare `"list1"`, markdown-codec's own `"md1:bullet"`) is read back as an ordinary bullet list with no declared start.
|
|
135
|
-
- **A container's own direct-child `<img>`** (some producers/editors wrap every floating image in a paragraph tag rather than a `<figure>`) is split at the image by `readContainerChildren`: the phrasing content before and after becomes its own paragraph (dropped entirely when empty), the image its own block, in source order. That split fires for every container this package reads transparently through `readContainerChildren` — `<body>` itself, `<p>`, `<li>`, `<blockquote>`, `<figure>`, `<div>`, `<section>`, `<article>`, `<aside>`, and `<nav>` — never only a named handful of them; an `<img>` reached anywhere else — nested inside a `<span>`/`<a>` at any depth, or a _direct_ child of a heading
|
|
136
|
-
- **A run-level construct extent (most commonly a footnote reference) carried by inline content built directly into a paragraph is preserved on that paragraph's own `constructs` field wherever such a paragraph is built** — a heading
|
|
135
|
+
- **A container's own direct-child `<img>`** (some producers/editors wrap every floating image in a paragraph tag rather than a `<figure>`) is split at the image by `readContainerChildren`: the phrasing content before and after becomes its own paragraph (dropped entirely when empty), the image its own block, in source order. That split fires for every container this package reads transparently through `readContainerChildren` — `<body>` itself, `<p>`, `<li>`, `<blockquote>`, `<figure>`, `<div>`, `<section>`, `<article>`, `<aside>`, and `<nav>` — never only a named handful of them; an `<img>` reached anywhere else — nested inside a `<span>`/`<a>` at any depth, or a _direct_ child of a heading (the one container this package still reads via a single `buildInlineRuns` call rather than `readContainerChildren`) — is instead reached by `src/xhtml/inline.ts`'s own run-building recursion, which by that point has committed to producing a flat run sequence with no block list left to insert a sibling image block into, and degrades to its alt text (or nothing, when it carries none) with an `epub/image-inline-unsupported` diagnostic rather than silently vanishing. A `<caption>`, `<dt>`/`<dd>`, `<figcaption>`, and a table cell all route through `readContainerChildren` too ([ExaDev/documents.js#1023](https://github.com/ExaDev/documents.js/issues/1023) — see the dedicated bullet below), so a direct-child `<img>` in any of them now becomes a real `ContentImageBlock` the same way, rather than degrading. [ExaDev/documents.js#994](https://github.com/ExaDev/documents.js/issues/994) closed the four remaining silent gaps this guarantee did not originally cover: a non-empty `<caption>`, a legal direct child of `<table>`, is now read as one or more ordinary blocks immediately before the table (`epub/table-caption-unsupported`, fired once per `<caption>` element regardless of how many blocks it decomposes into, since `ContentTable` has no field of its own for a caption's distinct tag; a run-level construct the caption's own inline content carries — a footnote reference, most commonly — rides its own paragraph's `constructs` field exactly like any other paragraph's), while an empty or whitespace-only `<caption>` is dropped entirely instead, with no diagnostic, matching this package's own empty-paragraph-drop rule documented above; a `<dl>` wrapping one or more `dt`/`dd` pairs in a `<div>` (legal HTML5, used for a per-entry styling hook) is now recognised by recursing into the `<div>`, with no diagnostic at all, since the wrapper carries no properties of its own to lose (identical to every other `<div>` this package already reads transparently); and any content — a nested `<ul>`/`<ol>`, a bare `<img>`, stray text — sitting directly inside a `<ul>`/`<ol>` rather than inside an `<li>` (not valid HTML5, but a shape real-world converters do emit) is now recovered via `epub/list-content-outside-item`, through the same `readContainerChildren` dispatch an `<li>`'s real children already use: content sitting between or after real `<li>` siblings attaches to the preceding item's own nesting — a stray list shares its numId and increments its level, exactly as if it had been nested correctly — while content sitting before the very first `<li>` has no preceding item to attach to and is instead recovered inheriting whatever list membership its own enclosing context already carries (none, unless the `<ul>`/`<ol>` it sits directly inside is itself nested inside another list's `<li>`), landing in the read result immediately before the list's own real items — matching a browser's rendering order for this shape, though not necessarily its nesting depth when the enclosing list is itself nested. One part of the original finding remains a genuine, permanent structural limit rather than a recovered gap: an `<img>` inside a `<pre>`/`<code>` block still cannot become a real `ContentImageBlock` — this package always reads a `<pre>` as a single text-content paragraph, so there is no block list to insert an image block into, the same constraint `epub/image-inline-unsupported` already names elsewhere (the HTML Standard's own content model for `<pre>` is phrasing content, not plain text, which is exactly why `<a>`/`<code>`/`<span>`/`<img>`/`<br>` are legal, real markup inside one and this package's `readPreRuns`/`readPreText` have to handle each explicitly) — but it no longer vanishes silently either; its alt text (or nothing, when it carries none) is spliced into the extracted text in its place, with an `epub/image-pre-unsupported` diagnostic firing unconditionally — every image inside a `<pre>`, not only one with no alt text.
|
|
136
|
+
- **A run-level construct extent (most commonly a footnote reference) carried by inline content built directly into a paragraph is preserved on that paragraph's own `constructs` field wherever such a paragraph is built** — a heading and `readContainerChildren`'s own segment flush both share `constructsField`, the one helper `src/xhtml/read.ts` funnels every such paragraph through, so a fix applied to one cannot silently miss the other. A table caption, a table cell, a `<dt>`/`<dd>`, and a `<figcaption>` get this for free by routing through `readContainerChildren` ([ExaDev/documents.js#1023](https://github.com/ExaDev/documents.js/issues/1023)) rather than needing their own direct call to the helper. A `<pre>`/`<code>` block's own paragraph shares it too, and round-trips it in both directions, despite never routing through `buildInlineRuns` (a `<pre>`'s content model needs its text preserved verbatim, which `buildInlineRuns`'s own whitespace normalisation would break): on read, `readPreRuns`, a dedicated run-splitting walk reached only once a cheap subtree pre-check confirms the `<pre>` actually carries a recognised footnote reference somewhere inside it, brackets that reference's own text as its own run range exactly like `src/xhtml/inline.ts`'s `appendAnchor` does, rebasing any nested call's own construct indices onto the outer run sequence at the point of the merge; the common case (no footnote reference anywhere in the block) still takes the cheap, single-run `readPreText` path unchanged. Because a construct nested inside a `<pre>` can split its content into more than one run with no bearing on whether the block is itself preformatted, `readPre` also stamps every paragraph it produces with `document-schema.js`'s own `ContentParagraph.preformatted` flag, unconditionally and regardless of run count — the one signal the writer can trust, since inferring "this was a `<pre>`" from run shape (a lone monospace run, say) silently misclassifies a multi-run one as an ordinary paragraph the moment it carries a construct. On write, `isPreBlockParagraph` checks `preformatted` first (falling back to `codeLanguage` or the legacy single-monospace-run-with-a-newline heuristic for a foreign producer's document that sets neither), and a recognised `<pre>` paragraph's own runs and constructs are written through `writePreRunsToNodes` — the `<pre>` twin of the ordinary paragraph writer, sharing its extent-finding walk but writing a run's embedded newline as a literal `"\n"` character rather than splitting it into a `<br/>` the way the ordinary path does; `readPreRuns`/`readPreText` map a `<br>` read back from a `<pre>` straight to the same literal `"\n"`, so either spelling round-trips to identical text. A stray element sitting where only a narrower set of tags is expected is likewise recovered rather than dropped, following the same `readContainerChildren`-plus-diagnostic pattern `epub/list-content-outside-item` already established: a `<dl>` (or one of its `<div>` wrappers) carrying anything other than `dt`/`dd`/`<div>` — a stray `<p>`, stray text, a stray `<img>`, or a non-conformant wrapper like `<section>` used in `<div>`'s own place — is recovered via `epub/definition-list-content-outside-entry` (a non-conformant wrapper's own `dt`/`dd` children lose their distinct term/definition treatment once routed this way, degrading to plain concatenated text — a real fidelity cost, but a text-preserving one). The same treatment applies to a `<table>`: content sitting outside any row, caption, or `<colgroup>` — whether directly inside the `<table>` itself, inside one of its `<thead>`/`<tbody>`/`<tfoot>` row groups (which admit only `tr` and script-supporting children per the HTML Standard), or inside a `<colgroup>` itself (which admits only `<col>` and `<template>` children per the HTML Standard — narrower than the script-supporting category, since a `<colgroup>` does not admit a bare `<script>`) — is recovered immediately before the table via `epub/table-content-unrecognized`; a `<tr>` carrying content outside any `<td>`/`<th>` is recovered as its own cell in the row's own column sequence via `epub/table-row-content-outside-cell`; and a `<table>` carrying more than one `<caption>` (HTML5 permits at most one) has every caption beyond the first read as its own paragraph too, via `epub/table-duplicate-caption`, rather than `findChildElement`'s own first-match-only resolution silently discarding it as it previously did. `<script>`, `<template>`, `<style>`, and `<noscript>` appearing anywhere in `<body>` content are all now skipped by one shared guard (`isInertElement`, `src/xhtml/context.ts`) rather than leaking their own raw content as document prose — none of the four were inert outside `<head>`-level residue quarantine before this fix. `<script>`'s raw JS and `<template>`'s inert DOM subtree are never real content regardless of where they are found, and a body-level `<style>` is CSS, exactly like the `<head>`-level style residue this package already quarantines rather than interprets — none of the three fire a diagnostic, since none of them ever carry anything document-schema.js's vocabulary could represent. `<noscript>` is treated the same conservative way for a different reason: its own children ARE ordinary markup a scripting-disabled reading system would genuinely render, but this package cannot tell that case apart from a producer's own "please enable JavaScript" placeholder from the markup alone — so, unlike the other three, dropping a `<noscript>`'s subtree fires its own `epub/noscript-content-skipped` diagnostic (`reportInertElementSkip`, `src/xhtml/context.ts`) at every site that discards one, naming the potential loss rather than staying silent about it.
|
|
137
|
+
- **A `<caption>`, `<dt>`, `<dd>`, `<figcaption>`, `<td>`, or `<th>` now recognises real block-level content rather than flattening it** ([ExaDev/documents.js#1023](https://github.com/ExaDev/documents.js/issues/1023)) — all six are Flow content per the HTML Standard, so a `<pre>`, a nested list, or more than one paragraph inside one is real, conformant markup. These six used to build their content with one bare `buildInlineRuns` call each; a block element reached that way has no case in `buildInlineRuns`'s own dispatch, so it fell into the same treatment as a `<span>`, recursing into its children as ordinary phrasing content — losing a `<pre>`'s own block shape, `preformatted` flag, `codeLanguage`, and verbatim whitespace, and, separately, concatenating more than one paragraph-shaped child into one undelimited run with no break (or even a word boundary) between them: `<td><p>Alpha</p><p>Beta</p></td>` used to read as the single run `"AlphaBeta"`. All six now route through `readContainerChildren` instead, the same general block-container reader `<p>`/`<li>`/`<blockquote>`/`<figure>`/`<div>`/`<section>`/`<article>`/`<aside>`/`<nav>` already use, so a `<pre>` stays preformatted, a nested list stays real list structure, and sibling paragraphs stay distinct. `<dd>`'s own `DEFINITION_BODY_INDENT_PT` offset is threaded through a `BuildState.extraIndentPt` field (additive with blockquote nesting's own `quoteDepth`, mirrored via the identical `withQuote`/`withExtraIndent` pattern) so every paragraph the descent produces picks up the indent, not only a single top-level one; a `<th>`'s own implied bold is threaded through as `readContainerChildren`'s own `baseStyle` parameter, reaching every direct phrasing segment but not content nested inside a further block-level child (a `<table>`-in-a-`<th>`, say) — a narrow, documented degrade for a genuinely rare shape, not a silent one.
|
|
137
138
|
- **A CDATA section (`<![CDATA[...]]>`) is read exactly like an ordinary text node everywhere in the XHTML reading path** — `xml/node.ts`'s `isTextLikeNode` is the one shared predicate every text-bearing walk in this package now dispatches on (`buildInlineRuns`, `readContainerChildren`'s own phrasing/block split, `readPre`'s three text-extraction paths, every stray-content collector in `read.ts`, and `xml/query.ts`'s own `decodedTextContent`), rather than each walk separately checking for `"text"` and quietly excluding `"cdata"`. A CDATA section is simply the alternate XML spelling a producer reaches for when its own literal text would otherwise need escaping (a code sample, or any other content containing a raw `<`/`&`) — exactly the kind of content a DocBook-to-EPUB pipeline or similar tool emits inside a `<pre>` — never a distinct kind of content, so treating the two differently was silently dropping real, well-formed input rather than a corpus-tolerance gap. The one place CDATA is genuinely _not_ interchangeable with a text node is entity decoding: `xml/entities.ts`'s `decodeTextLikeNode` decodes a text node's raw value exactly as before but returns a CDATA node's value untouched, since CDATA content is never subject to XML entity resolution in the first place — running it back through `decodeEntities` would corrupt exactly the unescaped content CDATA exists to carry. `xml/query.ts`'s own plain `textContent` is deliberately narrower and CDATA-blind: it is this package's long-standing published export, and a caller's own `decodeEntities(textContent(x))` idiom stays correct only because that walk never mixes in undecoded-by-design CDATA content for the wrap to misapply entity resolution to — the CDATA-aware, decode-internally behaviour lands as the distinctly named `decodedTextContent` instead, used by `opf/metadata.ts`'s own four Dublin Core readers, so upgrading to CDATA support never silently double-decodes an existing caller's text nodes.
|
|
138
139
|
- **A blockquote containing a heading cannot carry its `division` construct** — a marker extent may not open or close a heading scope, and the last heading inside an extent always leaves one standing (`document-schema.js`'s own constraint) — so it degrades to indent-only structure (still `indentLeftPt`/`styleId: "Quote"`) while the heading keeps its own heading fidelity.
|
|
139
140
|
- **Image dimensions are derived from pixel size via the CSS reference-pixel ratio (1px = 1/96in)**, not read from any `<img width>`/`<img height>` attribute or CSS: an EPUB's own XHTML/CSS carries no reliable point-based sizing of its own, so the image's natural pixel size is the one dimension every manifest image reliably has.
|
package/dist/codec.d.cts
CHANGED
|
@@ -96,9 +96,9 @@ declare const epubCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Ar
|
|
|
96
96
|
symbol: z.ZodString;
|
|
97
97
|
name: z.ZodOptional<z.ZodString>;
|
|
98
98
|
dimension: z.ZodRecord<z.ZodEnum<{
|
|
99
|
-
time: "time";
|
|
100
99
|
length: "length";
|
|
101
100
|
mass: "mass";
|
|
101
|
+
time: "time";
|
|
102
102
|
electricCurrent: "electricCurrent";
|
|
103
103
|
thermodynamicTemperature: "thermodynamicTemperature";
|
|
104
104
|
amountOfSubstance: "amountOfSubstance";
|
|
@@ -244,9 +244,9 @@ declare const epubCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Ar
|
|
|
244
244
|
symbol: z.ZodString;
|
|
245
245
|
name: z.ZodOptional<z.ZodString>;
|
|
246
246
|
dimension: z.ZodRecord<z.ZodEnum<{
|
|
247
|
-
time: "time";
|
|
248
247
|
length: "length";
|
|
249
248
|
mass: "mass";
|
|
249
|
+
time: "time";
|
|
250
250
|
electricCurrent: "electricCurrent";
|
|
251
251
|
thermodynamicTemperature: "thermodynamicTemperature";
|
|
252
252
|
amountOfSubstance: "amountOfSubstance";
|
|
@@ -392,9 +392,9 @@ declare const epubCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Ar
|
|
|
392
392
|
symbol: z.ZodString;
|
|
393
393
|
name: z.ZodOptional<z.ZodString>;
|
|
394
394
|
dimension: z.ZodRecord<z.ZodEnum<{
|
|
395
|
-
time: "time";
|
|
396
395
|
length: "length";
|
|
397
396
|
mass: "mass";
|
|
397
|
+
time: "time";
|
|
398
398
|
electricCurrent: "electricCurrent";
|
|
399
399
|
thermodynamicTemperature: "thermodynamicTemperature";
|
|
400
400
|
amountOfSubstance: "amountOfSubstance";
|
|
@@ -540,9 +540,9 @@ declare const epubCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Ar
|
|
|
540
540
|
symbol: z.ZodString;
|
|
541
541
|
name: z.ZodOptional<z.ZodString>;
|
|
542
542
|
dimension: z.ZodRecord<z.ZodEnum<{
|
|
543
|
-
time: "time";
|
|
544
543
|
length: "length";
|
|
545
544
|
mass: "mass";
|
|
545
|
+
time: "time";
|
|
546
546
|
electricCurrent: "electricCurrent";
|
|
547
547
|
thermodynamicTemperature: "thermodynamicTemperature";
|
|
548
548
|
amountOfSubstance: "amountOfSubstance";
|
|
@@ -719,9 +719,9 @@ declare const epubCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Ar
|
|
|
719
719
|
symbol: z.ZodString;
|
|
720
720
|
name: z.ZodOptional<z.ZodString>;
|
|
721
721
|
dimension: z.ZodRecord<z.ZodEnum<{
|
|
722
|
-
time: "time";
|
|
723
722
|
length: "length";
|
|
724
723
|
mass: "mass";
|
|
724
|
+
time: "time";
|
|
725
725
|
electricCurrent: "electricCurrent";
|
|
726
726
|
thermodynamicTemperature: "thermodynamicTemperature";
|
|
727
727
|
amountOfSubstance: "amountOfSubstance";
|
|
@@ -826,9 +826,9 @@ declare const epubContentCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>,
|
|
|
826
826
|
symbol: z.ZodString;
|
|
827
827
|
name: z.ZodOptional<z.ZodString>;
|
|
828
828
|
dimension: z.ZodRecord<z.ZodEnum<{
|
|
829
|
-
time: "time";
|
|
830
829
|
length: "length";
|
|
831
830
|
mass: "mass";
|
|
831
|
+
time: "time";
|
|
832
832
|
electricCurrent: "electricCurrent";
|
|
833
833
|
thermodynamicTemperature: "thermodynamicTemperature";
|
|
834
834
|
amountOfSubstance: "amountOfSubstance";
|
|
@@ -965,9 +965,9 @@ declare const epubContentCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>,
|
|
|
965
965
|
symbol: z.ZodString;
|
|
966
966
|
name: z.ZodOptional<z.ZodString>;
|
|
967
967
|
dimension: z.ZodRecord<z.ZodEnum<{
|
|
968
|
-
time: "time";
|
|
969
968
|
length: "length";
|
|
970
969
|
mass: "mass";
|
|
970
|
+
time: "time";
|
|
971
971
|
electricCurrent: "electricCurrent";
|
|
972
972
|
thermodynamicTemperature: "thermodynamicTemperature";
|
|
973
973
|
amountOfSubstance: "amountOfSubstance";
|
|
@@ -1425,11 +1425,11 @@ declare const epubContentCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>,
|
|
|
1425
1425
|
endColumn: z.ZodNumber;
|
|
1426
1426
|
}, z.core.$strip>>;
|
|
1427
1427
|
type: z.ZodEnum<{
|
|
1428
|
-
decimal: "decimal";
|
|
1429
|
-
list: "list";
|
|
1430
1428
|
date: "date";
|
|
1431
1429
|
custom: "custom";
|
|
1432
1430
|
time: "time";
|
|
1431
|
+
decimal: "decimal";
|
|
1432
|
+
list: "list";
|
|
1433
1433
|
whole: "whole";
|
|
1434
1434
|
textLength: "textLength";
|
|
1435
1435
|
}>;
|
|
@@ -1884,11 +1884,11 @@ declare const epubContentCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>,
|
|
|
1884
1884
|
stops: z.ZodArray<z.ZodObject<{
|
|
1885
1885
|
value: z.ZodObject<{
|
|
1886
1886
|
type: z.ZodEnum<{
|
|
1887
|
-
formula: "formula";
|
|
1888
1887
|
num: "num";
|
|
1889
|
-
percent: "percent";
|
|
1890
|
-
max: "max";
|
|
1891
1888
|
min: "min";
|
|
1889
|
+
max: "max";
|
|
1890
|
+
formula: "formula";
|
|
1891
|
+
percent: "percent";
|
|
1892
1892
|
percentile: "percentile";
|
|
1893
1893
|
}>;
|
|
1894
1894
|
value: z.ZodOptional<z.ZodString>;
|
|
@@ -1930,22 +1930,22 @@ declare const epubContentCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>,
|
|
|
1930
1930
|
}, z.core.$strip>, z.ZodObject<{
|
|
1931
1931
|
min: z.ZodObject<{
|
|
1932
1932
|
type: z.ZodEnum<{
|
|
1933
|
-
formula: "formula";
|
|
1934
1933
|
num: "num";
|
|
1935
|
-
percent: "percent";
|
|
1936
|
-
max: "max";
|
|
1937
1934
|
min: "min";
|
|
1935
|
+
max: "max";
|
|
1936
|
+
formula: "formula";
|
|
1937
|
+
percent: "percent";
|
|
1938
1938
|
percentile: "percentile";
|
|
1939
1939
|
}>;
|
|
1940
1940
|
value: z.ZodOptional<z.ZodString>;
|
|
1941
1941
|
}, z.core.$strip>;
|
|
1942
1942
|
max: z.ZodObject<{
|
|
1943
1943
|
type: z.ZodEnum<{
|
|
1944
|
-
formula: "formula";
|
|
1945
1944
|
num: "num";
|
|
1946
|
-
percent: "percent";
|
|
1947
|
-
max: "max";
|
|
1948
1945
|
min: "min";
|
|
1946
|
+
max: "max";
|
|
1947
|
+
formula: "formula";
|
|
1948
|
+
percent: "percent";
|
|
1949
1949
|
percentile: "percentile";
|
|
1950
1950
|
}>;
|
|
1951
1951
|
value: z.ZodOptional<z.ZodString>;
|
|
@@ -1988,11 +1988,11 @@ declare const epubContentCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>,
|
|
|
1988
1988
|
iconSetType: z.ZodString;
|
|
1989
1989
|
thresholds: z.ZodArray<z.ZodObject<{
|
|
1990
1990
|
type: z.ZodEnum<{
|
|
1991
|
-
formula: "formula";
|
|
1992
1991
|
num: "num";
|
|
1993
|
-
percent: "percent";
|
|
1994
|
-
max: "max";
|
|
1995
1992
|
min: "min";
|
|
1993
|
+
max: "max";
|
|
1994
|
+
formula: "formula";
|
|
1995
|
+
percent: "percent";
|
|
1996
1996
|
percentile: "percentile";
|
|
1997
1997
|
}>;
|
|
1998
1998
|
value: z.ZodOptional<z.ZodString>;
|
|
@@ -2062,9 +2062,9 @@ declare const epubContentCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>,
|
|
|
2062
2062
|
symbol: z.ZodString;
|
|
2063
2063
|
name: z.ZodOptional<z.ZodString>;
|
|
2064
2064
|
dimension: z.ZodRecord<z.ZodEnum<{
|
|
2065
|
-
time: "time";
|
|
2066
2065
|
length: "length";
|
|
2067
2066
|
mass: "mass";
|
|
2067
|
+
time: "time";
|
|
2068
2068
|
electricCurrent: "electricCurrent";
|
|
2069
2069
|
thermodynamicTemperature: "thermodynamicTemperature";
|
|
2070
2070
|
amountOfSubstance: "amountOfSubstance";
|
|
@@ -2453,9 +2453,9 @@ declare const epubContentCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>,
|
|
|
2453
2453
|
symbol: z.ZodString;
|
|
2454
2454
|
name: z.ZodOptional<z.ZodString>;
|
|
2455
2455
|
dimension: z.ZodRecord<z.ZodEnum<{
|
|
2456
|
-
time: "time";
|
|
2457
2456
|
length: "length";
|
|
2458
2457
|
mass: "mass";
|
|
2458
|
+
time: "time";
|
|
2459
2459
|
electricCurrent: "electricCurrent";
|
|
2460
2460
|
thermodynamicTemperature: "thermodynamicTemperature";
|
|
2461
2461
|
amountOfSubstance: "amountOfSubstance";
|
|
@@ -2553,9 +2553,9 @@ declare const epubContentCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>,
|
|
|
2553
2553
|
symbol: z.ZodString;
|
|
2554
2554
|
name: z.ZodOptional<z.ZodString>;
|
|
2555
2555
|
dimension: z.ZodRecord<z.ZodEnum<{
|
|
2556
|
-
time: "time";
|
|
2557
2556
|
length: "length";
|
|
2558
2557
|
mass: "mass";
|
|
2558
|
+
time: "time";
|
|
2559
2559
|
electricCurrent: "electricCurrent";
|
|
2560
2560
|
thermodynamicTemperature: "thermodynamicTemperature";
|
|
2561
2561
|
amountOfSubstance: "amountOfSubstance";
|
package/dist/codec.d.ts
CHANGED
|
@@ -96,9 +96,9 @@ declare const epubCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Ar
|
|
|
96
96
|
symbol: z.ZodString;
|
|
97
97
|
name: z.ZodOptional<z.ZodString>;
|
|
98
98
|
dimension: z.ZodRecord<z.ZodEnum<{
|
|
99
|
-
time: "time";
|
|
100
99
|
length: "length";
|
|
101
100
|
mass: "mass";
|
|
101
|
+
time: "time";
|
|
102
102
|
electricCurrent: "electricCurrent";
|
|
103
103
|
thermodynamicTemperature: "thermodynamicTemperature";
|
|
104
104
|
amountOfSubstance: "amountOfSubstance";
|
|
@@ -244,9 +244,9 @@ declare const epubCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Ar
|
|
|
244
244
|
symbol: z.ZodString;
|
|
245
245
|
name: z.ZodOptional<z.ZodString>;
|
|
246
246
|
dimension: z.ZodRecord<z.ZodEnum<{
|
|
247
|
-
time: "time";
|
|
248
247
|
length: "length";
|
|
249
248
|
mass: "mass";
|
|
249
|
+
time: "time";
|
|
250
250
|
electricCurrent: "electricCurrent";
|
|
251
251
|
thermodynamicTemperature: "thermodynamicTemperature";
|
|
252
252
|
amountOfSubstance: "amountOfSubstance";
|
|
@@ -392,9 +392,9 @@ declare const epubCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Ar
|
|
|
392
392
|
symbol: z.ZodString;
|
|
393
393
|
name: z.ZodOptional<z.ZodString>;
|
|
394
394
|
dimension: z.ZodRecord<z.ZodEnum<{
|
|
395
|
-
time: "time";
|
|
396
395
|
length: "length";
|
|
397
396
|
mass: "mass";
|
|
397
|
+
time: "time";
|
|
398
398
|
electricCurrent: "electricCurrent";
|
|
399
399
|
thermodynamicTemperature: "thermodynamicTemperature";
|
|
400
400
|
amountOfSubstance: "amountOfSubstance";
|
|
@@ -540,9 +540,9 @@ declare const epubCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Ar
|
|
|
540
540
|
symbol: z.ZodString;
|
|
541
541
|
name: z.ZodOptional<z.ZodString>;
|
|
542
542
|
dimension: z.ZodRecord<z.ZodEnum<{
|
|
543
|
-
time: "time";
|
|
544
543
|
length: "length";
|
|
545
544
|
mass: "mass";
|
|
545
|
+
time: "time";
|
|
546
546
|
electricCurrent: "electricCurrent";
|
|
547
547
|
thermodynamicTemperature: "thermodynamicTemperature";
|
|
548
548
|
amountOfSubstance: "amountOfSubstance";
|
|
@@ -719,9 +719,9 @@ declare const epubCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Ar
|
|
|
719
719
|
symbol: z.ZodString;
|
|
720
720
|
name: z.ZodOptional<z.ZodString>;
|
|
721
721
|
dimension: z.ZodRecord<z.ZodEnum<{
|
|
722
|
-
time: "time";
|
|
723
722
|
length: "length";
|
|
724
723
|
mass: "mass";
|
|
724
|
+
time: "time";
|
|
725
725
|
electricCurrent: "electricCurrent";
|
|
726
726
|
thermodynamicTemperature: "thermodynamicTemperature";
|
|
727
727
|
amountOfSubstance: "amountOfSubstance";
|
|
@@ -826,9 +826,9 @@ declare const epubContentCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>,
|
|
|
826
826
|
symbol: z.ZodString;
|
|
827
827
|
name: z.ZodOptional<z.ZodString>;
|
|
828
828
|
dimension: z.ZodRecord<z.ZodEnum<{
|
|
829
|
-
time: "time";
|
|
830
829
|
length: "length";
|
|
831
830
|
mass: "mass";
|
|
831
|
+
time: "time";
|
|
832
832
|
electricCurrent: "electricCurrent";
|
|
833
833
|
thermodynamicTemperature: "thermodynamicTemperature";
|
|
834
834
|
amountOfSubstance: "amountOfSubstance";
|
|
@@ -965,9 +965,9 @@ declare const epubContentCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>,
|
|
|
965
965
|
symbol: z.ZodString;
|
|
966
966
|
name: z.ZodOptional<z.ZodString>;
|
|
967
967
|
dimension: z.ZodRecord<z.ZodEnum<{
|
|
968
|
-
time: "time";
|
|
969
968
|
length: "length";
|
|
970
969
|
mass: "mass";
|
|
970
|
+
time: "time";
|
|
971
971
|
electricCurrent: "electricCurrent";
|
|
972
972
|
thermodynamicTemperature: "thermodynamicTemperature";
|
|
973
973
|
amountOfSubstance: "amountOfSubstance";
|
|
@@ -1425,11 +1425,11 @@ declare const epubContentCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>,
|
|
|
1425
1425
|
endColumn: z.ZodNumber;
|
|
1426
1426
|
}, z.core.$strip>>;
|
|
1427
1427
|
type: z.ZodEnum<{
|
|
1428
|
-
decimal: "decimal";
|
|
1429
|
-
list: "list";
|
|
1430
1428
|
date: "date";
|
|
1431
1429
|
custom: "custom";
|
|
1432
1430
|
time: "time";
|
|
1431
|
+
decimal: "decimal";
|
|
1432
|
+
list: "list";
|
|
1433
1433
|
whole: "whole";
|
|
1434
1434
|
textLength: "textLength";
|
|
1435
1435
|
}>;
|
|
@@ -1884,11 +1884,11 @@ declare const epubContentCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>,
|
|
|
1884
1884
|
stops: z.ZodArray<z.ZodObject<{
|
|
1885
1885
|
value: z.ZodObject<{
|
|
1886
1886
|
type: z.ZodEnum<{
|
|
1887
|
-
formula: "formula";
|
|
1888
1887
|
num: "num";
|
|
1889
|
-
percent: "percent";
|
|
1890
|
-
max: "max";
|
|
1891
1888
|
min: "min";
|
|
1889
|
+
max: "max";
|
|
1890
|
+
formula: "formula";
|
|
1891
|
+
percent: "percent";
|
|
1892
1892
|
percentile: "percentile";
|
|
1893
1893
|
}>;
|
|
1894
1894
|
value: z.ZodOptional<z.ZodString>;
|
|
@@ -1930,22 +1930,22 @@ declare const epubContentCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>,
|
|
|
1930
1930
|
}, z.core.$strip>, z.ZodObject<{
|
|
1931
1931
|
min: z.ZodObject<{
|
|
1932
1932
|
type: z.ZodEnum<{
|
|
1933
|
-
formula: "formula";
|
|
1934
1933
|
num: "num";
|
|
1935
|
-
percent: "percent";
|
|
1936
|
-
max: "max";
|
|
1937
1934
|
min: "min";
|
|
1935
|
+
max: "max";
|
|
1936
|
+
formula: "formula";
|
|
1937
|
+
percent: "percent";
|
|
1938
1938
|
percentile: "percentile";
|
|
1939
1939
|
}>;
|
|
1940
1940
|
value: z.ZodOptional<z.ZodString>;
|
|
1941
1941
|
}, z.core.$strip>;
|
|
1942
1942
|
max: z.ZodObject<{
|
|
1943
1943
|
type: z.ZodEnum<{
|
|
1944
|
-
formula: "formula";
|
|
1945
1944
|
num: "num";
|
|
1946
|
-
percent: "percent";
|
|
1947
|
-
max: "max";
|
|
1948
1945
|
min: "min";
|
|
1946
|
+
max: "max";
|
|
1947
|
+
formula: "formula";
|
|
1948
|
+
percent: "percent";
|
|
1949
1949
|
percentile: "percentile";
|
|
1950
1950
|
}>;
|
|
1951
1951
|
value: z.ZodOptional<z.ZodString>;
|
|
@@ -1988,11 +1988,11 @@ declare const epubContentCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>,
|
|
|
1988
1988
|
iconSetType: z.ZodString;
|
|
1989
1989
|
thresholds: z.ZodArray<z.ZodObject<{
|
|
1990
1990
|
type: z.ZodEnum<{
|
|
1991
|
-
formula: "formula";
|
|
1992
1991
|
num: "num";
|
|
1993
|
-
percent: "percent";
|
|
1994
|
-
max: "max";
|
|
1995
1992
|
min: "min";
|
|
1993
|
+
max: "max";
|
|
1994
|
+
formula: "formula";
|
|
1995
|
+
percent: "percent";
|
|
1996
1996
|
percentile: "percentile";
|
|
1997
1997
|
}>;
|
|
1998
1998
|
value: z.ZodOptional<z.ZodString>;
|
|
@@ -2062,9 +2062,9 @@ declare const epubContentCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>,
|
|
|
2062
2062
|
symbol: z.ZodString;
|
|
2063
2063
|
name: z.ZodOptional<z.ZodString>;
|
|
2064
2064
|
dimension: z.ZodRecord<z.ZodEnum<{
|
|
2065
|
-
time: "time";
|
|
2066
2065
|
length: "length";
|
|
2067
2066
|
mass: "mass";
|
|
2067
|
+
time: "time";
|
|
2068
2068
|
electricCurrent: "electricCurrent";
|
|
2069
2069
|
thermodynamicTemperature: "thermodynamicTemperature";
|
|
2070
2070
|
amountOfSubstance: "amountOfSubstance";
|
|
@@ -2453,9 +2453,9 @@ declare const epubContentCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>,
|
|
|
2453
2453
|
symbol: z.ZodString;
|
|
2454
2454
|
name: z.ZodOptional<z.ZodString>;
|
|
2455
2455
|
dimension: z.ZodRecord<z.ZodEnum<{
|
|
2456
|
-
time: "time";
|
|
2457
2456
|
length: "length";
|
|
2458
2457
|
mass: "mass";
|
|
2458
|
+
time: "time";
|
|
2459
2459
|
electricCurrent: "electricCurrent";
|
|
2460
2460
|
thermodynamicTemperature: "thermodynamicTemperature";
|
|
2461
2461
|
amountOfSubstance: "amountOfSubstance";
|
|
@@ -2553,9 +2553,9 @@ declare const epubContentCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>,
|
|
|
2553
2553
|
symbol: z.ZodString;
|
|
2554
2554
|
name: z.ZodOptional<z.ZodString>;
|
|
2555
2555
|
dimension: z.ZodRecord<z.ZodEnum<{
|
|
2556
|
-
time: "time";
|
|
2557
2556
|
length: "length";
|
|
2558
2557
|
mass: "mass";
|
|
2558
|
+
time: "time";
|
|
2559
2559
|
electricCurrent: "electricCurrent";
|
|
2560
2560
|
thermodynamicTemperature: "thermodynamicTemperature";
|
|
2561
2561
|
amountOfSubstance: "amountOfSubstance";
|
package/dist/index.cjs
CHANGED
|
@@ -93,6 +93,7 @@ exports.readNav3TocHrefs = require_nav_nav3.readNav3TocHrefs;
|
|
|
93
93
|
exports.readNcxHrefs = require_nav_ncx.readNcxHrefs;
|
|
94
94
|
exports.readOpfMetadata = require_opf_metadata.readOpfMetadata;
|
|
95
95
|
exports.readXhtmlBody = require_xhtml_read.readXhtmlBody;
|
|
96
|
+
exports.rebaseConstructs = require_xhtml_inline.rebaseConstructs;
|
|
96
97
|
exports.reportInertElementSkip = require_xhtml_context.reportInertElementSkip;
|
|
97
98
|
exports.resolveOpfPath = require_ocf_container.resolveOpfPath;
|
|
98
99
|
exports.resolvePackagePath = require_path.resolvePackagePath;
|
package/dist/index.d.cts
CHANGED
|
@@ -12,7 +12,7 @@ import { WriteOpfInput, writeOpf } from "./opf/write.cjs";
|
|
|
12
12
|
import { base64ToBytes, bytesToBase64 } from "./util/base64.cjs";
|
|
13
13
|
import { InlineStyle, XhtmlReadContext, isInertElement, reportInertElementSkip } from "./xhtml/context.cjs";
|
|
14
14
|
import { isFootnoteAside, isFootnoteReferenceAnchor, sameDocumentFragment } from "./xhtml/footnote.cjs";
|
|
15
|
-
import { InlineResult, buildInlineRuns } from "./xhtml/inline.cjs";
|
|
15
|
+
import { InlineResult, buildInlineRuns, rebaseConstructs } from "./xhtml/inline.cjs";
|
|
16
16
|
import { ListNumIdInfo, MintListNumIdOptions, mintListNumId, parseListNumId } from "./xhtml/list-id.cjs";
|
|
17
17
|
import { ReadXhtmlBodyOptions, ReadXhtmlBodyResult, readXhtmlBody } from "./xhtml/read.cjs";
|
|
18
18
|
import { DEFINITION_BODY_INDENT_PT, HORIZONTAL_RULE_STYLE_ID, MONOSPACE_FONT_FAMILY, QUOTE_INDENT_PT, QUOTE_STYLE_ID } from "./xhtml/style-constants.cjs";
|
|
@@ -29,4 +29,4 @@ import { parseXml } from "./xml/parse.cjs";
|
|
|
29
29
|
import { buildXml } from "./xml/build.cjs";
|
|
30
30
|
import { attrValue, childrenWithTag, decodedTextContent, elementsWithTag, findChildElement, findElement, rootElement, textContent } from "./xml/query.cjs";
|
|
31
31
|
import { decodeEntities, decodeTextLikeNode, encodeEntities } from "./xml/entities.cjs";
|
|
32
|
-
export { Attribute, AttributeSchema, DEFINITION_BODY_INDENT_PT, EPUB_MIME_TYPE, EpubBytesSchema, EpubDiagnostic, EpubDiagnosticCodes, EpubDiagnosticSeverity, EpubDiagnosticSink, EpubEmptySpineError, EpubImageFormat, EpubInvalidContainerError, EpubInvalidMimetypeError, EpubInvalidOpfError, EpubPackageFlattenError, EpubParseError, EpubUnbalancedConstructMarkersError, EpubUnsupportedDocumentKindError, EpubWriteError, HORIZONTAL_RULE_STYLE_ID, ImageDimensions, InlineResult, InlineStyle, ListNumIdInfo, MONOSPACE_FONT_FAMILY, MintListNumIdOptions, NOOP_EPUB_DIAGNOSTIC_SINK, NavSectionEntry, OCF_CONTAINER_PATH, OCF_MIMETYPE_PATH, OpfManifestItem, OpfPackage, OpfSpineItemRef, POINTS_PER_PIXEL, QUOTE_INDENT_PT, QUOTE_STYLE_ID, ReadEpubOptions, ReadXhtmlBodyOptions, ReadXhtmlBodyResult, WriteEpubOptions, WriteOpfInput, XhtmlReadContext, XhtmlWriteContext, XmlCdata, XmlCdataSchema, XmlComment, XmlCommentSchema, XmlDeclaration, XmlDeclarationSchema, XmlElement, XmlElementSchema, XmlNode, XmlNodeSchema, XmlPi, XmlPiSchema, XmlText, XmlTextSchema, ZipEntry, attrValue, base64ToBytes, buildInlineRuns, buildXml, bytesToBase64, childrenWithTag, decodeEntities, decodeTextLikeNode, decodedTextContent, detectImageFormat, dirname, elementsWithTag, encodeEntities, epubCodec, epubContentCodec, findChildElement, findElement, isFootnoteAside, isFootnoteReferenceAnchor, isInertElement, isTextLikeNode, isXmlNode, mintListNumId, navMatchesSpine, parseListNumId, parseOpf, parseXml, readEpub, readEpubContent, readImageDimensions, readNav3TocHrefs, readNcxHrefs, readOpfMetadata, readXhtmlBody, reportInertElementSkip, resolveOpfPath, resolvePackagePath, rootElement, sameDocumentFragment, sectionTitle, textContent, unzipPackage, writeContainerXml, writeEpub, writeEpubContent, writeNav3Document, writeOpf, writeXhtmlBody, zipPackage };
|
|
32
|
+
export { Attribute, AttributeSchema, DEFINITION_BODY_INDENT_PT, EPUB_MIME_TYPE, EpubBytesSchema, EpubDiagnostic, EpubDiagnosticCodes, EpubDiagnosticSeverity, EpubDiagnosticSink, EpubEmptySpineError, EpubImageFormat, EpubInvalidContainerError, EpubInvalidMimetypeError, EpubInvalidOpfError, EpubPackageFlattenError, EpubParseError, EpubUnbalancedConstructMarkersError, EpubUnsupportedDocumentKindError, EpubWriteError, HORIZONTAL_RULE_STYLE_ID, ImageDimensions, InlineResult, InlineStyle, ListNumIdInfo, MONOSPACE_FONT_FAMILY, MintListNumIdOptions, NOOP_EPUB_DIAGNOSTIC_SINK, NavSectionEntry, OCF_CONTAINER_PATH, OCF_MIMETYPE_PATH, OpfManifestItem, OpfPackage, OpfSpineItemRef, POINTS_PER_PIXEL, QUOTE_INDENT_PT, QUOTE_STYLE_ID, ReadEpubOptions, ReadXhtmlBodyOptions, ReadXhtmlBodyResult, WriteEpubOptions, WriteOpfInput, XhtmlReadContext, XhtmlWriteContext, XmlCdata, XmlCdataSchema, XmlComment, XmlCommentSchema, XmlDeclaration, XmlDeclarationSchema, XmlElement, XmlElementSchema, XmlNode, XmlNodeSchema, XmlPi, XmlPiSchema, XmlText, XmlTextSchema, ZipEntry, attrValue, base64ToBytes, buildInlineRuns, buildXml, bytesToBase64, childrenWithTag, decodeEntities, decodeTextLikeNode, decodedTextContent, detectImageFormat, dirname, elementsWithTag, encodeEntities, epubCodec, epubContentCodec, findChildElement, findElement, isFootnoteAside, isFootnoteReferenceAnchor, isInertElement, isTextLikeNode, isXmlNode, mintListNumId, navMatchesSpine, parseListNumId, parseOpf, parseXml, readEpub, readEpubContent, readImageDimensions, readNav3TocHrefs, readNcxHrefs, readOpfMetadata, readXhtmlBody, rebaseConstructs, reportInertElementSkip, resolveOpfPath, resolvePackagePath, rootElement, sameDocumentFragment, sectionTitle, textContent, unzipPackage, writeContainerXml, writeEpub, writeEpubContent, writeNav3Document, writeOpf, writeXhtmlBody, zipPackage };
|
package/dist/index.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ import { WriteOpfInput, writeOpf } from "./opf/write.js";
|
|
|
12
12
|
import { base64ToBytes, bytesToBase64 } from "./util/base64.js";
|
|
13
13
|
import { InlineStyle, XhtmlReadContext, isInertElement, reportInertElementSkip } from "./xhtml/context.js";
|
|
14
14
|
import { isFootnoteAside, isFootnoteReferenceAnchor, sameDocumentFragment } from "./xhtml/footnote.js";
|
|
15
|
-
import { InlineResult, buildInlineRuns } from "./xhtml/inline.js";
|
|
15
|
+
import { InlineResult, buildInlineRuns, rebaseConstructs } from "./xhtml/inline.js";
|
|
16
16
|
import { ListNumIdInfo, MintListNumIdOptions, mintListNumId, parseListNumId } from "./xhtml/list-id.js";
|
|
17
17
|
import { ReadXhtmlBodyOptions, ReadXhtmlBodyResult, readXhtmlBody } from "./xhtml/read.js";
|
|
18
18
|
import { DEFINITION_BODY_INDENT_PT, HORIZONTAL_RULE_STYLE_ID, MONOSPACE_FONT_FAMILY, QUOTE_INDENT_PT, QUOTE_STYLE_ID } from "./xhtml/style-constants.js";
|
|
@@ -29,4 +29,4 @@ import { parseXml } from "./xml/parse.js";
|
|
|
29
29
|
import { buildXml } from "./xml/build.js";
|
|
30
30
|
import { attrValue, childrenWithTag, decodedTextContent, elementsWithTag, findChildElement, findElement, rootElement, textContent } from "./xml/query.js";
|
|
31
31
|
import { decodeEntities, decodeTextLikeNode, encodeEntities } from "./xml/entities.js";
|
|
32
|
-
export { Attribute, AttributeSchema, DEFINITION_BODY_INDENT_PT, EPUB_MIME_TYPE, EpubBytesSchema, EpubDiagnostic, EpubDiagnosticCodes, EpubDiagnosticSeverity, EpubDiagnosticSink, EpubEmptySpineError, EpubImageFormat, EpubInvalidContainerError, EpubInvalidMimetypeError, EpubInvalidOpfError, EpubPackageFlattenError, EpubParseError, EpubUnbalancedConstructMarkersError, EpubUnsupportedDocumentKindError, EpubWriteError, HORIZONTAL_RULE_STYLE_ID, ImageDimensions, InlineResult, InlineStyle, ListNumIdInfo, MONOSPACE_FONT_FAMILY, MintListNumIdOptions, NOOP_EPUB_DIAGNOSTIC_SINK, NavSectionEntry, OCF_CONTAINER_PATH, OCF_MIMETYPE_PATH, OpfManifestItem, OpfPackage, OpfSpineItemRef, POINTS_PER_PIXEL, QUOTE_INDENT_PT, QUOTE_STYLE_ID, ReadEpubOptions, ReadXhtmlBodyOptions, ReadXhtmlBodyResult, WriteEpubOptions, WriteOpfInput, XhtmlReadContext, XhtmlWriteContext, XmlCdata, XmlCdataSchema, XmlComment, XmlCommentSchema, XmlDeclaration, XmlDeclarationSchema, XmlElement, XmlElementSchema, XmlNode, XmlNodeSchema, XmlPi, XmlPiSchema, XmlText, XmlTextSchema, ZipEntry, attrValue, base64ToBytes, buildInlineRuns, buildXml, bytesToBase64, childrenWithTag, decodeEntities, decodeTextLikeNode, decodedTextContent, detectImageFormat, dirname, elementsWithTag, encodeEntities, epubCodec, epubContentCodec, findChildElement, findElement, isFootnoteAside, isFootnoteReferenceAnchor, isInertElement, isTextLikeNode, isXmlNode, mintListNumId, navMatchesSpine, parseListNumId, parseOpf, parseXml, readEpub, readEpubContent, readImageDimensions, readNav3TocHrefs, readNcxHrefs, readOpfMetadata, readXhtmlBody, reportInertElementSkip, resolveOpfPath, resolvePackagePath, rootElement, sameDocumentFragment, sectionTitle, textContent, unzipPackage, writeContainerXml, writeEpub, writeEpubContent, writeNav3Document, writeOpf, writeXhtmlBody, zipPackage };
|
|
32
|
+
export { Attribute, AttributeSchema, DEFINITION_BODY_INDENT_PT, EPUB_MIME_TYPE, EpubBytesSchema, EpubDiagnostic, EpubDiagnosticCodes, EpubDiagnosticSeverity, EpubDiagnosticSink, EpubEmptySpineError, EpubImageFormat, EpubInvalidContainerError, EpubInvalidMimetypeError, EpubInvalidOpfError, EpubPackageFlattenError, EpubParseError, EpubUnbalancedConstructMarkersError, EpubUnsupportedDocumentKindError, EpubWriteError, HORIZONTAL_RULE_STYLE_ID, ImageDimensions, InlineResult, InlineStyle, ListNumIdInfo, MONOSPACE_FONT_FAMILY, MintListNumIdOptions, NOOP_EPUB_DIAGNOSTIC_SINK, NavSectionEntry, OCF_CONTAINER_PATH, OCF_MIMETYPE_PATH, OpfManifestItem, OpfPackage, OpfSpineItemRef, POINTS_PER_PIXEL, QUOTE_INDENT_PT, QUOTE_STYLE_ID, ReadEpubOptions, ReadXhtmlBodyOptions, ReadXhtmlBodyResult, WriteEpubOptions, WriteOpfInput, XhtmlReadContext, XhtmlWriteContext, XmlCdata, XmlCdataSchema, XmlComment, XmlCommentSchema, XmlDeclaration, XmlDeclarationSchema, XmlElement, XmlElementSchema, XmlNode, XmlNodeSchema, XmlPi, XmlPiSchema, XmlText, XmlTextSchema, ZipEntry, attrValue, base64ToBytes, buildInlineRuns, buildXml, bytesToBase64, childrenWithTag, decodeEntities, decodeTextLikeNode, decodedTextContent, detectImageFormat, dirname, elementsWithTag, encodeEntities, epubCodec, epubContentCodec, findChildElement, findElement, isFootnoteAside, isFootnoteReferenceAnchor, isInertElement, isTextLikeNode, isXmlNode, mintListNumId, navMatchesSpine, parseListNumId, parseOpf, parseXml, readEpub, readEpubContent, readImageDimensions, readNav3TocHrefs, readNcxHrefs, readOpfMetadata, readXhtmlBody, rebaseConstructs, reportInertElementSkip, resolveOpfPath, resolvePackagePath, rootElement, sameDocumentFragment, sectionTitle, textContent, unzipPackage, writeContainerXml, writeEpub, writeEpubContent, writeNav3Document, writeOpf, writeXhtmlBody, zipPackage };
|
package/dist/index.js
CHANGED
|
@@ -16,7 +16,7 @@ import { buildXml } from "./xml/build.js";
|
|
|
16
16
|
import { isInertElement, reportInertElementSkip } from "./xhtml/context.js";
|
|
17
17
|
import { isFootnoteAside, isFootnoteReferenceAnchor, sameDocumentFragment } from "./xhtml/footnote.js";
|
|
18
18
|
import { DEFINITION_BODY_INDENT_PT, HORIZONTAL_RULE_STYLE_ID, MONOSPACE_FONT_FAMILY, QUOTE_INDENT_PT, QUOTE_STYLE_ID } from "./xhtml/style-constants.js";
|
|
19
|
-
import { buildInlineRuns } from "./xhtml/inline.js";
|
|
19
|
+
import { buildInlineRuns, rebaseConstructs } from "./xhtml/inline.js";
|
|
20
20
|
import { mintListNumId, parseListNumId } from "./xhtml/list-id.js";
|
|
21
21
|
import { readXhtmlBody } from "./xhtml/read.js";
|
|
22
22
|
import { dirname, resolvePackagePath } from "./path.js";
|
|
@@ -29,4 +29,4 @@ import { writeXhtmlBody } from "./xhtml/write.js";
|
|
|
29
29
|
import { writeEpub, writeEpubContent } from "./write.js";
|
|
30
30
|
import { EpubBytesSchema, epubCodec, epubContentCodec } from "./codec.js";
|
|
31
31
|
import "./opf/types.js";
|
|
32
|
-
export { AttributeSchema, DEFINITION_BODY_INDENT_PT, EPUB_MIME_TYPE, EpubBytesSchema, EpubDiagnosticCodes, EpubEmptySpineError, EpubInvalidContainerError, EpubInvalidMimetypeError, EpubInvalidOpfError, EpubPackageFlattenError, EpubParseError, EpubUnbalancedConstructMarkersError, EpubUnsupportedDocumentKindError, EpubWriteError, HORIZONTAL_RULE_STYLE_ID, MONOSPACE_FONT_FAMILY, NOOP_EPUB_DIAGNOSTIC_SINK, OCF_CONTAINER_PATH, OCF_MIMETYPE_PATH, POINTS_PER_PIXEL, QUOTE_INDENT_PT, QUOTE_STYLE_ID, XmlCdataSchema, XmlCommentSchema, XmlDeclarationSchema, XmlElementSchema, XmlNodeSchema, XmlPiSchema, XmlTextSchema, attrValue, base64ToBytes, buildInlineRuns, buildXml, bytesToBase64, childrenWithTag, decodeEntities, decodeTextLikeNode, decodedTextContent, detectImageFormat, dirname, elementsWithTag, encodeEntities, epubCodec, epubContentCodec, findChildElement, findElement, isFootnoteAside, isFootnoteReferenceAnchor, isInertElement, isTextLikeNode, isXmlNode, mintListNumId, navMatchesSpine, parseListNumId, parseOpf, parseXml, readEpub, readEpubContent, readImageDimensions, readNav3TocHrefs, readNcxHrefs, readOpfMetadata, readXhtmlBody, reportInertElementSkip, resolveOpfPath, resolvePackagePath, rootElement, sameDocumentFragment, sectionTitle, textContent, unzipPackage, writeContainerXml, writeEpub, writeEpubContent, writeNav3Document, writeOpf, writeXhtmlBody, zipPackage };
|
|
32
|
+
export { AttributeSchema, DEFINITION_BODY_INDENT_PT, EPUB_MIME_TYPE, EpubBytesSchema, EpubDiagnosticCodes, EpubEmptySpineError, EpubInvalidContainerError, EpubInvalidMimetypeError, EpubInvalidOpfError, EpubPackageFlattenError, EpubParseError, EpubUnbalancedConstructMarkersError, EpubUnsupportedDocumentKindError, EpubWriteError, HORIZONTAL_RULE_STYLE_ID, MONOSPACE_FONT_FAMILY, NOOP_EPUB_DIAGNOSTIC_SINK, OCF_CONTAINER_PATH, OCF_MIMETYPE_PATH, POINTS_PER_PIXEL, QUOTE_INDENT_PT, QUOTE_STYLE_ID, XmlCdataSchema, XmlCommentSchema, XmlDeclarationSchema, XmlElementSchema, XmlNodeSchema, XmlPiSchema, XmlTextSchema, attrValue, base64ToBytes, buildInlineRuns, buildXml, bytesToBase64, childrenWithTag, decodeEntities, decodeTextLikeNode, decodedTextContent, detectImageFormat, dirname, elementsWithTag, encodeEntities, epubCodec, epubContentCodec, findChildElement, findElement, isFootnoteAside, isFootnoteReferenceAnchor, isInertElement, isTextLikeNode, isXmlNode, mintListNumId, navMatchesSpine, parseListNumId, parseOpf, parseXml, readEpub, readEpubContent, readImageDimensions, readNav3TocHrefs, readNcxHrefs, readOpfMetadata, readXhtmlBody, rebaseConstructs, reportInertElementSkip, resolveOpfPath, resolvePackagePath, rootElement, sameDocumentFragment, sectionTitle, textContent, unzipPackage, writeContainerXml, writeEpub, writeEpubContent, writeNav3Document, writeOpf, writeXhtmlBody, zipPackage };
|
package/dist/xhtml/inline.cjs
CHANGED
|
@@ -104,10 +104,18 @@ function appendImageFallback(element, style, context, runs) {
|
|
|
104
104
|
});
|
|
105
105
|
if (alt !== void 0 && alt.length > 0) runs.push(styledRun(require_xml_entities.decodeEntities(alt), style));
|
|
106
106
|
}
|
|
107
|
+
function rebaseConstructs(constructs, offset) {
|
|
108
|
+
return constructs.map((construct) => ({
|
|
109
|
+
...construct,
|
|
110
|
+
startRun: construct.startRun + offset,
|
|
111
|
+
endRun: construct.endRun + offset
|
|
112
|
+
}));
|
|
113
|
+
}
|
|
107
114
|
function appendNested(element, style, context, runs, constructs) {
|
|
115
|
+
const offset = runs.length;
|
|
108
116
|
const nested = buildInlineRuns(element.children, style, context);
|
|
109
117
|
runs.push(...nested.runs);
|
|
110
|
-
constructs.push(...nested.constructs);
|
|
118
|
+
constructs.push(...rebaseConstructs(nested.constructs, offset));
|
|
111
119
|
}
|
|
112
120
|
function appendAnchor(element, style, context, runs, constructs) {
|
|
113
121
|
const footnoteName = require_xhtml_footnote.isFootnoteReferenceAnchor(element, context.idElements);
|
|
@@ -115,7 +123,7 @@ function appendAnchor(element, style, context, runs, constructs) {
|
|
|
115
123
|
const startRun = runs.length;
|
|
116
124
|
const nested = buildInlineRuns(element.children, style, context);
|
|
117
125
|
runs.push(...nested.runs);
|
|
118
|
-
constructs.push(...nested.constructs);
|
|
126
|
+
constructs.push(...rebaseConstructs(nested.constructs, startRun));
|
|
119
127
|
constructs.push({
|
|
120
128
|
descriptor: {
|
|
121
129
|
kind: "anchor",
|
|
@@ -132,12 +140,13 @@ function appendAnchor(element, style, context, runs, constructs) {
|
|
|
132
140
|
appendNested(element, style, context, runs, constructs);
|
|
133
141
|
return;
|
|
134
142
|
}
|
|
143
|
+
const offset = runs.length;
|
|
135
144
|
const nested = buildInlineRuns(element.children, style, context);
|
|
136
145
|
for (const run of nested.runs) runs.push({
|
|
137
146
|
...run,
|
|
138
147
|
hyperlink: href
|
|
139
148
|
});
|
|
140
|
-
constructs.push(...nested.constructs);
|
|
149
|
+
constructs.push(...rebaseConstructs(nested.constructs, offset));
|
|
141
150
|
if (require_xhtml_footnote.sameDocumentFragment(href) === void 0 && !/^[a-z][a-z0-9+.-]*:/iu.test(href)) context.sink({
|
|
142
151
|
code: require_diagnostics.EpubDiagnosticCodes.LINK_TARGET_EXTERNAL_ONLY,
|
|
143
152
|
severity: "info",
|
|
@@ -147,3 +156,4 @@ function appendAnchor(element, style, context, runs, constructs) {
|
|
|
147
156
|
}
|
|
148
157
|
//#endregion
|
|
149
158
|
exports.buildInlineRuns = buildInlineRuns;
|
|
159
|
+
exports.rebaseConstructs = rebaseConstructs;
|
package/dist/xhtml/inline.d.cts
CHANGED
|
@@ -7,5 +7,6 @@ interface InlineResult {
|
|
|
7
7
|
readonly constructs: RunConstructExtent[];
|
|
8
8
|
}
|
|
9
9
|
declare function buildInlineRuns(nodes: readonly XmlNode[], style: InlineStyle, context: XhtmlReadContext): InlineResult;
|
|
10
|
+
declare function rebaseConstructs(constructs: readonly RunConstructExtent[], offset: number): RunConstructExtent[];
|
|
10
11
|
//#endregion
|
|
11
|
-
export { InlineResult, buildInlineRuns };
|
|
12
|
+
export { InlineResult, buildInlineRuns, rebaseConstructs };
|
package/dist/xhtml/inline.d.ts
CHANGED
|
@@ -7,5 +7,6 @@ interface InlineResult {
|
|
|
7
7
|
readonly constructs: RunConstructExtent[];
|
|
8
8
|
}
|
|
9
9
|
declare function buildInlineRuns(nodes: readonly XmlNode[], style: InlineStyle, context: XhtmlReadContext): InlineResult;
|
|
10
|
+
declare function rebaseConstructs(constructs: readonly RunConstructExtent[], offset: number): RunConstructExtent[];
|
|
10
11
|
//#endregion
|
|
11
|
-
export { InlineResult, buildInlineRuns };
|
|
12
|
+
export { InlineResult, buildInlineRuns, rebaseConstructs };
|
package/dist/xhtml/inline.js
CHANGED
|
@@ -103,10 +103,18 @@ function appendImageFallback(element, style, context, runs) {
|
|
|
103
103
|
});
|
|
104
104
|
if (alt !== void 0 && alt.length > 0) runs.push(styledRun(decodeEntities(alt), style));
|
|
105
105
|
}
|
|
106
|
+
function rebaseConstructs(constructs, offset) {
|
|
107
|
+
return constructs.map((construct) => ({
|
|
108
|
+
...construct,
|
|
109
|
+
startRun: construct.startRun + offset,
|
|
110
|
+
endRun: construct.endRun + offset
|
|
111
|
+
}));
|
|
112
|
+
}
|
|
106
113
|
function appendNested(element, style, context, runs, constructs) {
|
|
114
|
+
const offset = runs.length;
|
|
107
115
|
const nested = buildInlineRuns(element.children, style, context);
|
|
108
116
|
runs.push(...nested.runs);
|
|
109
|
-
constructs.push(...nested.constructs);
|
|
117
|
+
constructs.push(...rebaseConstructs(nested.constructs, offset));
|
|
110
118
|
}
|
|
111
119
|
function appendAnchor(element, style, context, runs, constructs) {
|
|
112
120
|
const footnoteName = isFootnoteReferenceAnchor(element, context.idElements);
|
|
@@ -114,7 +122,7 @@ function appendAnchor(element, style, context, runs, constructs) {
|
|
|
114
122
|
const startRun = runs.length;
|
|
115
123
|
const nested = buildInlineRuns(element.children, style, context);
|
|
116
124
|
runs.push(...nested.runs);
|
|
117
|
-
constructs.push(...nested.constructs);
|
|
125
|
+
constructs.push(...rebaseConstructs(nested.constructs, startRun));
|
|
118
126
|
constructs.push({
|
|
119
127
|
descriptor: {
|
|
120
128
|
kind: "anchor",
|
|
@@ -131,12 +139,13 @@ function appendAnchor(element, style, context, runs, constructs) {
|
|
|
131
139
|
appendNested(element, style, context, runs, constructs);
|
|
132
140
|
return;
|
|
133
141
|
}
|
|
142
|
+
const offset = runs.length;
|
|
134
143
|
const nested = buildInlineRuns(element.children, style, context);
|
|
135
144
|
for (const run of nested.runs) runs.push({
|
|
136
145
|
...run,
|
|
137
146
|
hyperlink: href
|
|
138
147
|
});
|
|
139
|
-
constructs.push(...nested.constructs);
|
|
148
|
+
constructs.push(...rebaseConstructs(nested.constructs, offset));
|
|
140
149
|
if (sameDocumentFragment(href) === void 0 && !/^[a-z][a-z0-9+.-]*:/iu.test(href)) context.sink({
|
|
141
150
|
code: EpubDiagnosticCodes.LINK_TARGET_EXTERNAL_ONLY,
|
|
142
151
|
severity: "info",
|
|
@@ -145,4 +154,4 @@ function appendAnchor(element, style, context, runs, constructs) {
|
|
|
145
154
|
});
|
|
146
155
|
}
|
|
147
156
|
//#endregion
|
|
148
|
-
export { buildInlineRuns };
|
|
157
|
+
export { buildInlineRuns, rebaseConstructs };
|
package/dist/xhtml/read.cjs
CHANGED
|
@@ -34,6 +34,12 @@ function withQuote(state) {
|
|
|
34
34
|
quoteDepth: state.quoteDepth + 1
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
|
+
function withExtraIndent(state, pt) {
|
|
38
|
+
return {
|
|
39
|
+
...state,
|
|
40
|
+
extraIndentPt: state.extraIndentPt + pt
|
|
41
|
+
};
|
|
42
|
+
}
|
|
37
43
|
function withListItem(state, listItem) {
|
|
38
44
|
return {
|
|
39
45
|
...state,
|
|
@@ -48,9 +54,13 @@ function decorateParagraph(paragraph, state) {
|
|
|
48
54
|
let decorated = paragraph;
|
|
49
55
|
if (state.quoteDepth > 0) decorated = {
|
|
50
56
|
...decorated,
|
|
51
|
-
indentLeftPt: state.quoteDepth * 36,
|
|
57
|
+
indentLeftPt: state.quoteDepth * 36 + state.extraIndentPt,
|
|
52
58
|
styleId: decorated.styleId ?? "Quote"
|
|
53
59
|
};
|
|
60
|
+
else if (state.extraIndentPt > 0) decorated = {
|
|
61
|
+
...decorated,
|
|
62
|
+
indentLeftPt: state.extraIndentPt
|
|
63
|
+
};
|
|
54
64
|
if (state.listItem !== void 0) {
|
|
55
65
|
const membership = {
|
|
56
66
|
numId: state.listItem.numId,
|
|
@@ -132,6 +142,7 @@ function readXhtmlBody(xml, options) {
|
|
|
132
142
|
context,
|
|
133
143
|
minter: createIdMinter(),
|
|
134
144
|
quoteDepth: 0,
|
|
145
|
+
extraIndentPt: 0,
|
|
135
146
|
listItem: void 0,
|
|
136
147
|
list: void 0,
|
|
137
148
|
contentWidthPt: options.contentWidthPt
|
|
@@ -165,12 +176,12 @@ const BLOCK_LEVEL_TAGS = /* @__PURE__ */ new Set([
|
|
|
165
176
|
"nav",
|
|
166
177
|
"img"
|
|
167
178
|
]);
|
|
168
|
-
function readContainerChildren(nodes, state) {
|
|
179
|
+
function readContainerChildren(nodes, state, baseStyle = {}) {
|
|
169
180
|
const blocks = [];
|
|
170
181
|
let segment = [];
|
|
171
182
|
const flush = () => {
|
|
172
183
|
if (segment.length === 0) return;
|
|
173
|
-
const inline = require_xhtml_inline.buildInlineRuns(segment,
|
|
184
|
+
const inline = require_xhtml_inline.buildInlineRuns(segment, baseStyle, state.context);
|
|
174
185
|
segment = [];
|
|
175
186
|
if (inline.runs.every((run) => run.text.trim().length === 0) && inline.constructs.length === 0) return;
|
|
176
187
|
const paragraph = {
|
|
@@ -238,14 +249,7 @@ function readBlockElementInner(element, state) {
|
|
|
238
249
|
case "dl": return readDefinitionList(element, state);
|
|
239
250
|
case "table": return readTable(element, state);
|
|
240
251
|
case "figure": return readContainerChildren(element.children, state);
|
|
241
|
-
case "figcaption":
|
|
242
|
-
const inline = require_xhtml_inline.buildInlineRuns(element.children, {}, state.context);
|
|
243
|
-
return [decorateParagraph({
|
|
244
|
-
kind: "paragraph",
|
|
245
|
-
runs: inline.runs,
|
|
246
|
-
...constructsField(inline)
|
|
247
|
-
}, state)];
|
|
248
|
-
}
|
|
252
|
+
case "figcaption": return readContainerChildren(element.children, state);
|
|
249
253
|
case "img": {
|
|
250
254
|
const block = readImage(element, state);
|
|
251
255
|
return block === void 0 ? [] : [block];
|
|
@@ -323,11 +327,7 @@ function readPreRuns(nodes, context) {
|
|
|
323
327
|
const startRun = runs.length;
|
|
324
328
|
const nested = readPreRuns(node.children, context);
|
|
325
329
|
runs.push(...nested.runs);
|
|
326
|
-
|
|
327
|
-
...construct,
|
|
328
|
-
startRun: construct.startRun + startRun,
|
|
329
|
-
endRun: construct.endRun + startRun
|
|
330
|
-
});
|
|
330
|
+
constructs.push(...require_xhtml_inline.rebaseConstructs(nested.constructs, startRun));
|
|
331
331
|
if (footnoteName !== void 0) constructs.push({
|
|
332
332
|
descriptor: {
|
|
333
333
|
kind: "anchor",
|
|
@@ -450,23 +450,12 @@ function readDefinitionListEntries(nodes, state) {
|
|
|
450
450
|
for (const child of nodes) {
|
|
451
451
|
if (child.type === "element" && child.tag === "dt") {
|
|
452
452
|
flushStray();
|
|
453
|
-
|
|
454
|
-
blocks.push(decorateParagraph({
|
|
455
|
-
kind: "paragraph",
|
|
456
|
-
runs: inline.runs,
|
|
457
|
-
...constructsField(inline)
|
|
458
|
-
}, state));
|
|
453
|
+
blocks.push(...readContainerChildren(child.children, state));
|
|
459
454
|
continue;
|
|
460
455
|
}
|
|
461
456
|
if (child.type === "element" && child.tag === "dd") {
|
|
462
457
|
flushStray();
|
|
463
|
-
|
|
464
|
-
blocks.push(decorateParagraph({
|
|
465
|
-
kind: "paragraph",
|
|
466
|
-
runs: inline.runs,
|
|
467
|
-
...constructsField(inline),
|
|
468
|
-
indentLeftPt: 36 + state.quoteDepth * 36
|
|
469
|
-
}, state));
|
|
458
|
+
blocks.push(...readContainerChildren(child.children, withExtraIndent(state, 36)));
|
|
470
459
|
continue;
|
|
471
460
|
}
|
|
472
461
|
if (child.type === "element" && child.tag === "div") {
|
|
@@ -539,16 +528,11 @@ function readTable(element, state) {
|
|
|
539
528
|
if (cellNode.type === "element" && (cellNode.tag === "td" || cellNode.tag === "th")) {
|
|
540
529
|
flushStrayCell();
|
|
541
530
|
const cellStyle = cellNode.tag === "th" ? { bold: true } : {};
|
|
542
|
-
const
|
|
543
|
-
const paragraph = {
|
|
544
|
-
kind: "paragraph",
|
|
545
|
-
runs: inline.runs,
|
|
546
|
-
...constructsField(inline)
|
|
547
|
-
};
|
|
531
|
+
const cellBlocks = readContainerChildren(cellNode.children, state, cellStyle);
|
|
548
532
|
const colSpan = positiveIntAttr(cellNode, "colspan");
|
|
549
533
|
const rowSpan = positiveIntAttr(cellNode, "rowspan");
|
|
550
534
|
cells.push({
|
|
551
|
-
blocks:
|
|
535
|
+
blocks: cellBlocks,
|
|
552
536
|
...colSpan !== void 0 ? { colSpan } : {},
|
|
553
537
|
...rowSpan !== void 0 ? { rowSpan } : {}
|
|
554
538
|
});
|
|
@@ -611,8 +595,8 @@ function collectColgroupStrayContent(section, strayNodes, context) {
|
|
|
611
595
|
}
|
|
612
596
|
}
|
|
613
597
|
function readTableCaption(captionElement, isDuplicate, state) {
|
|
614
|
-
const
|
|
615
|
-
if (
|
|
598
|
+
const captionBlocks = readContainerChildren(captionElement.children, state);
|
|
599
|
+
if (captionBlocks.length === 0) return [];
|
|
616
600
|
if (isDuplicate) state.context.sink({
|
|
617
601
|
code: require_diagnostics.EpubDiagnosticCodes.TABLE_DUPLICATE_CAPTION,
|
|
618
602
|
severity: "info",
|
|
@@ -625,11 +609,7 @@ function readTableCaption(captionElement, isDuplicate, state) {
|
|
|
625
609
|
message: "<caption> has no document-schema.js table-caption field to carry its own distinct tag; read as an ordinary paragraph immediately before the table",
|
|
626
610
|
href: state.context.sourceHref
|
|
627
611
|
});
|
|
628
|
-
return
|
|
629
|
-
kind: "paragraph",
|
|
630
|
-
runs: captionInline.runs,
|
|
631
|
-
...constructsField(captionInline)
|
|
632
|
-
}, state)];
|
|
612
|
+
return captionBlocks;
|
|
633
613
|
}
|
|
634
614
|
function positiveIntAttr(element, name) {
|
|
635
615
|
const raw = require_xml_query.attrValue(element, name);
|
package/dist/xhtml/read.js
CHANGED
|
@@ -9,7 +9,7 @@ import { buildXml } from "../xml/build.js";
|
|
|
9
9
|
import { isInertElement, reportInertElementSkip } from "./context.js";
|
|
10
10
|
import { isFootnoteAside, isFootnoteReferenceAnchor } from "./footnote.js";
|
|
11
11
|
import { HORIZONTAL_RULE_STYLE_ID, MONOSPACE_FONT_FAMILY } from "./style-constants.js";
|
|
12
|
-
import { buildInlineRuns } from "./inline.js";
|
|
12
|
+
import { buildInlineRuns, rebaseConstructs } from "./inline.js";
|
|
13
13
|
import { mintListNumId } from "./list-id.js";
|
|
14
14
|
import { clampHeadingLevel } from "document-schema.js";
|
|
15
15
|
//#region src/xhtml/read.ts
|
|
@@ -33,6 +33,12 @@ function withQuote(state) {
|
|
|
33
33
|
quoteDepth: state.quoteDepth + 1
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
|
+
function withExtraIndent(state, pt) {
|
|
37
|
+
return {
|
|
38
|
+
...state,
|
|
39
|
+
extraIndentPt: state.extraIndentPt + pt
|
|
40
|
+
};
|
|
41
|
+
}
|
|
36
42
|
function withListItem(state, listItem) {
|
|
37
43
|
return {
|
|
38
44
|
...state,
|
|
@@ -47,9 +53,13 @@ function decorateParagraph(paragraph, state) {
|
|
|
47
53
|
let decorated = paragraph;
|
|
48
54
|
if (state.quoteDepth > 0) decorated = {
|
|
49
55
|
...decorated,
|
|
50
|
-
indentLeftPt: state.quoteDepth * 36,
|
|
56
|
+
indentLeftPt: state.quoteDepth * 36 + state.extraIndentPt,
|
|
51
57
|
styleId: decorated.styleId ?? "Quote"
|
|
52
58
|
};
|
|
59
|
+
else if (state.extraIndentPt > 0) decorated = {
|
|
60
|
+
...decorated,
|
|
61
|
+
indentLeftPt: state.extraIndentPt
|
|
62
|
+
};
|
|
53
63
|
if (state.listItem !== void 0) {
|
|
54
64
|
const membership = {
|
|
55
65
|
numId: state.listItem.numId,
|
|
@@ -131,6 +141,7 @@ function readXhtmlBody(xml, options) {
|
|
|
131
141
|
context,
|
|
132
142
|
minter: createIdMinter(),
|
|
133
143
|
quoteDepth: 0,
|
|
144
|
+
extraIndentPt: 0,
|
|
134
145
|
listItem: void 0,
|
|
135
146
|
list: void 0,
|
|
136
147
|
contentWidthPt: options.contentWidthPt
|
|
@@ -164,12 +175,12 @@ const BLOCK_LEVEL_TAGS = /* @__PURE__ */ new Set([
|
|
|
164
175
|
"nav",
|
|
165
176
|
"img"
|
|
166
177
|
]);
|
|
167
|
-
function readContainerChildren(nodes, state) {
|
|
178
|
+
function readContainerChildren(nodes, state, baseStyle = {}) {
|
|
168
179
|
const blocks = [];
|
|
169
180
|
let segment = [];
|
|
170
181
|
const flush = () => {
|
|
171
182
|
if (segment.length === 0) return;
|
|
172
|
-
const inline = buildInlineRuns(segment,
|
|
183
|
+
const inline = buildInlineRuns(segment, baseStyle, state.context);
|
|
173
184
|
segment = [];
|
|
174
185
|
if (inline.runs.every((run) => run.text.trim().length === 0) && inline.constructs.length === 0) return;
|
|
175
186
|
const paragraph = {
|
|
@@ -237,14 +248,7 @@ function readBlockElementInner(element, state) {
|
|
|
237
248
|
case "dl": return readDefinitionList(element, state);
|
|
238
249
|
case "table": return readTable(element, state);
|
|
239
250
|
case "figure": return readContainerChildren(element.children, state);
|
|
240
|
-
case "figcaption":
|
|
241
|
-
const inline = buildInlineRuns(element.children, {}, state.context);
|
|
242
|
-
return [decorateParagraph({
|
|
243
|
-
kind: "paragraph",
|
|
244
|
-
runs: inline.runs,
|
|
245
|
-
...constructsField(inline)
|
|
246
|
-
}, state)];
|
|
247
|
-
}
|
|
251
|
+
case "figcaption": return readContainerChildren(element.children, state);
|
|
248
252
|
case "img": {
|
|
249
253
|
const block = readImage(element, state);
|
|
250
254
|
return block === void 0 ? [] : [block];
|
|
@@ -322,11 +326,7 @@ function readPreRuns(nodes, context) {
|
|
|
322
326
|
const startRun = runs.length;
|
|
323
327
|
const nested = readPreRuns(node.children, context);
|
|
324
328
|
runs.push(...nested.runs);
|
|
325
|
-
|
|
326
|
-
...construct,
|
|
327
|
-
startRun: construct.startRun + startRun,
|
|
328
|
-
endRun: construct.endRun + startRun
|
|
329
|
-
});
|
|
329
|
+
constructs.push(...rebaseConstructs(nested.constructs, startRun));
|
|
330
330
|
if (footnoteName !== void 0) constructs.push({
|
|
331
331
|
descriptor: {
|
|
332
332
|
kind: "anchor",
|
|
@@ -449,23 +449,12 @@ function readDefinitionListEntries(nodes, state) {
|
|
|
449
449
|
for (const child of nodes) {
|
|
450
450
|
if (child.type === "element" && child.tag === "dt") {
|
|
451
451
|
flushStray();
|
|
452
|
-
|
|
453
|
-
blocks.push(decorateParagraph({
|
|
454
|
-
kind: "paragraph",
|
|
455
|
-
runs: inline.runs,
|
|
456
|
-
...constructsField(inline)
|
|
457
|
-
}, state));
|
|
452
|
+
blocks.push(...readContainerChildren(child.children, state));
|
|
458
453
|
continue;
|
|
459
454
|
}
|
|
460
455
|
if (child.type === "element" && child.tag === "dd") {
|
|
461
456
|
flushStray();
|
|
462
|
-
|
|
463
|
-
blocks.push(decorateParagraph({
|
|
464
|
-
kind: "paragraph",
|
|
465
|
-
runs: inline.runs,
|
|
466
|
-
...constructsField(inline),
|
|
467
|
-
indentLeftPt: 36 + state.quoteDepth * 36
|
|
468
|
-
}, state));
|
|
457
|
+
blocks.push(...readContainerChildren(child.children, withExtraIndent(state, 36)));
|
|
469
458
|
continue;
|
|
470
459
|
}
|
|
471
460
|
if (child.type === "element" && child.tag === "div") {
|
|
@@ -538,16 +527,11 @@ function readTable(element, state) {
|
|
|
538
527
|
if (cellNode.type === "element" && (cellNode.tag === "td" || cellNode.tag === "th")) {
|
|
539
528
|
flushStrayCell();
|
|
540
529
|
const cellStyle = cellNode.tag === "th" ? { bold: true } : {};
|
|
541
|
-
const
|
|
542
|
-
const paragraph = {
|
|
543
|
-
kind: "paragraph",
|
|
544
|
-
runs: inline.runs,
|
|
545
|
-
...constructsField(inline)
|
|
546
|
-
};
|
|
530
|
+
const cellBlocks = readContainerChildren(cellNode.children, state, cellStyle);
|
|
547
531
|
const colSpan = positiveIntAttr(cellNode, "colspan");
|
|
548
532
|
const rowSpan = positiveIntAttr(cellNode, "rowspan");
|
|
549
533
|
cells.push({
|
|
550
|
-
blocks:
|
|
534
|
+
blocks: cellBlocks,
|
|
551
535
|
...colSpan !== void 0 ? { colSpan } : {},
|
|
552
536
|
...rowSpan !== void 0 ? { rowSpan } : {}
|
|
553
537
|
});
|
|
@@ -610,8 +594,8 @@ function collectColgroupStrayContent(section, strayNodes, context) {
|
|
|
610
594
|
}
|
|
611
595
|
}
|
|
612
596
|
function readTableCaption(captionElement, isDuplicate, state) {
|
|
613
|
-
const
|
|
614
|
-
if (
|
|
597
|
+
const captionBlocks = readContainerChildren(captionElement.children, state);
|
|
598
|
+
if (captionBlocks.length === 0) return [];
|
|
615
599
|
if (isDuplicate) state.context.sink({
|
|
616
600
|
code: EpubDiagnosticCodes.TABLE_DUPLICATE_CAPTION,
|
|
617
601
|
severity: "info",
|
|
@@ -624,11 +608,7 @@ function readTableCaption(captionElement, isDuplicate, state) {
|
|
|
624
608
|
message: "<caption> has no document-schema.js table-caption field to carry its own distinct tag; read as an ordinary paragraph immediately before the table",
|
|
625
609
|
href: state.context.sourceHref
|
|
626
610
|
});
|
|
627
|
-
return
|
|
628
|
-
kind: "paragraph",
|
|
629
|
-
runs: captionInline.runs,
|
|
630
|
-
...constructsField(captionInline)
|
|
631
|
-
}, state)];
|
|
611
|
+
return captionBlocks;
|
|
632
612
|
}
|
|
633
613
|
function positiveIntAttr(element, name) {
|
|
634
614
|
const raw = attrValue(element, name);
|