@xiee/utils 1.14.134 → 1.14.136

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/AGENTS.md ADDED
@@ -0,0 +1,33 @@
1
+ # Notes for AI agents
2
+
3
+ Small browser scripts and stylesheets in `js/` and `css/`, published as `@xiee/utils`. The `*.min.*` files are built by `build.sh` in CI; don't edit or commit them.
4
+
5
+ ## Tests
6
+
7
+ Playwright tests in `tests/` load HTML fixtures in headless Chromium (jsdom is no use: the scripts need real layout and a real browser).
8
+
9
+ ```sh
10
+ npm ci # first time only
11
+ npx playwright install chromium # first time only, unless a browser is installed
12
+ npm test # all tests
13
+ npx playwright test -g tabset # tests whose name matches
14
+ CHROMIUM_PATH=/usr/bin/chromium-browser npm test # use an installed browser
15
+ ```
16
+
17
+ - `.npmrc` pins the public npm registry so `package-lock.json` never gets URLs of a machine-specific (e.g., internal) registry; check with `grep -c resolved package-lock.json` vs `grep -c registry.npmjs.org package-lock.json` after changing dependencies.
18
+ - Fix a bug or add a feature => add a test that fails without the change.
19
+ - Tests for a script go in `tests/<script>.spec.js`; write the fixture HTML inline and load the script from the repo by absolute `file://` URL (see `fixture()` in `tests/helper.js`).
20
+ - Assert behavior and invariants, not pixels or exact layout. A hang shows up as a timeout.
21
+ - `pages.js` tests (`tests/pages.spec.js`): `paginate()` paginates a fixture and returns the pages. Invariants: pagination finishes, pages fit, no blank page, no text lost/duplicated/reordered, the pieces of broken elements are consistent (`bad` from `paginate()`: a non-last piece ends its parent on the page, a non-first piece starts it, none is both first and last).
22
+ - Testing `pages.js` on a real document (e.g., the litedown book): use its raw HTML (`curl`), or open the live URL and `page.route()` the CDN `pages.min.js/css` to the repo files. Don't save `page.content()` and test that: the re-parsing closes `<p>` at the `<div>` of a note that `sidenotes.js` put inside it, which creates bugs that don't exist.
23
+ - Tests for white space at page bottoms: a filler `div` of `B - free` px (`B`: body height of a probe page) before the block, sweep `free` over a range (the page capacity is not exactly the body height), assert on page 1 (see `firstPages()`), and check that the test fails without the change.
24
+ - Fill mode (`pagesjs-filling`: `height: auto`, `scrollHeight` is the natural height) differs from the final layout (fixed height; the body may hang over into the space above the footer). What the reader sees must be measured in the final layout (`checkOffsets()` for `page-multiple`).
25
+ - Footnotes and citations are measured as a `.footnotes` block after the page body, like in the end (`syncNotes()`); in the text they are hidden markers (`span.pagesjs-note`) that go with their references. Don't measure them inline or add CSS to approximate their space.
26
+ - By design, not bugs: a 2-line paragraph is not split (orphan/widow), a heading may end a page, `.figure`/diagrams/flex containers are never broken (they overflow small pages), `moveShortHead()` compares with one line.
27
+ - To compare a change: dump the `.pagesjs-page` HTML before and after (normalize file paths in link titles, random `md-<n>-<n>` ids and `data-page-number`), and check that the concatenated body text is identical.
28
+
29
+ ## Releases
30
+
31
+ 1. Commit the version bump in `package.json` as `Bump to X.Y.Z` (patch +1 unless told otherwise), after tests pass.
32
+ 2. Tag that commit `vX.Y.Z` and push the commit and the tag. Pushing a `v*` tag triggers `.github/workflows/npm-publish.yml`, which builds the minified files, runs `npm publish`, and purges the CDN cache.
33
+ 3. Pushing and tagging are outward-facing: do them only when the user asks for a release.
package/css/pages.css CHANGED
@@ -223,13 +223,6 @@
223
223
  .pagesjs-page {
224
224
  opacity: 0; /* don't show the page that is being filled (only the progress) */
225
225
  height: auto;
226
- .pagesjs-body:has(.footnotes) {
227
- margin-bottom: 1em;
228
- .footnotes {
229
- float: left;
230
- width: 100%;
231
- }
232
- }
233
226
  }
234
227
  }
235
228
  }
package/css/pages.min.css CHANGED
@@ -1,2 +1,2 @@
1
- :root{--paper-width:210mm;--paper-height:297mm;--paper-margin-top:40px;--paper-margin-right:80px;--paper-margin-bottom:40px;--paper-margin-left:80px;--page-header-height:40px;--page-header-bottom:40px;--page-footer-height:40px;--page-footer-top:40px}@page{size:var(--paper-width) var(--paper-height);margin:0}@page multiple{margin-top:var(--paper-margin-top);margin-bottom:var(--paper-margin-bottom)}.page-multiple{page:multiple}.pagesjs{flex-wrap:wrap;justify-content:center;gap:5mm;max-width:100%;margin:5mm;padding:0;display:flex;& .pagesjs-front,& .chapter{min-height:unset;box-shadow:none}&>*,&:not(:has(.pagesjs-front)):has(.chapter-toc) #TOC:not(.chapter-toc){display:none}& .pagesjs-page{width:var(--paper-width);height:var(--paper-height);padding:var(--paper-margin-top) var(--paper-margin-right) var(--paper-margin-bottom) var(--paper-margin-left);break-after:page;flex-direction:column;justify-content:space-between;display:flex;overflow:hidden;& img{max-width:100%}& .chapter-before,& .chapter-after,& .buttons:has(+.chapter-before){display:none}& #TOC{border:none;margin-left:auto;padding:0;&:not(.chapter-toc):is(.fragment-first,:not(.pagesjs-fragmented)):before{content:"Contents";margin-bottom:1em;font-size:1.5em;font-weight:700;display:block}& a{display:flex;&:after{content:attr(data-page-number);align-self:end;margin-left:1ch}& .section-number{margin-right:.3em}& .toc-text{flex:1 0;position:relative;overflow:hidden;&:after{content:"";border-bottom:1px dashed;width:100%;margin-left:1ch;position:absolute;bottom:1.5ex}}}}& .pagesjs-wrap{box-shadow:none!important;float:none!important;background:0 0!important;border:none!important;width:auto!important;max-width:none!important;height:auto!important;min-height:0!important;margin:0!important;padding:0!important;display:block!important;position:static!important;transform:none!important}& .pagesjs-run{display:block}& .pagesjs-fragmented{&:not(.fragment-first){border-top:none;margin-top:0;padding-top:0;&>thead{opacity:.5}}&:not(.fragment-last){border-bottom:none;margin-bottom:0;padding-bottom:0;&>tfoot{opacity:.5}}}& li.pagesjs-fragmented:not(.fragment-first)::marker{content:""}& .fullwidth{float:none;max-width:none;width:var(--paper-width);margin-left:calc(0px - var(--paper-margin-left));transform:none}& .footnotes{margin-top:1.5em}& .footnotes:before{content:"";border-top:1px solid;max-width:20em;display:block}&:has(.side-left,.embed-left) .pagesjs-body{padding-left:calc(0px - var(--side-margin));& .fullwidth{transform:translate(var(--side-margin))}}&:has(.side-right,.embed-right) .pagesjs-body{padding-right:calc(0px - var(--side-margin))}& .side{background:0 0;font-size:.9em}}}.pagesjs>.pagesjs-progress{z-index:9999;color:#fff;background:#000000bf;border-radius:1em;padding:.3em .8em;font:14px sans-serif;display:block;position:fixed;top:50%;left:50%;transform:translate(-50%,-50%)}.pagesjs-settle .pagesjs-body{padding:0!important}.pagesjs-header,.pagesjs-footer{justify-content:space-between;font-size:.9em;display:flex}.pagesjs-header{flex:0 0 var(--page-header-height);margin-bottom:var(--page-header-bottom);align-items:end;&:before{content:attr(data-main-title)}&:after{content:attr(data-page-title)}}.pagesjs-footer{flex:0 0 var(--page-footer-height);margin-top:var(--page-footer-top);align-items:start;&:before{content:" "}&:after{content:attr(data-page-number)}}.pagesjs-body{flex-grow:1;min-height:0;position:relative}@media only screen{.pagesjs{&:has(.pagesjs-page){background:#f7f7f7}& .pagesjs-page{background:#fff}& .page-multiple{overflow-y:auto}}.pagesjs-filling{display:block;& .pagesjs-page{opacity:0;height:auto;& .pagesjs-body:has(.footnotes){margin-bottom:1em;& .footnotes{float:left;width:100%}}}}}@media print{.pagesjs{gap:0;margin:0;& .page-multiple{height:auto;padding-top:0;padding-bottom:0}}}
1
+ :root{--paper-width:210mm;--paper-height:297mm;--paper-margin-top:40px;--paper-margin-right:80px;--paper-margin-bottom:40px;--paper-margin-left:80px;--page-header-height:40px;--page-header-bottom:40px;--page-footer-height:40px;--page-footer-top:40px}@page{size:var(--paper-width) var(--paper-height);margin:0}@page multiple{margin-top:var(--paper-margin-top);margin-bottom:var(--paper-margin-bottom)}.page-multiple{page:multiple}.pagesjs{flex-wrap:wrap;justify-content:center;gap:5mm;max-width:100%;margin:5mm;padding:0;display:flex;& .pagesjs-front,& .chapter{min-height:unset;box-shadow:none}&>*,&:not(:has(.pagesjs-front)):has(.chapter-toc) #TOC:not(.chapter-toc){display:none}& .pagesjs-page{width:var(--paper-width);height:var(--paper-height);padding:var(--paper-margin-top) var(--paper-margin-right) var(--paper-margin-bottom) var(--paper-margin-left);break-after:page;flex-direction:column;justify-content:space-between;display:flex;overflow:hidden;& img{max-width:100%}& .chapter-before,& .chapter-after,& .buttons:has(+.chapter-before){display:none}& #TOC{border:none;margin-left:auto;padding:0;&:not(.chapter-toc):is(.fragment-first,:not(.pagesjs-fragmented)):before{content:"Contents";margin-bottom:1em;font-size:1.5em;font-weight:700;display:block}& a{display:flex;&:after{content:attr(data-page-number);align-self:end;margin-left:1ch}& .section-number{margin-right:.3em}& .toc-text{flex:1 0;position:relative;overflow:hidden;&:after{content:"";border-bottom:1px dashed;width:100%;margin-left:1ch;position:absolute;bottom:1.5ex}}}}& .pagesjs-wrap{box-shadow:none!important;float:none!important;background:0 0!important;border:none!important;width:auto!important;max-width:none!important;height:auto!important;min-height:0!important;margin:0!important;padding:0!important;display:block!important;position:static!important;transform:none!important}& .pagesjs-run{display:block}& .pagesjs-fragmented{&:not(.fragment-first){border-top:none;margin-top:0;padding-top:0;&>thead{opacity:.5}}&:not(.fragment-last){border-bottom:none;margin-bottom:0;padding-bottom:0;&>tfoot{opacity:.5}}}& li.pagesjs-fragmented:not(.fragment-first)::marker{content:""}& .fullwidth{float:none;max-width:none;width:var(--paper-width);margin-left:calc(0px - var(--paper-margin-left));transform:none}& .footnotes{margin-top:1.5em}& .footnotes:before{content:"";border-top:1px solid;max-width:20em;display:block}&:has(.side-left,.embed-left) .pagesjs-body{padding-left:calc(0px - var(--side-margin));& .fullwidth{transform:translate(var(--side-margin))}}&:has(.side-right,.embed-right) .pagesjs-body{padding-right:calc(0px - var(--side-margin))}& .side{background:0 0;font-size:.9em}}}.pagesjs>.pagesjs-progress{z-index:9999;color:#fff;background:#000000bf;border-radius:1em;padding:.3em .8em;font:14px sans-serif;display:block;position:fixed;top:50%;left:50%;transform:translate(-50%,-50%)}.pagesjs-settle .pagesjs-body{padding:0!important}.pagesjs-header,.pagesjs-footer{justify-content:space-between;font-size:.9em;display:flex}.pagesjs-header{flex:0 0 var(--page-header-height);margin-bottom:var(--page-header-bottom);align-items:end;&:before{content:attr(data-main-title)}&:after{content:attr(data-page-title)}}.pagesjs-footer{flex:0 0 var(--page-footer-height);margin-top:var(--page-footer-top);align-items:start;&:before{content:" "}&:after{content:attr(data-page-number)}}.pagesjs-body{flex-grow:1;min-height:0;position:relative}@media only screen{.pagesjs{&:has(.pagesjs-page){background:#f7f7f7}& .pagesjs-page{background:#fff}& .page-multiple{overflow-y:auto}}.pagesjs-filling{display:block;& .pagesjs-page{opacity:0;height:auto}}}@media print{.pagesjs{gap:0;margin:0;& .page-multiple{height:auto;padding-top:0;padding-bottom:0}}}
2
2
  /*# sourceMappingURL=pages.min.css.map */
@@ -1 +1 @@
1
- {"version":3,"mappings":"AAAA,0PAYA,2DAIA,2FAIA,6BAGA,wGAQE,6DAIA,sFAGA,oRASE,qBAGA,iFAGA,8CAIE,4JAOA,iBAEE,sEAKA,oCAGA,uDAIE,yGAaN,2TAeA,6BAIA,sBACE,kEAIE,oBAEF,0EAIE,qBAIJ,gEAGA,gIAOA,8BAGA,iFAMA,wFAEE,sDAIF,2FAGA,wCAMJ,8MAaA,kDAIA,0FAKA,2GAIE,uCAGA,uCAIF,uGAIE,qBAGA,wCAIF,yDAKA,mBACE,SACE,wCAGA,gCAGA,kCAIF,+BAEE,sCAGE,kDAEE,uCAQR,aACE,wBAGE","sources":["pages.css"],"sourcesContent":[":root {\n --paper-width: 210mm;\n --paper-height: 297mm;\n --paper-margin-top: 40px;\n --paper-margin-right: 80px;\n --paper-margin-bottom: 40px;\n --paper-margin-left: 80px;\n --page-header-height: 40px;\n --page-header-bottom: 40px;\n --page-footer-height: 40px;\n --page-footer-top: 40px;\n}\n@page {\n size: var(--paper-width) var(--paper-height);\n margin: 0;\n}\n@page multiple {\n margin-top: var(--paper-margin-top);\n margin-bottom: var(--paper-margin-bottom);\n}\n.page-multiple {\n page: multiple;\n}\n.pagesjs {\n padding: 0;\n max-width: 100%;\n margin: 5mm;\n display: flex;\n justify-content: center;\n flex-wrap: wrap;\n gap: 5mm;\n .pagesjs-front, .chapter {\n min-height: unset;\n box-shadow: none;\n }\n & > *, &:not(:has(.pagesjs-front)):has(.chapter-toc) #TOC:not(.chapter-toc) {\n display: none;\n }\n .pagesjs-page {\n width: var(--paper-width);\n height: var(--paper-height);\n padding: var(--paper-margin-top) var(--paper-margin-right) var(--paper-margin-bottom) var(--paper-margin-left);\n break-after: page;\n display: flex;\n flex-direction: column;\n justify-content: space-between;\n overflow: hidden;\n img {\n max-width: 100%;\n }\n .chapter-before, .chapter-after, .buttons:has(+ .chapter-before) {\n display: none;\n }\n #TOC {\n border: none;\n padding: 0;\n margin-left: auto;\n &:not(.chapter-toc):is(.fragment-first, :not(.pagesjs-fragmented))::before {\n content: \"Contents\";\n display: block;\n font-weight: bold;\n font-size: 1.5em;\n margin-bottom: 1em;\n }\n a {\n display: flex;\n &::after {\n content: attr(data-page-number);\n align-self: end;\n margin-left: 1ch;\n }\n .section-number {\n margin-right: .3em;\n }\n .toc-text {\n position: relative;\n flex: 1 0;\n overflow: hidden;\n &::after {\n content: \"\";\n width: 100%;\n position: absolute;\n bottom: 1.5ex;\n margin-left: 1ch;\n border-bottom: dashed 1px;\n }\n }\n }\n }\n /* wrappers cloned from the content root and its ancestors: keep their\n context for CSS selectors, but not their boxes */\n .pagesjs-wrap {\n display: block !important;\n margin: 0 !important;\n padding: 0 !important;\n border: none !important;\n box-shadow: none !important;\n background: none !important;\n width: auto !important;\n max-width: none !important;\n min-height: 0 !important;\n height: auto !important;\n float: none !important;\n position: static !important;\n transform: none !important;\n }\n .pagesjs-run {\n display: block;\n }\n /* pieces of a fragmented element: slice it (instead of decorating each piece) */\n .pagesjs-fragmented {\n &:not(.fragment-first) {\n border-top: none;\n margin-top: 0;\n padding-top: 0;\n & > thead { opacity: .5; }\n }\n &:not(.fragment-last) {\n border-bottom: none;\n margin-bottom: 0;\n padding-bottom: 0;\n & > tfoot { opacity: .5; }\n }\n }\n /* a list item continued from the previous page has no marker */\n li.pagesjs-fragmented:not(.fragment-first)::marker {\n content: \"\";\n }\n .fullwidth {\n float: none;\n max-width: none;\n width: var(--paper-width);\n margin-left: calc(0px - var(--paper-margin-left));\n transform: none;\n }\n .footnotes {\n margin-top: 1.5em;\n }\n .footnotes::before {\n content: \"\";\n display: block;\n max-width: 20em;\n border-top: solid 1px;\n }\n &:has(.side-left, .embed-left) .pagesjs-body {\n padding-left: calc(0px - var(--side-margin));\n .fullwidth {\n transform: translate(var(--side-margin));\n }\n }\n &:has(.side-right, .embed-right) .pagesjs-body {\n padding-right: calc(0px - var(--side-margin));\n }\n .side {\n font-size: .9em;\n background: none;\n }\n }\n}\n.pagesjs > .pagesjs-progress {\n display: block;\n position: fixed;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n z-index: 9999;\n padding: .3em .8em;\n border-radius: 1em;\n background: rgba(0, 0, 0, .75);\n color: white;\n font: 14px sans-serif;\n}\n.pagesjs-settle .pagesjs-body {\n /* the probe page that holds all content has sides, but normal pages don't */\n padding: 0 !important;\n}\n.pagesjs-header, .pagesjs-footer {\n font-size: .9em;\n display: flex;\n justify-content: space-between;\n}\n.pagesjs-header {\n flex: 0 0 var(--page-header-height);\n margin-bottom: var(--page-header-bottom);\n align-items: end;\n &::before {\n content: attr(data-main-title);\n }\n &::after {\n content: attr(data-page-title);\n }\n}\n.pagesjs-footer {\n flex: 0 0 var(--page-footer-height);\n margin-top: var(--page-footer-top);\n align-items: start;\n &::before {\n content: \" \";\n }\n &::after {\n content: attr(data-page-number);\n }\n}\n.pagesjs-body {\n flex-grow: 1;\n min-height: 0; /* don't let the body push the footer down when content overhangs by a few pixels */\n position: relative;\n}\n@media only screen {\n .pagesjs {\n &:has(.pagesjs-page) {\n background: #f7f7f7;\n }\n .pagesjs-page {\n background: white;\n }\n .page-multiple {\n overflow-y: auto;\n }\n }\n .pagesjs-filling {\n display: block;\n .pagesjs-page {\n opacity: 0; /* don't show the page that is being filled (only the progress) */\n height: auto;\n .pagesjs-body:has(.footnotes) {\n margin-bottom: 1em;\n .footnotes {\n float: left;\n width: 100%;\n }\n }\n }\n }\n}\n@media print {\n .pagesjs {\n margin: 0;\n gap: 0;\n .page-multiple {\n padding-top: 0;\n padding-bottom: 0;\n height: auto;\n }\n }\n}\n"],"names":[]}
1
+ {"version":3,"mappings":"AAAA,0PAYA,2DAIA,2FAIA,6BAGA,wGAQE,6DAIA,sFAGA,oRASE,qBAGA,iFAGA,8CAIE,4JAOA,iBAEE,sEAKA,oCAGA,uDAIE,yGAaN,2TAeA,6BAIA,sBACE,kEAIE,oBAEF,0EAIE,qBAIJ,gEAGA,gIAOA,8BAGA,iFAMA,wFAEE,sDAIF,2FAGA,wCAMJ,8MAaA,kDAIA,0FAKA,2GAIE,uCAGA,uCAIF,uGAIE,qBAGA,wCAIF,yDAKA,mBACE,SACE,wCAGA,gCAGA,kCAIF,+BAEE,wCAMJ,aACE,wBAGE","sources":["pages.css"],"sourcesContent":[":root {\n --paper-width: 210mm;\n --paper-height: 297mm;\n --paper-margin-top: 40px;\n --paper-margin-right: 80px;\n --paper-margin-bottom: 40px;\n --paper-margin-left: 80px;\n --page-header-height: 40px;\n --page-header-bottom: 40px;\n --page-footer-height: 40px;\n --page-footer-top: 40px;\n}\n@page {\n size: var(--paper-width) var(--paper-height);\n margin: 0;\n}\n@page multiple {\n margin-top: var(--paper-margin-top);\n margin-bottom: var(--paper-margin-bottom);\n}\n.page-multiple {\n page: multiple;\n}\n.pagesjs {\n padding: 0;\n max-width: 100%;\n margin: 5mm;\n display: flex;\n justify-content: center;\n flex-wrap: wrap;\n gap: 5mm;\n .pagesjs-front, .chapter {\n min-height: unset;\n box-shadow: none;\n }\n & > *, &:not(:has(.pagesjs-front)):has(.chapter-toc) #TOC:not(.chapter-toc) {\n display: none;\n }\n .pagesjs-page {\n width: var(--paper-width);\n height: var(--paper-height);\n padding: var(--paper-margin-top) var(--paper-margin-right) var(--paper-margin-bottom) var(--paper-margin-left);\n break-after: page;\n display: flex;\n flex-direction: column;\n justify-content: space-between;\n overflow: hidden;\n img {\n max-width: 100%;\n }\n .chapter-before, .chapter-after, .buttons:has(+ .chapter-before) {\n display: none;\n }\n #TOC {\n border: none;\n padding: 0;\n margin-left: auto;\n &:not(.chapter-toc):is(.fragment-first, :not(.pagesjs-fragmented))::before {\n content: \"Contents\";\n display: block;\n font-weight: bold;\n font-size: 1.5em;\n margin-bottom: 1em;\n }\n a {\n display: flex;\n &::after {\n content: attr(data-page-number);\n align-self: end;\n margin-left: 1ch;\n }\n .section-number {\n margin-right: .3em;\n }\n .toc-text {\n position: relative;\n flex: 1 0;\n overflow: hidden;\n &::after {\n content: \"\";\n width: 100%;\n position: absolute;\n bottom: 1.5ex;\n margin-left: 1ch;\n border-bottom: dashed 1px;\n }\n }\n }\n }\n /* wrappers cloned from the content root and its ancestors: keep their\n context for CSS selectors, but not their boxes */\n .pagesjs-wrap {\n display: block !important;\n margin: 0 !important;\n padding: 0 !important;\n border: none !important;\n box-shadow: none !important;\n background: none !important;\n width: auto !important;\n max-width: none !important;\n min-height: 0 !important;\n height: auto !important;\n float: none !important;\n position: static !important;\n transform: none !important;\n }\n .pagesjs-run {\n display: block;\n }\n /* pieces of a fragmented element: slice it (instead of decorating each piece) */\n .pagesjs-fragmented {\n &:not(.fragment-first) {\n border-top: none;\n margin-top: 0;\n padding-top: 0;\n & > thead { opacity: .5; }\n }\n &:not(.fragment-last) {\n border-bottom: none;\n margin-bottom: 0;\n padding-bottom: 0;\n & > tfoot { opacity: .5; }\n }\n }\n /* a list item continued from the previous page has no marker */\n li.pagesjs-fragmented:not(.fragment-first)::marker {\n content: \"\";\n }\n .fullwidth {\n float: none;\n max-width: none;\n width: var(--paper-width);\n margin-left: calc(0px - var(--paper-margin-left));\n transform: none;\n }\n .footnotes {\n margin-top: 1.5em;\n }\n .footnotes::before {\n content: \"\";\n display: block;\n max-width: 20em;\n border-top: solid 1px;\n }\n &:has(.side-left, .embed-left) .pagesjs-body {\n padding-left: calc(0px - var(--side-margin));\n .fullwidth {\n transform: translate(var(--side-margin));\n }\n }\n &:has(.side-right, .embed-right) .pagesjs-body {\n padding-right: calc(0px - var(--side-margin));\n }\n .side {\n font-size: .9em;\n background: none;\n }\n }\n}\n.pagesjs > .pagesjs-progress {\n display: block;\n position: fixed;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n z-index: 9999;\n padding: .3em .8em;\n border-radius: 1em;\n background: rgba(0, 0, 0, .75);\n color: white;\n font: 14px sans-serif;\n}\n.pagesjs-settle .pagesjs-body {\n /* the probe page that holds all content has sides, but normal pages don't */\n padding: 0 !important;\n}\n.pagesjs-header, .pagesjs-footer {\n font-size: .9em;\n display: flex;\n justify-content: space-between;\n}\n.pagesjs-header {\n flex: 0 0 var(--page-header-height);\n margin-bottom: var(--page-header-bottom);\n align-items: end;\n &::before {\n content: attr(data-main-title);\n }\n &::after {\n content: attr(data-page-title);\n }\n}\n.pagesjs-footer {\n flex: 0 0 var(--page-footer-height);\n margin-top: var(--page-footer-top);\n align-items: start;\n &::before {\n content: \" \";\n }\n &::after {\n content: attr(data-page-number);\n }\n}\n.pagesjs-body {\n flex-grow: 1;\n min-height: 0; /* don't let the body push the footer down when content overhangs by a few pixels */\n position: relative;\n}\n@media only screen {\n .pagesjs {\n &:has(.pagesjs-page) {\n background: #f7f7f7;\n }\n .pagesjs-page {\n background: white;\n }\n .page-multiple {\n overflow-y: auto;\n }\n }\n .pagesjs-filling {\n display: block;\n .pagesjs-page {\n opacity: 0; /* don't show the page that is being filled (only the progress) */\n height: auto;\n }\n }\n}\n@media print {\n .pagesjs {\n margin: 0;\n gap: 0;\n .page-multiple {\n padding-top: 0;\n padding-bottom: 0;\n height: auto;\n }\n }\n}\n"],"names":[]}
package/js/fix-toc.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // fix some issues in TOC generated by Hugo (Blackfriday or Goldmark)
2
2
  (function() {
3
- const toc = document.getElementById('TableOfContents');
3
+ const toc = document.querySelector('#TOC, #TableOfContents');
4
4
  if (!toc) return;
5
5
  // fix header ids and a hrefs if a header contains a link
6
6
  toc.querySelectorAll('a[href^="#"]').forEach((a) => {
package/js/fix-toc.min.js CHANGED
@@ -1,2 +1,2 @@
1
- !function(){const e=document.getElementById("TableOfContents");if(!e)return;e.querySelectorAll('a[href^="#"]').forEach(e=>{let t=e.getAttribute("href").replace(/^#/,"");const n=document.getElementById(t);if(t=t.replace(/-https?-.+$/,""),n&&(n.id=t),e.href="#"+t,""!==e.innerHTML)return;const r=e.nextElementSibling;r&&"A"===r.tagName&&(e.innerHTML=r.innerHTML,r.remove())});let t,n=e.querySelector("ul");1===n.childElementCount&&(t=n.firstElementChild,"LI"===t.tagName&&(n.outerHTML=t.innerHTML))}();
1
+ !function(){const e=document.querySelector("#TOC, #TableOfContents");if(!e)return;e.querySelectorAll('a[href^="#"]').forEach(e=>{let t=e.getAttribute("href").replace(/^#/,"");const n=document.getElementById(t);if(t=t.replace(/-https?-.+$/,""),n&&(n.id=t),e.href="#"+t,""!==e.innerHTML)return;const r=e.nextElementSibling;r&&"A"===r.tagName&&(e.innerHTML=r.innerHTML,r.remove())});let t,n=e.querySelector("ul");1===n.childElementCount&&(t=n.firstElementChild,"LI"===t.tagName&&(n.outerHTML=t.innerHTML))}();
2
2
  //# sourceMappingURL=fix-toc.min.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["toc","document","getElementById","querySelectorAll","forEach","a","id","getAttribute","replace","h","href","innerHTML","a2","nextElementSibling","tagName","remove","li","ul","querySelector","childElementCount","firstElementChild","outerHTML"],"sources":["fix-toc.js"],"mappings":"CACA,WACE,MAAMA,EAAMC,SAASC,eAAe,mBACpC,IAAKF,EAAK,OAEVA,EAAIG,iBAAiB,gBAAgBC,QAASC,IAC5C,IAAIC,EAAKD,EAAEE,aAAa,QAAQC,QAAQ,KAAM,IAC9C,MAAMC,EAAIR,SAASC,eAAeI,GAKlC,GAHAA,EAAKA,EAAGE,QAAQ,cAAe,IAC3BC,IAAGA,EAAEH,GAAKA,GAAID,EAAEK,KAAO,IAAMJ,EAEb,KAAhBD,EAAEM,UAAkB,OACxB,MAAMC,EAAKP,EAAEQ,mBACRD,GAAqB,MAAfA,EAAGE,UACdT,EAAEM,UAAYC,EAAGD,UACjBC,EAAGG,YAIL,IAAIC,EAAIC,EAAKjB,EAAIkB,cAAc,MACF,IAAzBD,EAAGE,oBACPH,EAAKC,EAAGG,kBACW,OAAfJ,EAAGF,UAEPG,EAAGI,UAAYL,EAAGL,WACnB,CAzBD","ignoreList":[]}
1
+ {"version":3,"names":["toc","document","querySelector","querySelectorAll","forEach","a","id","getAttribute","replace","h","getElementById","href","innerHTML","a2","nextElementSibling","tagName","remove","li","ul","childElementCount","firstElementChild","outerHTML"],"sources":["fix-toc.js"],"mappings":"CACA,WACE,MAAMA,EAAMC,SAASC,cAAc,0BACnC,IAAKF,EAAK,OAEVA,EAAIG,iBAAiB,gBAAgBC,QAASC,IAC5C,IAAIC,EAAKD,EAAEE,aAAa,QAAQC,QAAQ,KAAM,IAC9C,MAAMC,EAAIR,SAASS,eAAeJ,GAKlC,GAHAA,EAAKA,EAAGE,QAAQ,cAAe,IAC3BC,IAAGA,EAAEH,GAAKA,GAAID,EAAEM,KAAO,IAAML,EAEb,KAAhBD,EAAEO,UAAkB,OACxB,MAAMC,EAAKR,EAAES,mBACRD,GAAqB,MAAfA,EAAGE,UACdV,EAAEO,UAAYC,EAAGD,UACjBC,EAAGG,YAIL,IAAIC,EAAIC,EAAKlB,EAAIE,cAAc,MACF,IAAzBgB,EAAGC,oBACPF,EAAKC,EAAGE,kBACW,OAAfH,EAAGF,UAEPG,EAAGG,UAAYJ,EAAGL,WACnB,CAzBD","ignoreList":[]}
package/js/fullwidth.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // look for overflowed <pre> and <table>, and assign .fullwidth class to them
2
- document.querySelectorAll('pre,table,#TableOfContents').forEach(node => {
2
+ document.querySelectorAll('pre,table,#TOC,#TableOfContents').forEach(node => {
3
3
  function fullwidth(el) {
4
4
  el.classList.add('fullwidth');
5
5
  el.dataset.autoFullwidth = ''; // so sidenotes.js only undoes what we added
@@ -16,10 +16,18 @@ document.querySelectorAll('pre,table,#TableOfContents').forEach(node => {
16
16
  p && p.offsetWidth < node.offsetWidth && fullwidth(node);
17
17
  break;
18
18
  default:
19
- // assume it's #TableOfContents for now
19
+ // assume it's the TOC for now
20
20
  node.querySelectorAll('a').forEach(a => {
21
21
  // if a TOC line is wrapped, make TOC full-width
22
22
  !node.classList.contains('fullwidth') && a.getClientRects().length > 1 && fullwidth(node);
23
23
  });
24
24
  }
25
25
  });
26
+
27
+ // pages.js doesn't use the auto fullwidth feature; undo what we added
28
+ addEventListener('pagesjs:before', () => {
29
+ document.querySelectorAll('[data-auto-fullwidth]').forEach(el => {
30
+ el.classList.remove('fullwidth');
31
+ delete el.dataset.autoFullwidth;
32
+ });
33
+ });
@@ -1,2 +1,2 @@
1
- document.querySelectorAll("pre,table,#TableOfContents").forEach(t=>{function e(t){t.classList.add("fullwidth"),t.dataset.autoFullwidth=""}if(!t.closest(".fullwidth,.tabset"))switch(t.tagName){case"PRE":const l=t.firstElementChild;"CODE"===l?.tagName&&l.scrollWidth>l.offsetWidth&&e(l.parentNode);break;case"TABLE":const a=t.parentElement;a&&a.offsetWidth<t.offsetWidth&&e(t);break;default:t.querySelectorAll("a").forEach(l=>{!t.classList.contains("fullwidth")&&l.getClientRects().length>1&&e(t)})}});
1
+ document.querySelectorAll("pre,table,#TOC,#TableOfContents").forEach(t=>{function e(t){t.classList.add("fullwidth"),t.dataset.autoFullwidth=""}if(!t.closest(".fullwidth,.tabset"))switch(t.tagName){case"PRE":const l=t.firstElementChild;"CODE"===l?.tagName&&l.scrollWidth>l.offsetWidth&&e(l.parentNode);break;case"TABLE":const a=t.parentElement;a&&a.offsetWidth<t.offsetWidth&&e(t);break;default:t.querySelectorAll("a").forEach(l=>{!t.classList.contains("fullwidth")&&l.getClientRects().length>1&&e(t)})}}),addEventListener("pagesjs:before",()=>{document.querySelectorAll("[data-auto-fullwidth]").forEach(t=>{t.classList.remove("fullwidth"),delete t.dataset.autoFullwidth})});
2
2
  //# sourceMappingURL=fullwidth.min.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["document","querySelectorAll","forEach","node","fullwidth","el","classList","add","dataset","autoFullwidth","closest","tagName","firstElementChild","scrollWidth","offsetWidth","parentNode","p","parentElement","a","contains","getClientRects","length"],"sources":["fullwidth.js"],"mappings":"AACAA,SAASC,iBAAiB,8BAA8BC,QAAQC,IAC9D,SAASC,EAAUC,GACjBA,EAAGC,UAAUC,IAAI,aACjBF,EAAGG,QAAQC,cAAgB,EAC7B,CAEA,IAAIN,EAAKO,QAAQ,sBACjB,OAAQP,EAAKQ,SACX,IAAK,MACH,MAAMN,EAAKF,EAAKS,kBACA,SAAhBP,GAAIM,SAAsBN,EAAGQ,YAAcR,EAAGS,aAAeV,EAAUC,EAAGU,YAC1E,MACF,IAAK,QACH,MAAMC,EAAIb,EAAKc,cACfD,GAAKA,EAAEF,YAAcX,EAAKW,aAAeV,EAAUD,GACnD,MACF,QAEEA,EAAKF,iBAAiB,KAAKC,QAAQgB,KAEhCf,EAAKG,UAAUa,SAAS,cAAgBD,EAAEE,iBAAiBC,OAAS,GAAKjB,EAAUD","ignoreList":[]}
1
+ {"version":3,"names":["document","querySelectorAll","forEach","node","fullwidth","el","classList","add","dataset","autoFullwidth","closest","tagName","firstElementChild","scrollWidth","offsetWidth","parentNode","p","parentElement","a","contains","getClientRects","length","addEventListener","remove"],"sources":["fullwidth.js"],"mappings":"AACAA,SAASC,iBAAiB,mCAAmCC,QAAQC,IACnE,SAASC,EAAUC,GACjBA,EAAGC,UAAUC,IAAI,aACjBF,EAAGG,QAAQC,cAAgB,EAC7B,CAEA,IAAIN,EAAKO,QAAQ,sBACjB,OAAQP,EAAKQ,SACX,IAAK,MACH,MAAMN,EAAKF,EAAKS,kBACA,SAAhBP,GAAIM,SAAsBN,EAAGQ,YAAcR,EAAGS,aAAeV,EAAUC,EAAGU,YAC1E,MACF,IAAK,QACH,MAAMC,EAAIb,EAAKc,cACfD,GAAKA,EAAEF,YAAcX,EAAKW,aAAeV,EAAUD,GACnD,MACF,QAEEA,EAAKF,iBAAiB,KAAKC,QAAQgB,KAEhCf,EAAKG,UAAUa,SAAS,cAAgBD,EAAEE,iBAAiBC,OAAS,GAAKjB,EAAUD,QAM5FmB,iBAAiB,iBAAkB,KACjCtB,SAASC,iBAAiB,yBAAyBC,QAAQG,IACzDA,EAAGC,UAAUiB,OAAO,oBACblB,EAAGG,QAAQC","ignoreList":[]}
package/js/pages.js CHANGED
@@ -23,13 +23,30 @@
23
23
  function $(s, el = d) { return el?.querySelector(s); }
24
24
  function $$(s, el = d) { return el ? el.querySelectorAll(s) : []; }
25
25
  function nChild(el) { return el.childElementCount; }
26
+ function kids(el) { return [...el.children]; }
27
+ function firstEl(el) { return el.firstElementChild; }
28
+ function lastEl(el) { return el.lastElementChild; }
29
+ function rect(el) { return el.getBoundingClientRect(); }
30
+ function style(el) { return getComputedStyle(el); }
31
+ function num(v) { return parseFloat(v) || 0; }
32
+ function has(el, c) { return el.classList.contains(c); }
33
+ function addCls(el, ...c) { el.classList.add(...c); }
34
+ function rmCls(el, ...c) { el.classList.remove(...c); }
35
+ function make(tag, cls) {
36
+ const el = d.createElement(tag);
37
+ if (cls) el.className = cls;
38
+ return el;
39
+ }
40
+ function range() { return d.createRange(); }
41
+ function on(type, fn) { addEventListener(type, fn); }
42
+ function fire(type) { dispatchEvent(new Event(type)); }
26
43
 
27
44
  // --- Constants and state -------------------------------------------
28
45
 
29
46
  const
30
47
  book = $$('h1').length > 1, // a document with multiple <h1> is a book (chapters)
31
48
  // elements that are never broken across pages (CSS break-inside: avoid also works)
32
- atomic = 'h1,h2,h3,h4,h5,h6,hr,img,svg,video,canvas,iframe,object,embed,math,mjx-container,figure,.figure,details',
49
+ atomic = 'h1,h2,h3,h4,h5,h6,hr,img,svg,video,canvas,iframe,object,embed,math,mjx-container,figure,.figure,.caption,details',
33
50
  // classes of the pieces of a broken element
34
51
  fr_cls = 'pagesjs-fragmented', fr_1 = 'fragment-first', fr_2 = 'fragment-last',
35
52
  // pixels that the content may hang over the bottom of a page (the page has a
@@ -37,14 +54,15 @@
37
54
  tol = 3,
38
55
  // top/bottom page margin
39
56
  tb = ['top', 'bottom'].map(i =>
40
- parseFloat(getComputedStyle(d.documentElement).getPropertyValue(`--paper-margin-${i}`)) || 0
57
+ num(style(d.documentElement).getPropertyValue(`--paper-margin-${i}`))
41
58
  ),
42
59
  // the template of a page
43
- tpl = d.createElement('div'),
60
+ tpl = make('div', 'pagesjs-page'),
44
61
  boxes = [], // all pages
45
62
  wrapped = new WeakSet(), // elements whose runs of inline nodes have been wrapped
46
- hold = d.createElement('div'); // a hidden container for elements that need styles
47
- tpl.className = 'pagesjs-page';
63
+ guessed = new WeakSet(), // pages whose number of physical pages is an estimate (see calcPages())
64
+ notes = new Map(), // the items of each note (footnote or citation), by its marker (see detachNotes())
65
+ hold = make('div'); // a hidden container for elements that need styles
48
66
  tpl.innerHTML = `<div class="pagesjs-header"></div>
49
67
  <div class="pagesjs-body"></div>
50
68
  <div class="pagesjs-footer"></div>`;
@@ -55,7 +73,7 @@
55
73
  box_ctx, // where the content goes in the body (see ctx())
56
74
  wrap = [], // the ancestors of the content root (outermost first)
57
75
  H, B, // the height of a page and of its body
58
- H_min, // the height of a single-line paragraph
76
+ H_min, H_line, // the height of a single-line paragraph (with margins) and of a line
59
77
  main_title, // the title of the document
60
78
  probed, // the content that is on the probe page (see probe())
61
79
  pending, // the rest of the pagination, which is waiting for the probe
@@ -77,32 +95,58 @@
77
95
  // descendants, until one with padding/border at the bottom.
78
96
  function trailingMargin(body = box_body) {
79
97
  let m = 0;
80
- for (let e = body.lastElementChild; e; e = e.lastElementChild) {
81
- const cs = getComputedStyle(e);
82
- m = Math.max(m, parseFloat(cs.marginBottom) || 0);
83
- if (parseFloat(cs.paddingBottom) || parseFloat(cs.borderBottomWidth)) break;
98
+ for (let e = lastEl(body); e; e = lastEl(e)) {
99
+ const cs = style(e);
100
+ m = Math.max(m, num(cs.marginBottom));
101
+ if (num(cs.paddingBottom) || num(cs.borderBottomWidth)) break;
84
102
  }
85
103
  return m;
86
104
  }
87
105
  // the height of the page without the margin at the end of its content
88
- function pageHeight() { return box.getBoundingClientRect().height - trailingMargin(); }
106
+ function pageHeight() { syncNotes(); return rect(box).height - trailingMargin(); }
89
107
  // does the page overflow?
90
- function overflows() { return box.scrollHeight - trailingMargin() > H; }
108
+ function overflows() { syncNotes(); return box.scrollHeight - trailingMargin() > H; }
109
+ // The notes are not measured inline (where they are floats next to their references),
110
+ // but in a block after the page body, as in the end: put the notes of the references
111
+ // that are on the page there (and take the others off).
112
+ function syncNotes(b = box) {
113
+ const body = b.children[1], ms = [...$$('.pagesjs-note', body)], items = ms.flatMap(m => notes.get(m));
114
+ let c = $(':scope > .footnotes', b);
115
+ if (!items.length) return c?.remove();
116
+ c || body.after(c = make('div'));
117
+ c.className = 'footnotes';
118
+ if (items.some((e, i) => c.children[i] !== e) || nChild(c) !== items.length) c.replaceChildren(...items);
119
+ }
91
120
  // start the next page and finish current page
92
121
  function nextPage(el, callback) {
93
122
  const cur = box; cur.after(newPage(el)); callback && callback(); finish(cur);
94
123
  }
95
124
  // compute page numbers and temporarily remove the box
96
125
  function finish(box) {
126
+ syncNotes(box);
97
127
  const h = box.scrollHeight;
98
128
  // tolerate a few pixels (and the margin of the last element) hanging over the page bottom
99
129
  if (h - trailingMargin(box.children[1]) > H && !box.dataset.pagesOffset) {
100
130
  const n = calcPages(box, h);
101
- if (n > 1) box.dataset.pagesOffset = n;
131
+ if (n > 1) box.dataset.pagesOffset = n, guessed.add(box);
102
132
  }
103
133
  box.remove();
104
134
  progress && (progress.textContent = `Paginating: ${++n_done} pages done`);
105
135
  }
136
+ // The height of a page in fill mode is its natural height, which includes spaces that
137
+ // are not needed in the end (e.g., the margins of the last element), so a page that is a
138
+ // few pixels too tall may be fine with its fixed height. Check the pages in the end:
139
+ // if the content doesn't reach the notes/footer after the body and nothing hangs over
140
+ // the paper, the estimated number of pages is wrong.
141
+ function checkOffsets() {
142
+ boxes.forEach(box => {
143
+ if (!guessed.has(box)) return;
144
+ const body = box.children[1], r = range();
145
+ r.selectNodeContents(body);
146
+ if (rect(r).bottom <= rect(body.nextElementSibling).top &&
147
+ box.scrollHeight <= box.clientHeight + 1) delete box.dataset.pagesOffset;
148
+ });
149
+ }
106
150
  // calculate how many new pages we need for overflowed content (this is just
107
151
  // an estimate; if not accurate, use <div class="pagesjs-page" data-pages-offset="N">
108
152
  // to provide a number manually)
@@ -135,7 +179,7 @@
135
179
  if (!wrap.length) return box_body;
136
180
  if (!box_ctx || !box_body.contains(box_ctx)) {
137
181
  box_ctx = wrap.reduce((p, el) => {
138
- const c = el.cloneNode(); c.classList.add('pagesjs-wrap');
182
+ const c = el.cloneNode(); addCls(c, 'pagesjs-wrap');
139
183
  return p.appendChild(c);
140
184
  }, box_body);
141
185
  }
@@ -153,17 +197,17 @@
153
197
 
154
198
  function* fill(el, more = true) {
155
199
  // if the element is already a page, just use it as the box
156
- if (el.classList.contains('pagesjs-page')) {
200
+ if (has(el, 'pagesjs-page')) {
157
201
  nextPage(el, () => nChild(el) > 3 && (
158
202
  // if current element is not empty, fill its content into the box
159
- box_body.append(...[...el.children].slice(3)),
203
+ box_body.append(...kids(el).slice(3)),
160
204
  // TODO: should we fragment this page if it's too long?
161
205
  nextPage() // create a new empty page
162
206
  ));
163
207
  } else {
164
208
  // in a book, a chapter (a container of <h1>) starts on a new page
165
209
  if (book && box.innerText !== '' && $('h1', el)) nextPage();
166
- if (el.innerText.trim() && H - box.scrollHeight < H_min) nextPage();
210
+ if (el.innerText.trim() && (syncNotes(), H - box.scrollHeight < H_min)) nextPage();
167
211
  yield* place(el, more);
168
212
  }
169
213
  }
@@ -196,14 +240,16 @@
196
240
  function split(el, container, kind, more) {
197
241
  // (for a block, prev is determined after it is cut, to avoid laying it out)
198
242
  const k = kind || kindOf(el), prev = k === 'block' ? undefined : hasPrev(el),
199
- first = !el.classList.contains(fr_cls), r = k && splitters[k](el, container, prev, first, more);
243
+ first = !has(el, fr_cls), r = k && splitters[k](el, container, prev, first, more);
200
244
  if (!r) return prev && (el.remove(), el);
201
245
  const [head, rest] = r;
202
246
  if (blank(head)) return head.remove(), rest; // nothing fits
203
247
  if (rest) {
204
- rest.classList.add(fr_cls); rest.classList.remove(fr_1, fr_2);
248
+ addCls(rest, fr_cls); rmCls(rest, fr_1, fr_2);
249
+ } else if (has(head, fr_1)) {
250
+ rmCls(head, fr_cls, fr_1, fr_2); // it's not really split
205
251
  } else {
206
- head.classList.add(fr_2); // the last piece (also the first if it's not really split)
252
+ addCls(head, fr_2); // the last piece
207
253
  }
208
254
  return rest;
209
255
  }
@@ -212,12 +258,12 @@
212
258
  function isBigBlock(el) {
213
259
  return !['TABLE', 'PRE'].includes(el.tagName) && el.getElementsByTagName('*').length > 300;
214
260
  }
215
- function blank(el) { return !el.firstElementChild && !el.textContent.trim(); }
261
+ function blank(el) { return !firstEl(el) && !el.textContent.trim(); }
216
262
  // is there anything above el on the page (which means el may go to the next page)?
217
263
  function hasPrev(el) {
218
264
  for (; el && el !== box_body; el = el.parentNode)
219
265
  for (let p = el.previousElementSibling; p; p = p.previousElementSibling)
220
- if (p.getBoundingClientRect().height) return true;
266
+ if (rect(p).height) return true;
221
267
  return false;
222
268
  }
223
269
  function inFlow(cs) {
@@ -226,19 +272,19 @@
226
272
  // text, inline elements, and out-of-flow elements go with the text around them
227
273
  function isInline(n) {
228
274
  if (n.nodeType !== 1) return true;
229
- const cs = getComputedStyle(n), v = cs.display;
275
+ const cs = style(n), v = cs.display;
230
276
  return v.startsWith('inline') || v === 'none' || v === 'contents' || !inFlow(cs);
231
277
  }
232
278
  // is an element a part of the text (inline, and not a float, etc.)?
233
279
  function inTextFlow(el) {
234
- const cs = getComputedStyle(el);
280
+ const cs = style(el);
235
281
  return (cs.display.startsWith('inline') || cs.display === 'contents') && inFlow(cs);
236
282
  }
237
283
  // lines of <pre><code>; tags open at the end of a line (e.g., a multi-line
238
284
  // comment) are closed there and reopened on the next line, so each line is balanced
239
285
  function codeLines(pre) {
240
286
  const open = [];
241
- return pre.firstElementChild.innerHTML.replace(/\n$/, '').split('\n').map(line => {
287
+ return firstEl(pre).innerHTML.replace(/\n$/, '').split('\n').map(line => {
242
288
  const start = open.map(t => t[0]).join('');
243
289
  line.replace(/<(\/?)([a-z][\w-]*)[^>]*>/gi, (m, c, t) => {
244
290
  c ? open.pop() : open.push([m, t]);
@@ -249,26 +295,26 @@
249
295
  // how can the element be broken: by 'block' (its child blocks), 'inline' (text
250
296
  // lines), 'table' (rows), 'code' (lines), or not at all (undefined)?
251
297
  function kindOf(el) {
252
- const cs = getComputedStyle(el), t = el.tagName;
298
+ const cs = style(el), t = el.tagName;
253
299
  if (/avoid/.test(cs.breakInside) || el.matches(atomic)) return;
254
300
  if (t === 'TABLE') return el.tBodies[0] && 'table';
255
301
  if (!['block', 'list-item', 'flow-root'].includes(cs.display) || !inFlow(cs)) return;
256
302
  if (t === 'PRE') {
257
- if (el.firstElementChild?.tagName === 'CODE' && codeLines(el).length > 1) return 'code';
303
+ if (firstEl(el)?.tagName === 'CODE' && codeLines(el).length > 1) return 'code';
258
304
  // wrapped long lines: move to the next page if it fits there, otherwise break by lines
259
305
  if (el.offsetHeight <= B) return;
260
306
  }
261
- return [...el.children].some(c => !isInline(c)) ? 'block' : 'inline';
307
+ return kids(el).some(c => !isInline(c)) ? 'block' : 'inline';
262
308
  }
263
309
  function mark(el, first) {
264
- el.classList.add(fr_cls); el.classList.remove(fr_2); first && el.classList.add(fr_1);
310
+ addCls(el, fr_cls); rmCls(el, fr_2); first && addCls(el, fr_1);
265
311
  }
266
312
  // pieces of a fragmented element that are put on a page as a whole are the last
267
313
  // pieces; mark them (and their fragmented descendants) before measuring, since
268
314
  // the size of the last piece is different (see pages.css); if it turns out to be
269
315
  // too big and is split, the mark is removed
270
316
  function endFrag(el) {
271
- if (el.nodeType === 1) [el, ...$$('.' + fr_cls, el)].forEach(e => e.classList.contains(fr_cls) && e.classList.add(fr_2));
317
+ if (el.nodeType === 1) [el, ...$$('.' + fr_cls, el)].forEach(e => has(e, fr_cls) && addCls(e, fr_2));
272
318
  }
273
319
  // shallow clone el (wrapper only) as the first piece of el in container
274
320
  function cut(el, container, first) {
@@ -279,15 +325,16 @@
279
325
  // wrap each run of inline nodes in a block (like an anonymous block box in CSS)
280
326
  // so mixed content (e.g., <li>text<ul>...</ul></li>) can be broken as paragraphs
281
327
  function wrapRuns(el) {
282
- if (wrapped.has(el)) return;
328
+ // (a run is made of inline nodes already; wrapping it again would nest runs endlessly)
329
+ if (wrapped.has(el) || has(el, 'pagesjs-run')) return;
283
330
  wrapped.add(el);
284
331
  // computed styles are available only in the DOM (but not necessarily on a page)
285
332
  el.isConnected || hold.append(el);
286
333
  let run = [];
287
334
  function flush() {
288
335
  if (run.some(n => n.nodeType === 1 || n.nodeType === 3 && n.nodeValue.trim())) {
289
- const s = d.createElement('span');
290
- s.className = 'pagesjs-run'; run[0].before(s); s.append(...run);
336
+ const s = make('span', 'pagesjs-run');
337
+ run[0].before(s); s.append(...run);
291
338
  }
292
339
  run = [];
293
340
  }
@@ -315,7 +362,7 @@
315
362
  head.append(item);
316
363
  if (!overflows()) continue;
317
364
  }
318
- const n = nChild(head), rest = split(item, head, big ? 'block' : undefined, more || !!el.firstElementChild);
365
+ const n = nChild(head), rest = split(item, head, big ? 'block' : undefined, more || !!firstEl(el));
319
366
  if (rest) { partial = nChild(head) > n; el.prepend(rest); break; }
320
367
  }
321
368
  blank(el) && fitLastPiece(head, el, prev); // (may push children to el)
@@ -325,37 +372,53 @@
325
372
  return [head, blank(el) ? null : el];
326
373
  }
327
374
 
328
- // a legend (which is too tall for moveShortHead() when it's in a framed block)
329
- // should not be the last child of a piece that is continued, so move it (and
330
- // those before it) to the rest (el)
375
+ // a legend or a caption (which is too tall for moveShortHead() when it's in a framed
376
+ // block or above a table) should not be the last child of a piece that is continued,
377
+ // so move it (and those before it) to the rest (el)
331
378
  function moveTrailingHeadings(head, el, prev) {
332
- for (let h; (h = head.lastElementChild)?.matches('legend') && (nChild(head) > 1 || prev);)
379
+ for (let h; (h = lastEl(head))?.matches('legend, .caption') && (nChild(head) > 1 || prev);)
333
380
  el.prepend(h);
334
381
  }
335
382
  // if only about one line (e.g., a legend or the first list item) is left on the
336
383
  // page, and no child was split, move it to the next page with the rest (el)
337
384
  function moveShortHead(head, el) {
338
- if (!blank(el) && head.getBoundingClientRect().height < 1.5 * H_min)
385
+ if (!blank(el) && rect(head).height < 1.5 * H_line) {
386
+ rejoin(lastEl(head), firstEl(el));
339
387
  el.prepend(...head.childNodes);
388
+ }
389
+ }
390
+ // put back the piece a (at the end of the head) into its rest b (at the start of el),
391
+ // so they are one element again
392
+ function rejoin(a, b) {
393
+ if (!a || !b || !has(a, fr_cls) || !has(b, fr_cls) || a.tagName !== b.tagName) return;
394
+ rejoin(lastEl(a), firstEl(b));
395
+ b.prepend(...a.childNodes);
396
+ // (b is not marked as the last piece yet; if a was the first piece, they are the original element)
397
+ rmCls(b, ...has(a, fr_1) ? [fr_cls, fr_1, fr_2] : [fr_1]);
398
+ a.remove();
340
399
  }
341
400
  // If all children fit, head is the last piece, which has bottom margin/padding/
342
- // border that were hidden when it was measured as a non-last piece; push the
343
- // last children out (into el) if it is too big now.
401
+ // border that were hidden when it was measured as a non-last piece; if it is too
402
+ // big now, break the last child (or push it out entirely if it can't be broken).
344
403
  function fitLastPiece(head, el, prev) {
345
- head.classList.add(fr_2);
346
- while (overflows() && head.lastElementChild && (nChild(head) > 1 || prev))
347
- el.prepend(head.lastElementChild);
348
- blank(el) || head.classList.remove(fr_2);
404
+ addCls(head, fr_2);
405
+ while (overflows() && lastEl(head) && (nChild(head) > 1 || prev)) {
406
+ const last = lastEl(head), rest = split(last, head, undefined, true);
407
+ if (!rest) break;
408
+ el.prepend(rest);
409
+ if (rest !== last) break; // (a piece of the child is still on the page)
410
+ }
411
+ blank(el) || rmCls(head, fr_2);
349
412
  }
350
413
  // update the start number of the rest of <ol> (an item split in half counts once)
351
414
  function fixOlStart(head, el) {
352
- el.start += nChild(head) - (el.firstElementChild.classList.contains(fr_cls) ? 1 : 0);
415
+ el.start += nChild(head) - (has(firstEl(el), fr_cls) ? 1 : 0);
353
416
  }
354
417
  // split <p> by testing if a range fits the current box
355
418
  function splitInline(el, container, prev, first, more) {
356
419
  const ends = lineStarts(el);
357
420
  if (ends.length < 2) return; // single-line paragraph
358
- const r = d.createRange(), rest = el.cloneNode(), n = ends.length;
421
+ const r = range(), rest = el.cloneNode(), n = ends.length;
359
422
  let k = n; // number of lines left in el
360
423
  function cutLine() {
361
424
  const loc = ends[--k];
@@ -380,7 +443,7 @@
380
443
 
381
444
  // find the break position of each line (exclude block elements like footnotes)
382
445
  function lineStarts(el) {
383
- const r = d.createRange(), ends = [{node: el, i: 0}];
446
+ const r = range(), ends = [{node: el, i: 0}];
384
447
  const walker = d.createTreeWalker(el, NodeFilter.SHOW_TEXT | NodeFilter.SHOW_ELEMENT);
385
448
  let node, prev;
386
449
  // if the previous rect is at top-right of current rect, assume a line ends
@@ -398,9 +461,9 @@
398
461
  if (node.firstChild) continue; // for element nodes, traverse to bottom
399
462
  }
400
463
  if (node.tagName) {
401
- const rect = node.getBoundingClientRect();
402
- newLine(rect) && ends.push({node, i: -1});
403
- prev = rect;
464
+ const rc = rect(node);
465
+ newLine(rc) && ends.push({node, i: -1});
466
+ prev = rc;
404
467
  } else if (node.textContent.trim()) {
405
468
  // a text node has one rect per line, and a new line starts at the first
406
469
  // character that makes the range of the text have one more rect
@@ -428,42 +491,45 @@
428
491
  function splitTable(el, container, prev, first) {
429
492
  const head = cut(el, container, first), tb = el.tBodies[0], tb2 = tb.cloneNode(),
430
493
  rows = [...tb.rows], n = rows.length, min = prev ? 0 : 1;
431
- head.append(tb2);
432
- // copy table header and footer
433
- [el.tHead, el.tFoot].forEach(t => t && head.append(t.cloneNode(true)));
494
+ // the caption (which is not broken) goes with the first rows, unless it is below the table
495
+ const cap = el.caption && style(el.caption).captionSide !== 'bottom' ? el.caption : null;
496
+ function clear() { cap && el.prepend(cap); head.innerHTML = ''; }
497
+ cap && head.append(cap);
498
+ // copy table header and footer (the header goes first, as in the original)
499
+ [el.tHead, tb2, el.tFoot].forEach(t => t && head.append(t === tb2 ? t : t.cloneNode(true)));
434
500
  // Put all rows in the page and lay them out once. The rows whose bottoms are
435
501
  // below (the bottom of the last row - the overflow) do not fit; put them back.
436
502
  tb2.append(...rows);
437
503
  const over = pageHeight() - H - .5; // (see fitLines())
438
504
  if (over >= 0) {
439
- const limit = rows[n - 1].getBoundingClientRect().bottom - over;
505
+ const limit = rect(rows[n - 1]).bottom - over;
440
506
  let lo = 0, hi = n; // the first row that is below the limit (by bisection)
441
507
  while (lo < hi) {
442
508
  const mid = (lo + hi) >> 1;
443
- rows[mid].getBoundingClientRect().bottom <= limit ? lo = mid + 1 : hi = mid;
509
+ rect(rows[mid]).bottom <= limit ? lo = mid + 1 : hi = mid;
444
510
  }
445
511
  let k = Math.max(lo, min);
446
512
  tb.prepend(...rows.slice(k));
447
513
  while (k > min && pageHeight() > H + .5) tb.prepend(rows[--k]); // make sure they fit
448
514
  }
449
515
  // clear the clone if current page can't fit even one row
450
- tb2.rows.length || (head.innerHTML = '');
516
+ tb2.rows.length || clear();
451
517
  // avoid a single row on either page
452
518
  const m = tb2.rows.length;
453
519
  if (tb.rows.length === 1 && m > 1 || m === 1 && prev && tb.rows.length) {
454
520
  tb.prepend(tb2.rows[m - 1]);
455
- if (m === 1) head.innerHTML = '';
521
+ if (m === 1) clear();
456
522
  }
457
523
  return [head, tb.rows.length ? el : null];
458
524
  }
459
525
  // split lines in <code> and move as many lines into the clone as possible
460
526
  function splitCode(el, container, prev, first) {
461
- const code = el.firstElementChild, lines = codeLines(el);
527
+ const code = firstEl(el), lines = codeLines(el);
462
528
  // other children go to the first piece, except those after <code> in the normal
463
529
  // flow (e.g., a link to the output), which go to the last piece
464
- const kids = [...el.children], tail = kids.filter((c, j) => j > kids.indexOf(code) && inFlow(getComputedStyle(c)));
530
+ const ch = kids(el), tail = ch.filter((c, j) => j > ch.indexOf(code) && inFlow(style(c)));
465
531
  const head = cut(el, container, first), code2 = code.cloneNode();
466
- head.append(code2, ...kids.filter(c => c !== code && !tail.includes(c)));
532
+ head.append(code2, ...ch.filter(c => c !== code && !tail.includes(c)));
467
533
  let i = fitLines(code2, lines, prev);
468
534
  // avoid a single line on either page
469
535
  if (i > 1 && lines.length - i === 1) i--;
@@ -486,12 +552,12 @@
486
552
  // (the page fits if its height is rounded to H or less, i.e., it is < H + .5)
487
553
  const over = pageHeight() - H - .5;
488
554
  if (over < 0) return n;
489
- const r = d.createRange(), bottoms = []; // the bottom of each line
555
+ const r = range(), bottoms = []; // the bottom of each line
490
556
  code.childNodes.forEach(node => {
491
557
  if (node.nodeType !== 3) return;
492
558
  for (let i = node.data.indexOf('\n'); i >= 0; i = node.data.indexOf('\n', i + 1)) {
493
559
  r.setStart(node, i); r.setEnd(node, i + 1);
494
- bottoms.push(r.getBoundingClientRect().bottom);
560
+ bottoms.push(rect(r).bottom);
495
561
  }
496
562
  });
497
563
  // the bottom of the last line (which has no line break), and the space after it
@@ -518,7 +584,7 @@
518
584
  // a ResizeObserver) settle at the page width before measuring anything: put all
519
585
  // content on a probe page and wait for a few frames.
520
586
  function probe(roots, els) {
521
- box.classList.add('pagesjs-settle');
587
+ addCls(box, 'pagesjs-settle');
522
588
  roots.forEach((el, i) => {
523
589
  wrap = ancestors(el); box_ctx = null; ctx().append(...els[i]);
524
590
  });
@@ -535,7 +601,7 @@
535
601
  if (!probed) return;
536
602
  probed.forEach(ch => ch.forEach(el => el.remove()));
537
603
  box_body.innerHTML = ''; box_ctx = null; wrap = [];
538
- box.classList.remove('pagesjs-settle');
604
+ rmCls(box, 'pagesjs-settle');
539
605
  probed = null;
540
606
  }
541
607
 
@@ -555,22 +621,17 @@
555
621
  $(ps, box) && (page_title = ''); // empty title for first page of chapter
556
622
  }
557
623
  const N = +box.dataset.pagesOffset || 1;
558
- if (N > 1) box.classList.add('page-multiple');
624
+ if (N > 1) addCls(box, 'page-multiple');
559
625
  i += N;
560
- box.classList.add(`page-${i % 2 === 0 ? 'even' : 'odd'}`);
626
+ addCls(box, `page-${i % 2 === 0 ? 'even' : 'odd'}`);
561
627
  const info = {
562
628
  'pageNumber': i, 'mainTitle': main_title, 'pageTitle': page_title
563
629
  };
564
- [box.children[0], box.children[2]].forEach(el => {
630
+ [box.children[0], lastEl(box)].forEach(el => {
565
631
  for (const key in info) info[key] && (el.dataset[key] = info[key]);
566
632
  });
567
633
  // find page title for next page
568
634
  page_title = shortTitle([...$$(ps, box)].pop()) || page_title;
569
- let ft; // first footnote on page
570
- // move all footnotes after the page body
571
- $$('.footnotes', box).forEach((el, i) => {
572
- i === 0 ? (ft = el, box.children[1].after(el)) : (ft.append(...el.children), el.remove());
573
- });
574
635
  });
575
636
  }
576
637
 
@@ -585,6 +646,10 @@ i === 0 ? (ft = el, box.children[1].after(el)) : (ft.append(...el.children), el.
585
646
 
586
647
  // --- Pagination ----------------------------------------------------
587
648
 
649
+ function ownText(el) {
650
+ return [...el.childNodes].some(n => n.nodeType === 3 && n.nodeValue.trim());
651
+ }
652
+ function canBeRoot(el) { return !['PRE', 'TABLE'].includes(el.tagName) && !ownText(el); }
588
653
  // The content root is specified via <body data-pages-root="selector">, or is
589
654
  // <main> (or an element with role="main"), or the top-level <article> elements,
590
655
  // or <body>. If <main> only has a child (e.g., <article>), the child is the root
@@ -594,7 +659,9 @@ i === 0 ? (ft = el, box.children[1].after(el)) : (ft.append(...el.children), el.
594
659
  if (x.length) return x;
595
660
  let main = $('main, [role="main"]');
596
661
  // if it only contains a wrapper (e.g., an <article>), use the wrapper instead
597
- while (main?.childElementCount === 1) main = main.firstElementChild;
662
+ // (but not an element that is broken by its own, or has text, which would be lost)
663
+ while (main && nChild(main) === 1 && !ownText(main) && canBeRoot(firstEl(main)))
664
+ main = firstEl(main);
598
665
  if (main) return [main];
599
666
  const articles = [...$$('article')].filter(el => !el.parentNode.closest('article'));
600
667
  return articles.length ? articles : [d.body];
@@ -603,29 +670,40 @@ i === 0 ? (ft = el, box.children[1].after(el)) : (ft.append(...el.children), el.
603
670
  // <body>) by default, or specified via <body data-pages-front="selector">; it is
604
671
  // put on its own page in a book.
605
672
  function markFrontmatter() {
606
- $$(d.body.dataset.pagesFront || 'body > header').forEach(el => el.classList.add('pagesjs-front'));
673
+ $$(d.body.dataset.pagesFront || 'body > header').forEach(el => addCls(el, 'pagesjs-front'));
607
674
  }
608
675
  // remove the classes of the TOC, footnotes, etc. that put them in the margin on
609
676
  // screen but are not suitable for printing
610
677
  function removeSideClasses() {
611
678
  $$(':is(#TOC, .footnotes, .chapter-before, .chapter-after):is(.side-left, .side-right).side').forEach(el => {
612
- el.classList.remove('side', 'side-left', 'side-right');
679
+ rmCls(el, 'side', 'side-left', 'side-right');
680
+ });
681
+ }
682
+ // Replace the notes (footnotes and citations that sidenotes.js has put after their
683
+ // references) with markers, which go with the references when the text is broken.
684
+ function detachNotes() {
685
+ $$('.footnotes').forEach(el => {
686
+ const p = el.previousElementSibling;
687
+ if (!p || !has(p, 'note-ref')) return;
688
+ const m = make('span', 'pagesjs-note');
689
+ m.hidden = true;
690
+ notes.set(m, kids(el)); el.replaceWith(m);
613
691
  });
614
692
  }
615
693
  // test how much space a single-line paragraph needs
616
694
  function measureMinHeight() {
617
- const p = d.createElement('p'), H0 = box.scrollHeight;
695
+ const p = make('p'), H0 = box.scrollHeight;
618
696
  p.innerText = 'A'; box_body.append(p);
619
- H_min = box.scrollHeight - H0; p.remove();
697
+ H_min = box.scrollHeight - H0; H_line = rect(p).height; p.remove();
620
698
  }
621
699
  // add dot leaders to TOC (page numbers will be added after the pages are ready)
622
700
  function addTocLeaders() {
623
701
  $$('#TOC a[href^="#"]').forEach(a => {
624
- const s = d.createElement('span'); // move TOC item content into a span
625
- s.className = 'toc-text'; a.append(s);
702
+ const s = make('span', 'toc-text'); // move TOC item content into a span
703
+ a.append(s);
626
704
  let c; while (c = s.previousSibling) {
627
705
  // exclude section number spans
628
- if (c.classList?.contains('section-number')) break; s.prepend(c);
706
+ if (c.nodeType === 1 && has(c, 'section-number')) break; s.prepend(c);
629
707
  }
630
708
  a.dataset.pageNumber = '000'; // placeholder for page numbers
631
709
  });
@@ -637,7 +715,7 @@ i === 0 ? (ft = el, box.children[1].after(el)) : (ft.append(...el.children), el.
637
715
  // move <style>/<link> into <head> so styles can be applied globally (not
638
716
  // only when they are in the DOM), no matter how deeply they are nested
639
717
  $$('style, link[rel="stylesheet"]', el).forEach(el => d.head.append(el));
640
- const ch = [...el.children].filter(el => ![box, hold, progress].includes(el) &&
718
+ const ch = kids(el).filter(el => ![box, hold, progress].includes(el) &&
641
719
  !['SCRIPT', 'NOSCRIPT', 'TEMPLATE'].includes(el.tagName));
642
720
  ch.forEach(el => el.remove());
643
721
  return ch;
@@ -674,11 +752,12 @@ i === 0 ? (ft = el, box.children[1].after(el)) : (ft.append(...el.children), el.
674
752
  // nobody sees the progress in a headless browser (and printing has to be sync)
675
753
  const quiet = sync || /Headless/.test(navigator.userAgent) || navigator.webdriver;
676
754
  // we need to wait for all resources to be fully loaded before paginating
677
- if (d.readyState !== 'complete') return addEventListener('load', () => paginate(sync));
755
+ if (d.readyState !== 'complete') return on('load', () => paginate(sync));
678
756
 
679
757
  const cls = d.body.classList;
680
758
  if (cls.contains('pagesjs')) return; // already paginated
681
- dispatchEvent(new Event('pagesjs:before'));
759
+ fire('pagesjs:before');
760
+ const t0 = performance.now();
682
761
 
683
762
  markFrontmatter();
684
763
  // (get the title while the document is visible, so innerText works)
@@ -687,8 +766,7 @@ i === 0 ? (ft = el, box.children[1].after(el)) : (ft.append(...el.children), el.
687
766
  cls.add('pagesjs');
688
767
  d.body.append(hold);
689
768
  if (!quiet) { // a simple indicator to tell users to wait
690
- progress = d.createElement('div');
691
- progress.className = 'pagesjs-progress';
769
+ progress = make('div', 'pagesjs-progress');
692
770
  progress.textContent = 'Paginating...';
693
771
  d.body.append(progress);
694
772
  }
@@ -699,16 +777,21 @@ i === 0 ? (ft = el, box.children[1].after(el)) : (ft.append(...el.children), el.
699
777
  measureMinHeight();
700
778
  addTocLeaders();
701
779
 
780
+ detachNotes();
702
781
  const roots = findRoots(), els = detachContent(roots);
703
782
  function* run() {
704
783
  yield* fillPages(roots, els);
705
784
  cls.remove('pagesjs-filling');
706
- numberPages();
707
785
  d.body.prepend(...boxes); // unhide all pages
786
+ checkOffsets();
787
+ numberPages();
708
788
  numberToc();
709
789
  hold.remove(); progress?.remove();
710
790
  finished = true;
711
- dispatchEvent(new Event('pagesjs:after'));
791
+ const over = boxes.filter(b => b.classList.contains('page-multiple')).length;
792
+ console.info(`pages.js: ${boxes.length} pages in ${Math.round(performance.now() - t0)} ms` +
793
+ (over ? `; ${over} overflow their page` : ''));
794
+ fire('pagesjs:after');
712
795
  }
713
796
  // Pagination is async unless it has to be sync (beforeprint). If printing
714
797
  // starts while it's pending (e.g., headless printing right after the page is
@@ -716,7 +799,7 @@ i === 0 ? (ft = el, box.children[1].after(el)) : (ft.append(...el.children), el.
716
799
  pending = sync => { pending = null; unprobe(); running = run(); return advance(sync || quiet); };
717
800
  sync ? pending(true) : probe(roots, els).then(() => pending?.());
718
801
  }
719
- addEventListener('beforeprint', () => {
802
+ on('beforeprint', () => {
720
803
  if (pending) pending(true);
721
804
  else if (running) while (!running.next().done); // finish the pagination in progress
722
805
  else paginate(true);
@@ -724,13 +807,13 @@ i === 0 ? (ft = el, box.children[1].after(el)) : (ft.append(...el.children), el.
724
807
  // A script that controls the browser can request the pagination by dispatching
725
808
  // pagesjs:paginate, and wait for pagesjs:after (which is also dispatched if the
726
809
  // pagination was already finished)
727
- addEventListener('pagesjs:paginate', () => {
728
- finished ? dispatchEvent(new Event('pagesjs:after')) : paginate();
810
+ on('pagesjs:paginate', () => {
811
+ finished ? fire('pagesjs:after') : paginate();
729
812
  });
730
813
  // use query param ?paged=1 to indicate pagination (press p to toggle)
731
814
  const SP = new URLSearchParams(location.search);
732
815
  SP.get('paged') && paginate();
733
- addEventListener('keypress', e => {
816
+ on('keypress', e => {
734
817
  if (e.key === 'p') {
735
818
  if (SP.get('paged')) {
736
819
  SP.delete('paged'); location.href = location.pathname + (SP.size ? `?${SP}` : '');
package/js/pages.min.js CHANGED
@@ -1,2 +1,2 @@
1
- (e=>{function t(t,n=e){return n?.querySelector(t)}function n(t,n=e){return n?n.querySelectorAll(t):[]}function o(e){return e.childElementCount}const i=n("h1").length>1,r="h1,h2,h3,h4,h5,h6,hr,img,svg,video,canvas,iframe,object,embed,math,mjx-container,figure,.figure,details",s="pagesjs-fragmented",a="fragment-first",l="fragment-last",c=["top","bottom"].map(t=>parseFloat(getComputedStyle(e.documentElement).getPropertyValue(`--paper-margin-${t}`))||0),d=e.createElement("div"),f=[],p=new WeakSet,u=e.createElement("div");d.className="pagesjs-page",d.innerHTML='<div class="pagesjs-header"></div>\n<div class="pagesjs-body"></div>\n<div class="pagesjs-footer"></div>',u.style.display="none";let g,h,m,E,v,b,C,T,L,y,N,j,H=[],S=0;function x(e){return e&&!t(".pagesjs-body",e)&&e.insertAdjacentHTML("afterbegin",d.innerHTML),g=e||d.cloneNode(!0),h=g.children[1],m=null,f.includes(g)||f.push(g),g}function M(e=h){let t=0;for(let n=e.lastElementChild;n;n=n.lastElementChild){const e=getComputedStyle(n);if(t=Math.max(t,parseFloat(e.marginBottom)||0),parseFloat(e.paddingBottom)||parseFloat(e.borderBottomWidth))break}return t}function w(){return g.getBoundingClientRect().height-M()}function R(){return g.scrollHeight-M()>E}function O(e,t){const n=g;n.after(x(e)),t&&t(),B(n)}function B(e){const t=e.scrollHeight;if(t-M(e.children[1])>E&&!e.dataset.pagesOffset){const o=function(e,t){let o=+e.dataset.pagesOffset;if(o)return o;if(o=Math.ceil(t/E),o<=1)return o;const i=c.concat([...n("thead",e)].map(e=>+e.offsetHeight)).reduce((e,t)=>e+t);if(!i)return o;function r(){return Math.ceil((t+(o-1)*i)/E)}let s=r();for(;s>o;)o=s,s=r();return o}(e,t);o>1&&(e.dataset.pagesOffset=o)}e.remove(),N&&(N.textContent=`Paginating: ${++S} pages done`)}function k(t){const n=[];for(;t&&t!==e.body;t=t.parentNode)n.unshift(t);return n}function A(){return H.length?(m&&h.contains(m)||(m=H.reduce((e,t)=>{const n=t.cloneNode();return n.classList.add("pagesjs-wrap"),e.appendChild(n)},h)),m):h}function P(e){if(!e||"BODY"===e.tagName)return!1;const t=!("P"===e.tagName?e.innerHTML:e.innerText).trim();return t&&e.remove(),t}function*F(e,n=!0){e.classList.contains("pagesjs-page")?O(e,()=>o(e)>3&&(h.append(...[...e.children].slice(3)),O())):(i&&""!==g.innerText&&t("h1",e)&&O(),e.innerText.trim()&&E-g.scrollHeight<b&&O(),yield*function*(e,t){for(;;){const n=A();if(J(e),$(e))e=W(e,n,"block",t);else{if(n.append(e),!R())return;e=W(e,n,void 0,t)}if(!e)return;O(),yield}}(e,n))}function W(e,t,n,o){const i=n||function(e){const t=getComputedStyle(e),n=e.tagName;if(/avoid/.test(t.breakInside)||e.matches(r))return;if("TABLE"===n)return e.tBodies[0]&&"table";if(!["block","list-item","flow-root"].includes(t.display)||!z(t))return;if("PRE"===n){if("CODE"===e.firstElementChild?.tagName&&X(e).length>1)return"code";if(e.offsetHeight<=v)return}return[...e.children].some(e=>!D(e))?"block":"inline"}(e),c="block"===i?void 0:I(e),d=!e.classList.contains(s),f=i&&Y[i](e,t,c,d,o);if(!f)return c&&(e.remove(),e);const[p,u]=f;return q(p)?(p.remove(),u):(u?(u.classList.add(s),u.classList.remove(a,l)):p.classList.add(l),u)}function $(e){return!["TABLE","PRE"].includes(e.tagName)&&e.getElementsByTagName("*").length>300}function q(e){return!e.firstElementChild&&!e.textContent.trim()}function I(e){for(;e&&e!==h;e=e.parentNode)for(let t=e.previousElementSibling;t;t=t.previousElementSibling)if(t.getBoundingClientRect().height)return!0;return!1}function z(e){return"none"===e.float&&!["absolute","fixed"].includes(e.position)}function D(e){if(1!==e.nodeType)return!0;const t=getComputedStyle(e),n=t.display;return n.startsWith("inline")||"none"===n||"contents"===n||!z(t)}function V(e){const t=getComputedStyle(e);return(t.display.startsWith("inline")||"contents"===t.display)&&z(t)}function X(e){const t=[];return e.firstElementChild.innerHTML.replace(/\n$/,"").split("\n").map(e=>{const n=t.map(e=>e[0]).join("");return e.replace(/<(\/?)([a-z][\w-]*)[^>]*>/gi,(e,n,o)=>{n?t.pop():t.push([e,o])}),n+e+t.map(e=>`</${e[1]}>`).reverse().join("")})}function _(e,t){e.classList.add(s),e.classList.remove(l),t&&e.classList.add(a)}function J(e){1===e.nodeType&&[e,...n("."+s,e)].forEach(e=>e.classList.contains(s)&&e.classList.add(l))}function U(e,t,n){const o=e.cloneNode();return e.remove(),t.append(o),_(o,n),o}const Y={block:function(t,n,i,r,s){!function(t){if(p.has(t))return;p.add(t),t.isConnected||u.append(t);let n=[];function o(){if(n.some(e=>1===e.nodeType||3===e.nodeType&&e.nodeValue.trim())){const t=e.createElement("span");t.className="pagesjs-run",n[0].before(t),t.append(...n)}n=[]}for(const e of[...t.childNodes])D(e)?n.push(e):o();o(),t.parentNode===u&&t.remove()}(t);const a=U(t,n,r);let l,c;i=I(a);for(;l=t.firstChild;){if(1!==l.nodeType){a.append(l);continue}J(l);const e=$(l);if(!e&&(a.append(l),!R()))continue;const n=o(a),i=W(l,a,e?"block":void 0,s||!!t.firstElementChild);if(i){c=o(a)>n,t.prepend(i);break}}return q(t)&&Q(a,t,i),q(t)||G(a,t,i),i&&!c&&K(a,t),"OL"===t.tagName&&o(a)&&!q(t)&&Z(a,t),[a,q(t)?null:t]},inline:function(n,o,i,r,s){const a=function(n){const o=e.createRange(),i=[{node:n,i:0}],r=e.createTreeWalker(n,NodeFilter.SHOW_TEXT|NodeFilter.SHOW_ELEMENT);let s,a;function l(e){return a&&a.bottom<=e.top&&a.right>e.left}for(;s=r.nextNode();){const e=s.tagName;if(e){if(("MJX-CONTAINER"===e||"SPAN"===e&&t(".katex",s)||!V(s))&&(s=r.nextSibling(),!s))break;if(s.firstChild)continue}if(s.tagName){const e=s.getBoundingClientRect();l(e)&&i.push({node:s,i:-1}),a=e}else if(s.textContent.trim()){o.selectNodeContents(s);const e=o.getClientRects();if(!e.length)continue;l(e[0])&&i.push({node:s,i:0});for(let t=1;t<e.length;t++)i.push({node:s,i:ee(s,t,o)});a=e[e.length-1]}}return i}(n);if(a.length<2)return;const l=e.createRange(),c=n.cloneNode(),d=a.length;let f=d;function p(){const e=a[--f];e.i<0?l.setStartBefore(e.node):l.setStart(e.node,e.i),l.setEnd(n,n.childNodes.length),c.prepend(l.extractContents());const t=n.lastChild;""===t?.innerHTML&&t.remove()}_(n,r);for(;f>(i?0:1)&&(p(),!(f>0)||R()););f>1&&d-f===1&&!s&&p();return[n,c]},table:function(e,t,n,o){const i=U(e,t,o),r=e.tBodies[0],s=r.cloneNode(),a=[...r.rows],l=a.length,c=n?0:1;i.append(s),[e.tHead,e.tFoot].forEach(e=>e&&i.append(e.cloneNode(!0))),s.append(...a);const d=w()-E-.5;if(d>=0){const e=a[l-1].getBoundingClientRect().bottom-d;let t=0,n=l;for(;t<n;){const o=t+n>>1;a[o].getBoundingClientRect().bottom<=e?t=o+1:n=o}let o=Math.max(t,c);for(r.prepend(...a.slice(o));o>c&&w()>E+.5;)r.prepend(a[--o])}s.rows.length||(i.innerHTML="");const f=s.rows.length;(1===r.rows.length&&f>1||1===f&&n&&r.rows.length)&&(r.prepend(s.rows[f-1]),1===f&&(i.innerHTML=""));return[i,r.rows.length?e:null]},code:function(t,n,o,i){const r=t.firstElementChild,s=X(t),a=[...t.children],l=a.filter((e,t)=>t>a.indexOf(r)&&z(getComputedStyle(e))),c=U(t,n,i),d=r.cloneNode();c.append(d,...a.filter(e=>e!==r&&!l.includes(e)));let f=function(t,n,o){const i=n.length,r=o?0:1;t.innerHTML=n.join("\n");const s=w()-E-.5;if(s<0)return i;const a=e.createRange(),l=[];t.childNodes.forEach(e=>{if(3===e.nodeType)for(let t=e.data.indexOf("\n");t>=0;t=e.data.indexOf("\n",t+1))a.setStart(e,t),a.setEnd(e,t+1),l.push(a.getBoundingClientRect().bottom)}),a.selectNodeContents(t);const c=a.getClientRects(),d=c[c.length-1].bottom;l.push(d);let f=0;for(;f<i&&l[f]<=d-s;)f++;for(;f&&f<i&&!n[f].trim();)f++;t.innerHTML=n.slice(0,Math.max(f,r)).join("\n");for(;f>r&&w()>E+.5;)t.innerHTML=n.slice(0,--f).join("\n");return Math.max(f,r)}(d,s,o);f>1&&s.length-f===1&&f--;1===f&&o&&(f=0);f?d.innerHTML=s.slice(0,f).join("\n"):c.innerHTML="";return r.innerHTML=s.slice(f).join("\n"),r.innerHTML.trim()?[c,t]:(f&&c.append(...l),[c,null])}};function G(e,t,n){for(let i;(i=e.lastElementChild)?.matches("legend")&&(o(e)>1||n);)t.prepend(i)}function K(e,t){!q(t)&&e.getBoundingClientRect().height<1.5*b&&t.prepend(...e.childNodes)}function Q(e,t,n){for(e.classList.add(l);R()&&e.lastElementChild&&(o(e)>1||n);)t.prepend(e.lastElementChild);q(t)||e.classList.remove(l)}function Z(e,t){t.start+=o(e)-(t.firstElementChild.classList.contains(s)?1:0)}function ee(e,t,n){let o=0,i=e.length;for(;o<i;){const r=o+i>>1;n.setStart(e,0),n.setEnd(e,r),n.getClientRects().length>t?i=r:o=r+1}return o-1}function te(e){return e&&(e.dataset.shortTitle||e.innerText)}const ne=(i?"h1":"h2")+":not(.pagesjs-front *)";function oe(e){const t=performance.now();for(;!y.next().done;)if(!(e||performance.now()-t<500))return new Promise(e=>{requestAnimationFrame(e),setTimeout(e,50)}).then(()=>oe())}function ie(o){const r=o||/Headless/.test(navigator.userAgent)||navigator.webdriver;if("complete"!==e.readyState)return addEventListener("load",()=>ie(o));const s=e.body.classList;if(s.contains("pagesjs"))return;dispatchEvent(new Event("pagesjs:before")),n(e.body.dataset.pagesFront||"body > header").forEach(e=>e.classList.add("pagesjs-front")),C=te(t("h1.title, .pagesjs-front h1, .title, h1")),s.add("pagesjs"),e.body.append(u),r||(N=e.createElement("div"),N.className="pagesjs-progress",N.textContent="Paginating...",e.body.append(N)),e.body.insertAdjacentElement("afterbegin",x()),E=(g.clientHeight||window.innerHeight)+3,v=h.clientHeight||E,n(":is(#TOC, .footnotes, .chapter-before, .chapter-after):is(.side-left, .side-right).side").forEach(e=>{e.classList.remove("side","side-left","side-right")}),s.add("pagesjs-filling"),function(){const t=e.createElement("p"),n=g.scrollHeight;t.innerText="A",h.append(t),b=g.scrollHeight-n,t.remove()}(),n('#TOC a[href^="#"]').forEach(t=>{const n=e.createElement("span");let o;for(n.className="toc-text",t.append(n);(o=n.previousSibling)&&!o.classList?.contains("section-number");)n.prepend(o);t.dataset.pageNumber="000"});const a=function(){const o=e.body.dataset.pagesRoot,i=o?[...n(o)]:[];if(i.length)return i;let r=t('main, [role="main"]');for(;1===r?.childElementCount;)r=r.firstElementChild;if(r)return[r];const s=[...n("article")].filter(e=>!e.parentNode.closest("article"));return s.length?s:[e.body]}(),l=function(t){return t.map(t=>{n('style, link[rel="stylesheet"]',t).forEach(t=>e.head.append(t));const o=[...t.children].filter(e=>![g,u,N].includes(e)&&!["SCRIPT","NOSCRIPT","TEMPLATE"].includes(e.tagName));return o.forEach(e=>e.remove()),o})}(a);function*c(){yield*function*(e,t){for(const e of n(".pagesjs-front, .abstract, #TOC:not(.chapter-toc)"))yield*F(e),i&&O();for(const[n,o]of e.entries()){H=k(o),m=null,i&&(""===g.innerText?x(g):O());for(const[o,i]of t[n].entries())yield*F(i,n<e.length-1||o<t[n].length-1);P(o.parentNode),P(o)}B(g),n(".pagesjs-run").forEach(e=>e.replaceWith(...e.childNodes))}(a,l),s.remove("pagesjs-filling"),function(){let e,o=0;f.forEach(r=>{if(i){if(t(".pagesjs-front",r))return;t(ne,r)&&(e="")}const s=+r.dataset.pagesOffset||1;s>1&&r.classList.add("page-multiple"),o+=s,r.classList.add("page-"+(o%2==0?"even":"odd"));const a={pageNumber:o,mainTitle:C,pageTitle:e};let l;[r.children[0],r.children[2]].forEach(e=>{for(const t in a)a[t]&&(e.dataset[t]=a[t])}),e=te([...n(ne,r)].pop())||e,n(".footnotes",r).forEach((e,t)=>{0===t?(l=e,r.children[1].after(e)):(l.append(...e.children),e.remove())})})}(),e.body.prepend(...f),n('#TOC a[href^="#"]').forEach(e=>{const n=t(`.pagesjs-page:has(#${CSS.escape(e.getAttribute("href").replace(/^#/,""))}) .pagesjs-header`);e.dataset.pageNumber=n?n.dataset.pageNumber:""}),u.remove(),N?.remove(),j=!0,dispatchEvent(new Event("pagesjs:after"))}L=e=>(L=null,T&&(T.forEach(e=>e.forEach(e=>e.remove())),h.innerHTML="",m=null,H=[],g.classList.remove("pagesjs-settle"),T=null),y=c(),oe(e||r)),o?L(!0):function(e,t){return g.classList.add("pagesjs-settle"),e.forEach((e,n)=>{H=k(e),m=null,A().append(...t[n])}),T=t,new Promise(e=>{const t=setTimeout(e,500);let n=0;!function o(){requestAnimationFrame(()=>++n<3?o():(clearTimeout(t),e()))}()})}(a,l).then(()=>L?.())}addEventListener("beforeprint",()=>{if(L)L(!0);else if(y)for(;!y.next().done;);else ie(!0)}),addEventListener("pagesjs:paginate",()=>{j?dispatchEvent(new Event("pagesjs:after")):ie()});const re=new URLSearchParams(location.search);re.get("paged")&&ie(),addEventListener("keypress",e=>{"p"===e.key&&(re.get("paged")?(re.delete("paged"),location.href=location.pathname+(re.size?`?${re}`:"")):(ie(),re.set("paged",1),history.replaceState({},"",`${location.pathname}?${re}`)))})})(document);
1
+ (e=>{function t(t,n=e){return n?.querySelector(t)}function n(t,n=e){return n?n.querySelectorAll(t):[]}function o(e){return e.childElementCount}function r(e){return[...e.children]}function i(e){return e.firstElementChild}function s(e){return e.lastElementChild}function a(e){return e.getBoundingClientRect()}function c(e){return getComputedStyle(e)}function l(e){return parseFloat(e)||0}function f(e,t){return e.classList.contains(t)}function d(e,...t){e.classList.add(...t)}function u(e,...t){e.classList.remove(...t)}function p(t,n){const o=e.createElement(t);return n&&(o.className=n),o}function g(){return e.createRange()}function h(e,t){addEventListener(e,t)}function m(e){dispatchEvent(new Event(e))}const b=n("h1").length>1,T="h1,h2,h3,h4,h5,h6,hr,img,svg,video,canvas,iframe,object,embed,math,mjx-container,figure,.figure,.caption,details",N="pagesjs-fragmented",E="fragment-first",v="fragment-last",j=["top","bottom"].map(t=>l(c(e.documentElement).getPropertyValue(`--paper-margin-${t}`))),y=p("div","pagesjs-page"),C=[],H=new WeakSet,L=new WeakSet,x=new Map,M=p("div");y.innerHTML='<div class="pagesjs-header"></div>\n<div class="pagesjs-body"></div>\n<div class="pagesjs-footer"></div>',M.style.display="none";let S,w,k,O,A,P,R,B,$,W,F,q,I,V=[],z=0;function D(e){return e&&!t(".pagesjs-body",e)&&e.insertAdjacentHTML("afterbegin",y.innerHTML),S=e||y.cloneNode(!0),w=S.children[1],k=null,C.includes(S)||C.push(S),S}function X(e=w){let t=0;for(let n=s(e);n;n=s(n)){const e=c(n);if(t=Math.max(t,l(e.marginBottom)),l(e.paddingBottom)||l(e.borderBottomWidth))break}return t}function _(){return U(),a(S).height-X()}function J(){return U(),S.scrollHeight-X()>O}function U(e=S){const r=e.children[1],i=[...n(".pagesjs-note",r)].flatMap(e=>x.get(e));let s=t(":scope > .footnotes",e);if(!i.length)return s?.remove();s||r.after(s=p("div")),s.className="footnotes",(i.some((e,t)=>s.children[t]!==e)||o(s)!==i.length)&&s.replaceChildren(...i)}function Y(e,t){const n=S;n.after(D(e)),t&&t(),G(n)}function G(e){U(e);const t=e.scrollHeight;if(t-X(e.children[1])>O&&!e.dataset.pagesOffset){const o=function(e,t){let o=+e.dataset.pagesOffset;if(o)return o;if(o=Math.ceil(t/O),o<=1)return o;const r=j.concat([...n("thead",e)].map(e=>+e.offsetHeight)).reduce((e,t)=>e+t);if(!r)return o;function i(){return Math.ceil((t+(o-1)*r)/O)}let s=i();for(;s>o;)o=s,s=i();return o}(e,t);o>1&&(e.dataset.pagesOffset=o,L.add(e))}e.remove(),q&&(q.textContent=`Paginating: ${++z} pages done`)}function K(t){const n=[];for(;t&&t!==e.body;t=t.parentNode)n.unshift(t);return n}function Q(){return V.length?(k&&w.contains(k)||(k=V.reduce((e,t)=>{const n=t.cloneNode();return d(n,"pagesjs-wrap"),e.appendChild(n)},w)),k):w}function Z(e){if(!e||"BODY"===e.tagName)return!1;const t=!("P"===e.tagName?e.innerHTML:e.innerText).trim();return t&&e.remove(),t}function*ee(e,n=!0){f(e,"pagesjs-page")?Y(e,()=>o(e)>3&&(w.append(...r(e).slice(3)),Y())):(b&&""!==S.innerText&&t("h1",e)&&Y(),e.innerText.trim()&&(U(),O-S.scrollHeight<P)&&Y(),yield*function*(e,t){for(;;){const n=Q();if(fe(e),ne(e))e=te(e,n,"block",t);else{if(n.append(e),!J())return;e=te(e,n,void 0,t)}if(!e)return;Y(),yield}}(e,n))}function te(e,t,n,o){const s=n||function(e){const t=c(e),n=e.tagName;if(/avoid/.test(t.breakInside)||e.matches(T))return;if("TABLE"===n)return e.tBodies[0]&&"table";if(!["block","list-item","flow-root"].includes(t.display)||!ie(t))return;if("PRE"===n){if("CODE"===i(e)?.tagName&&ce(e).length>1)return"code";if(e.offsetHeight<=A)return}return r(e).some(e=>!se(e))?"block":"inline"}(e),a="block"===s?void 0:re(e),l=!f(e,N),p=s&&ue[s](e,t,a,l,o);if(!p)return a&&(e.remove(),e);const[g,h]=p;return oe(g)?(g.remove(),h):(h?(d(h,N),u(h,E,v)):f(g,E)?u(g,N,E,v):d(g,v),h)}function ne(e){return!["TABLE","PRE"].includes(e.tagName)&&e.getElementsByTagName("*").length>300}function oe(e){return!i(e)&&!e.textContent.trim()}function re(e){for(;e&&e!==w;e=e.parentNode)for(let t=e.previousElementSibling;t;t=t.previousElementSibling)if(a(t).height)return!0;return!1}function ie(e){return"none"===e.float&&!["absolute","fixed"].includes(e.position)}function se(e){if(1!==e.nodeType)return!0;const t=c(e),n=t.display;return n.startsWith("inline")||"none"===n||"contents"===n||!ie(t)}function ae(e){const t=c(e);return(t.display.startsWith("inline")||"contents"===t.display)&&ie(t)}function ce(e){const t=[];return i(e).innerHTML.replace(/\n$/,"").split("\n").map(e=>{const n=t.map(e=>e[0]).join("");return e.replace(/<(\/?)([a-z][\w-]*)[^>]*>/gi,(e,n,o)=>{n?t.pop():t.push([e,o])}),n+e+t.map(e=>`</${e[1]}>`).reverse().join("")})}function le(e,t){d(e,N),u(e,v),t&&d(e,E)}function fe(e){1===e.nodeType&&[e,...n("."+N,e)].forEach(e=>f(e,N)&&d(e,v))}function de(e,t,n){const o=e.cloneNode();return e.remove(),t.append(o),le(o,n),o}const ue={block:function(e,t,n,r,s){!function(e){if(H.has(e)||f(e,"pagesjs-run"))return;H.add(e),e.isConnected||M.append(e);let t=[];function n(){if(t.some(e=>1===e.nodeType||3===e.nodeType&&e.nodeValue.trim())){const e=p("span","pagesjs-run");t[0].before(e),e.append(...t)}t=[]}for(const o of[...e.childNodes])se(o)?t.push(o):n();n(),e.parentNode===M&&e.remove()}(e);const a=de(e,t,r);let c,l;n=re(a);for(;c=e.firstChild;){if(1!==c.nodeType){a.append(c);continue}fe(c);const t=ne(c);if(!t&&(a.append(c),!J()))continue;const n=o(a),r=te(c,a,t?"block":void 0,s||!!i(e));if(r){l=o(a)>n,e.prepend(r);break}}return oe(e)&&me(a,e,n),oe(e)||pe(a,e,n),n&&!l&&ge(a,e),"OL"===e.tagName&&o(a)&&!oe(e)&&be(a,e),[a,oe(e)?null:e]},inline:function(n,o,r,i,s){const c=function(n){const o=g(),r=[{node:n,i:0}],i=e.createTreeWalker(n,NodeFilter.SHOW_TEXT|NodeFilter.SHOW_ELEMENT);let s,c;function l(e){return c&&c.bottom<=e.top&&c.right>e.left}for(;s=i.nextNode();){const e=s.tagName;if(e){if(("MJX-CONTAINER"===e||"SPAN"===e&&t(".katex",s)||!ae(s))&&(s=i.nextSibling(),!s))break;if(s.firstChild)continue}if(s.tagName){const e=a(s);l(e)&&r.push({node:s,i:-1}),c=e}else if(s.textContent.trim()){o.selectNodeContents(s);const e=o.getClientRects();if(!e.length)continue;l(e[0])&&r.push({node:s,i:0});for(let t=1;t<e.length;t++)r.push({node:s,i:Te(s,t,o)});c=e[e.length-1]}}return r}(n);if(c.length<2)return;const l=g(),f=n.cloneNode(),d=c.length;let u=d;function p(){const e=c[--u];e.i<0?l.setStartBefore(e.node):l.setStart(e.node,e.i),l.setEnd(n,n.childNodes.length),f.prepend(l.extractContents());const t=n.lastChild;""===t?.innerHTML&&t.remove()}le(n,i);for(;u>(r?0:1)&&(p(),!(u>0)||J()););u>1&&d-u===1&&!s&&p();return[n,f]},table:function(e,t,n,o){const r=de(e,t,o),i=e.tBodies[0],s=i.cloneNode(),l=[...i.rows],f=l.length,d=n?0:1,u=e.caption&&"bottom"!==c(e.caption).captionSide?e.caption:null;function p(){u&&e.prepend(u),r.innerHTML=""}u&&r.append(u),[e.tHead,s,e.tFoot].forEach(e=>e&&r.append(e===s?e:e.cloneNode(!0))),s.append(...l);const g=_()-O-.5;if(g>=0){const e=a(l[f-1]).bottom-g;let t=0,n=f;for(;t<n;){const o=t+n>>1;a(l[o]).bottom<=e?t=o+1:n=o}let o=Math.max(t,d);for(i.prepend(...l.slice(o));o>d&&_()>O+.5;)i.prepend(l[--o])}s.rows.length||p();const h=s.rows.length;(1===i.rows.length&&h>1||1===h&&n&&i.rows.length)&&(i.prepend(s.rows[h-1]),1===h&&p());return[r,i.rows.length?e:null]},code:function(e,t,n,o){const s=i(e),l=ce(e),f=r(e),d=f.filter((e,t)=>t>f.indexOf(s)&&ie(c(e))),u=de(e,t,o),p=s.cloneNode();u.append(p,...f.filter(e=>e!==s&&!d.includes(e)));let h=function(e,t,n){const o=t.length,r=n?0:1;e.innerHTML=t.join("\n");const i=_()-O-.5;if(i<0)return o;const s=g(),c=[];e.childNodes.forEach(e=>{if(3===e.nodeType)for(let t=e.data.indexOf("\n");t>=0;t=e.data.indexOf("\n",t+1))s.setStart(e,t),s.setEnd(e,t+1),c.push(a(s).bottom)}),s.selectNodeContents(e);const l=s.getClientRects(),f=l[l.length-1].bottom;c.push(f);let d=0;for(;d<o&&c[d]<=f-i;)d++;for(;d&&d<o&&!t[d].trim();)d++;e.innerHTML=t.slice(0,Math.max(d,r)).join("\n");for(;d>r&&_()>O+.5;)e.innerHTML=t.slice(0,--d).join("\n");return Math.max(d,r)}(p,l,n);h>1&&l.length-h===1&&h--;1===h&&n&&(h=0);h?p.innerHTML=l.slice(0,h).join("\n"):u.innerHTML="";return s.innerHTML=l.slice(h).join("\n"),s.innerHTML.trim()?[u,e]:(h&&u.append(...d),[u,null])}};function pe(e,t,n){for(let r;(r=s(e))?.matches("legend, .caption")&&(o(e)>1||n);)t.prepend(r)}function ge(e,t){!oe(t)&&a(e).height<1.5*R&&(he(s(e),i(t)),t.prepend(...e.childNodes))}function he(e,t){e&&t&&f(e,N)&&f(t,N)&&e.tagName===t.tagName&&(he(s(e),i(t)),t.prepend(...e.childNodes),u(t,...f(e,E)?[N,E,v]:[E]),e.remove())}function me(e,t,n){for(d(e,v);J()&&s(e)&&(o(e)>1||n);){const n=s(e),o=te(n,e,void 0,!0);if(!o)break;if(t.prepend(o),o!==n)break}oe(t)||u(e,v)}function be(e,t){t.start+=o(e)-(f(i(t),N)?1:0)}function Te(e,t,n){let o=0,r=e.length;for(;o<r;){const i=o+r>>1;n.setStart(e,0),n.setEnd(e,i),n.getClientRects().length>t?r=i:o=i+1}return o-1}function Ne(e){return e&&(e.dataset.shortTitle||e.innerText)}const Ee=(b?"h1":"h2")+":not(.pagesjs-front *)";function ve(e){return[...e.childNodes].some(e=>3===e.nodeType&&e.nodeValue.trim())}function je(e){return!["PRE","TABLE"].includes(e.tagName)&&!ve(e)}function ye(e){const t=performance.now();for(;!F.next().done;)if(!(e||performance.now()-t<500))return new Promise(e=>{requestAnimationFrame(e),setTimeout(e,50)}).then(()=>ye())}function Ce(c){const l=c||/Headless/.test(navigator.userAgent)||navigator.webdriver;if("complete"!==e.readyState)return h("load",()=>Ce(c));const T=e.body.classList;if(T.contains("pagesjs"))return;m("pagesjs:before");const N=performance.now();n(e.body.dataset.pagesFront||"body > header").forEach(e=>d(e,"pagesjs-front")),B=Ne(t("h1.title, .pagesjs-front h1, .title, h1")),T.add("pagesjs"),e.body.append(M),l||(q=p("div","pagesjs-progress"),q.textContent="Paginating...",e.body.append(q)),e.body.insertAdjacentElement("afterbegin",D()),O=(S.clientHeight||window.innerHeight)+3,A=w.clientHeight||O,n(":is(#TOC, .footnotes, .chapter-before, .chapter-after):is(.side-left, .side-right).side").forEach(e=>{u(e,"side","side-left","side-right")}),T.add("pagesjs-filling"),function(){const e=p("p"),t=S.scrollHeight;e.innerText="A",w.append(e),P=S.scrollHeight-t,R=a(e).height,e.remove()}(),n('#TOC a[href^="#"]').forEach(e=>{const t=p("span","toc-text");let n;for(e.append(t);(n=t.previousSibling)&&(1!==n.nodeType||!f(n,"section-number"));)t.prepend(n);e.dataset.pageNumber="000"}),n(".footnotes").forEach(e=>{const t=e.previousElementSibling;if(!t||!f(t,"note-ref"))return;const n=p("span","pagesjs-note");n.hidden=!0,x.set(n,r(e)),e.replaceWith(n)});const E=function(){const r=e.body.dataset.pagesRoot,s=r?[...n(r)]:[];if(s.length)return s;let a=t('main, [role="main"]');for(;a&&1===o(a)&&!ve(a)&&je(i(a));)a=i(a);if(a)return[a];const c=[...n("article")].filter(e=>!e.parentNode.closest("article"));return c.length?c:[e.body]}(),v=function(t){return t.map(t=>{n('style, link[rel="stylesheet"]',t).forEach(t=>e.head.append(t));const o=r(t).filter(e=>![S,M,q].includes(e)&&!["SCRIPT","NOSCRIPT","TEMPLATE"].includes(e.tagName));return o.forEach(e=>e.remove()),o})}(E);function*j(){yield*function*(e,t){for(const e of n(".pagesjs-front, .abstract, #TOC:not(.chapter-toc)"))yield*ee(e),b&&Y();for(const[n,o]of e.entries()){V=K(o),k=null,b&&(""===S.innerText?D(S):Y());for(const[o,r]of t[n].entries())yield*ee(r,n<e.length-1||o<t[n].length-1);Z(o.parentNode),Z(o)}G(S),n(".pagesjs-run").forEach(e=>e.replaceWith(...e.childNodes))}(E,v),T.remove("pagesjs-filling"),e.body.prepend(...C),C.forEach(e=>{if(!L.has(e))return;const t=e.children[1],n=g();n.selectNodeContents(t),a(n).bottom<=a(t.nextElementSibling).top&&e.scrollHeight<=e.clientHeight+1&&delete e.dataset.pagesOffset}),function(){let e,o=0;C.forEach(r=>{if(b){if(t(".pagesjs-front",r))return;t(Ee,r)&&(e="")}const i=+r.dataset.pagesOffset||1;i>1&&d(r,"page-multiple"),o+=i,d(r,"page-"+(o%2==0?"even":"odd"));const a={pageNumber:o,mainTitle:B,pageTitle:e};[r.children[0],s(r)].forEach(e=>{for(const t in a)a[t]&&(e.dataset[t]=a[t])}),e=Ne([...n(Ee,r)].pop())||e})}(),n('#TOC a[href^="#"]').forEach(e=>{const n=t(`.pagesjs-page:has(#${CSS.escape(e.getAttribute("href").replace(/^#/,""))}) .pagesjs-header`);e.dataset.pageNumber=n?n.dataset.pageNumber:""}),M.remove(),q?.remove(),I=!0;const o=C.filter(e=>e.classList.contains("page-multiple")).length;console.info(`pages.js: ${C.length} pages in ${Math.round(performance.now()-N)} ms`+(o?`; ${o} overflow their page`:"")),m("pagesjs:after")}W=e=>(W=null,$&&($.forEach(e=>e.forEach(e=>e.remove())),w.innerHTML="",k=null,V=[],u(S,"pagesjs-settle"),$=null),F=j(),ye(e||l)),c?W(!0):function(e,t){return d(S,"pagesjs-settle"),e.forEach((e,n)=>{V=K(e),k=null,Q().append(...t[n])}),$=t,new Promise(e=>{const t=setTimeout(e,500);let n=0;!function o(){requestAnimationFrame(()=>++n<3?o():(clearTimeout(t),e()))}()})}(E,v).then(()=>W?.())}h("beforeprint",()=>{if(W)W(!0);else if(F)for(;!F.next().done;);else Ce(!0)}),h("pagesjs:paginate",()=>{I?m("pagesjs:after"):Ce()});const He=new URLSearchParams(location.search);He.get("paged")&&Ce(),h("keypress",e=>{"p"===e.key&&(He.get("paged")?(He.delete("paged"),location.href=location.pathname+(He.size?`?${He}`:"")):(Ce(),He.set("paged",1),history.replaceState({},"",`${location.pathname}?${He}`)))})})(document);
2
2
  //# sourceMappingURL=pages.min.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["d","$","s","el","querySelector","$$","querySelectorAll","nChild","childElementCount","book","length","atomic","fr_cls","fr_1","fr_2","tb","map","i","parseFloat","getComputedStyle","documentElement","getPropertyValue","tpl","createElement","boxes","wrapped","WeakSet","hold","className","innerHTML","style","display","box","box_body","box_ctx","H","B","H_min","main_title","probed","pending","running","progress","finished","wrap","n_done","newPage","insertAdjacentHTML","cloneNode","children","includes","push","trailingMargin","body","m","e","lastElementChild","cs","Math","max","marginBottom","paddingBottom","borderBottomWidth","pageHeight","getBoundingClientRect","height","overflows","scrollHeight","nextPage","callback","cur","after","finish","h","dataset","pagesOffset","n","ceil","concat","offsetHeight","reduce","m1","m2","nPages","n2","calcPages","remove","textContent","ancestors","a","parentNode","unshift","ctx","contains","p","c","classList","add","appendChild","removeBlank","tagName","v","innerText","trim","fill","more","append","slice","endFrag","isBigBlock","split","undefined","place","container","kind","k","t","test","breakInside","matches","tBodies","inFlow","firstElementChild","codeLines","some","isInline","kindOf","prev","hasPrev","first","r","splitters","head","rest","blank","getElementsByTagName","previousElementSibling","float","position","nodeType","startsWith","inTextFlow","pre","open","replace","line","start","join","pop","reverse","mark","forEach","cut","block","has","isConnected","run","flush","nodeValue","before","childNodes","wrapRuns","item","partial","firstChild","big","prepend","fitLastPiece","moveTrailingHeadings","moveShortHead","fixOlStart","inline","ends","createRange","node","walker","createTreeWalker","NodeFilter","SHOW_TEXT","SHOW_ELEMENT","newLine","rect","bottom","top","right","left","nextNode","nextSibling","selectNodeContents","rects","getClientRects","lineOffset","lineStarts","cutLine","loc","setStartBefore","setStart","setEnd","extractContents","last","lastChild","table","tb2","rows","min","tHead","tFoot","over","limit","lo","hi","mid","code","lines","kids","tail","filter","j","indexOf","code2","bottoms","data","fitLines","shortTitle","ps","advance","sync","performance","now","next","done","Promise","go","requestAnimationFrame","setTimeout","then","paginate","quiet","navigator","userAgent","webdriver","readyState","addEventListener","cls","dispatchEvent","Event","pagesFront","insertAdjacentElement","clientHeight","window","innerHeight","H0","measureMinHeight","previousSibling","pageNumber","roots","sel","pagesRoot","x","main","articles","closest","findRoots","els","ch","detachContent","entries","child","replaceWith","fillPages","page_title","N","info","mainTitle","pageTitle","ft","key","numberPages","CSS","escape","getAttribute","tick","clearTimeout","probe","SP","URLSearchParams","location","search","get","delete","href","pathname","size","set","history","replaceState","document"],"sources":["pages.js"],"mappings":"AAkBA,CAACA,IAIC,SAAUC,EAAEC,EAAGC,EAAKH,GAAK,OAAOG,GAAIC,cAAcF,EAAI,CACtD,SAASG,EAAGH,EAAGC,EAAKH,GAAK,OAAOG,EAAKA,EAAGG,iBAAiBJ,GAAK,EAAI,CAClE,SAASK,EAAOJ,GAAM,OAAOA,EAAGK,iBAAmB,CAInD,MACEC,EAAOJ,EAAG,MAAMK,OAAS,EAEzBC,EAAS,0GAETC,EAAS,qBAAsBC,EAAO,iBAAkBC,EAAO,gBAK/DC,EAAK,CAAC,MAAO,UAAUC,IAAIC,GACzBC,WAAWC,iBAAiBnB,EAAEoB,iBAAiBC,iBAAiB,kBAAkBJ,OAAS,GAG7FK,EAAMtB,EAAEuB,cAAc,OACtBC,EAAQ,GACRC,EAAU,IAAIC,QACdC,EAAO3B,EAAEuB,cAAc,OACzBD,EAAIM,UAAY,eAChBN,EAAIO,UAAY,2GAGhBF,EAAKG,MAAMC,QAAU,OAErB,IACEC,EAAKC,EACLC,EAEAC,EAAGC,EACHC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EARAC,EAAO,GAOGC,EAAS,EAKrB,SAASC,EAAQ3C,GAIf,OAHAA,IAAOF,EAAE,gBAAiBE,IAAOA,EAAG4C,mBAAmB,aAAczB,EAAIO,WACzEG,EAAM7B,GAAMmB,EAAI0B,WAAU,GAAOf,EAAWD,EAAIiB,SAAS,GAAIf,EAAU,KACvEV,EAAM0B,SAASlB,IAAQR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B,GAAIC,EAAS,MAAQA,EAAQ4L,OAAOC,YACpCM,IAAS,KAKhBM,iBAAiB,mBAAoB,KACnCvM,EAAWyM,cAAc,IAAIC,MAAM,kBAAoBT,OAGzD,MAAMgD,GAAK,IAAIC,gBAAgBC,SAASC,QACxCH,GAAGI,IAAI,UAAYpD,KACnBM,iBAAiB,WAAY3L,IACb,MAAVA,EAAE6N,MACAQ,GAAGI,IAAI,UACTJ,GAAGK,OAAO,SAAUH,SAASI,KAAOJ,SAASK,UAAYP,GAAGQ,KAAO,IAAIR,KAAO,MAE9EhD,KACAgD,GAAGS,IAAI,QAAS,GAAIC,QAAQC,aAAa,CAAC,EAAG,GAAI,GAAGT,SAASK,YAAYP,SAIhF,EAptBD,CAotBGY","ignoreList":[]}
1
+ {"version":3,"names":["d","$","s","el","querySelector","$$","querySelectorAll","nChild","childElementCount","kids","children","firstEl","firstElementChild","lastEl","lastElementChild","rect","getBoundingClientRect","style","getComputedStyle","num","v","parseFloat","has","c","classList","contains","addCls","add","rmCls","remove","make","tag","cls","createElement","className","range","createRange","on","type","fn","addEventListener","fire","dispatchEvent","Event","book","length","atomic","fr_cls","fr_1","fr_2","tb","map","i","documentElement","getPropertyValue","tpl","boxes","wrapped","WeakSet","guessed","notes","Map","hold","innerHTML","display","box","box_body","box_ctx","H","B","H_min","H_line","main_title","probed","pending","running","progress","finished","wrap","n_done","newPage","insertAdjacentHTML","cloneNode","includes","push","trailingMargin","body","m","e","cs","Math","max","marginBottom","paddingBottom","borderBottomWidth","pageHeight","syncNotes","height","overflows","scrollHeight","b","items","flatMap","get","after","some","replaceChildren","nextPage","callback","cur","finish","h","dataset","pagesOffset","n","ceil","concat","offsetHeight","reduce","m1","m2","nPages","n2","calcPages","textContent","ancestors","a","parentNode","unshift","ctx","p","appendChild","removeBlank","tagName","innerText","trim","fill","more","append","slice","endFrag","isBigBlock","split","undefined","place","container","kind","k","t","test","breakInside","matches","tBodies","inFlow","codeLines","isInline","kindOf","prev","hasPrev","first","r","splitters","head","rest","blank","getElementsByTagName","previousElementSibling","float","position","nodeType","startsWith","inTextFlow","pre","open","replace","line","start","join","pop","reverse","mark","forEach","cut","block","isConnected","run","flush","nodeValue","before","childNodes","wrapRuns","item","partial","firstChild","big","prepend","fitLastPiece","moveTrailingHeadings","moveShortHead","fixOlStart","inline","ends","node","walker","createTreeWalker","NodeFilter","SHOW_TEXT","SHOW_ELEMENT","newLine","bottom","top","right","left","nextNode","nextSibling","rc","selectNodeContents","rects","getClientRects","lineOffset","lineStarts","cutLine","loc","setStartBefore","setStart","setEnd","extractContents","last","lastChild","table","tb2","rows","min","cap","caption","captionSide","clear","tHead","tFoot","over","limit","lo","hi","mid","code","lines","ch","tail","filter","j","indexOf","code2","bottoms","data","fitLines","rejoin","shortTitle","ps","ownText","canBeRoot","advance","sync","performance","now","next","done","Promise","go","requestAnimationFrame","setTimeout","then","paginate","quiet","navigator","userAgent","webdriver","readyState","t0","pagesFront","insertAdjacentElement","clientHeight","window","innerHeight","H0","measureMinHeight","previousSibling","pageNumber","hidden","set","replaceWith","roots","sel","pagesRoot","x","main","articles","closest","findRoots","els","detachContent","entries","child","fillPages","nextElementSibling","page_title","N","info","mainTitle","pageTitle","key","numberPages","CSS","escape","getAttribute","console","round","tick","clearTimeout","probe","SP","URLSearchParams","location","search","delete","href","pathname","size","history","replaceState","document"],"sources":["pages.js"],"mappings":"AAkBA,CAACA,IAIC,SAAUC,EAAEC,EAAGC,EAAKH,GAAK,OAAOG,GAAIC,cAAcF,EAAI,CACtD,SAASG,EAAGH,EAAGC,EAAKH,GAAK,OAAOG,EAAKA,EAAGG,iBAAiBJ,GAAK,EAAI,CAClE,SAASK,EAAOJ,GAAM,OAAOA,EAAGK,iBAAmB,CACnD,SAASC,EAAKN,GAAM,MAAO,IAAIA,EAAGO,SAAW,CAC7C,SAASC,EAAQR,GAAM,OAAOA,EAAGS,iBAAmB,CACpD,SAASC,EAAOV,GAAM,OAAOA,EAAGW,gBAAkB,CAClD,SAASC,EA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ACzCqC,EAASH,UAAY,GAAII,EAAU,KAAMW,EAAO,GAChDlD,EAAMqC,EAAK,kBACXQ,EAAS,MAkMsCE,EAAU8G,IAAc2E,GAAQC,GAAQW,IACvFX,EAAO3L,GAAQ,GAtNjB,SAAewN,EAAOQ,GAMpB,OALAhR,EAAOuC,EAAK,kBACZiO,EAAM7G,QAAQ,CAAClL,EAAIiD,KACjB0B,EAAO+C,EAAU1H,GAAKgE,EAAU,KAAM8D,IAAMS,UAAUgK,EAAItP,MAE5DqB,EAASiO,EACF,IAAIhC,QAAQD,IACjB,MAAMrH,EAAIyH,WAAWJ,EAAM,KAC3B,IAAIvJ,EAAI,GACR,SAAU0M,IACRhD,sBAAsB,MAAQ1J,EAAI,EAAI0M,KAAUC,aAAazK,GAAIqH,KAClE,CAFD,IAIJ,CAyMyBqD,CAAM5B,EAAOQ,GAAK5B,KAAK,IAAMpM,MACtD,CACArC,EAAG,cAAe,KAChB,GAAIqC,EAASA,GAAQ,QAChB,GAAIC,EAAS,MAAQA,EAAQ6L,OAAOC,YACpCM,IAAS,KAKhB1O,EAAG,mBAAoB,KACrBwC,EAAWpC,EAAK,iBAAmBsO,OAGrC,MAAMgD,GAAK,IAAIC,gBAAgBC,SAASC,QACxCH,GAAGxN,IAAI,UAAYwK,KACnB1O,EAAG,WAAYmD,IACC,MAAVA,EAAE6N,MACAU,GAAGxN,IAAI,UACTwN,GAAGI,OAAO,SAAUF,SAASG,KAAOH,SAASI,UAAYN,GAAGO,KAAO,IAAIP,KAAO,MAE9EhD,KACAgD,GAAG/B,IAAI,QAAS,GAAIuC,QAAQC,aAAa,CAAC,EAAG,GAAI,GAAGP,SAASI,YAAYN,SAIhF,EAvyBD,CAuyBGU","ignoreList":[]}
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@xiee/utils",
3
- "version": "1.14.134",
3
+ "version": "1.14.136",
4
4
  "description": "Miscellaneous tools and utilities to manipulate HTML pages",
5
5
  "scripts": {
6
- "test": "echo \"Error: no test specified\" && exit 1"
6
+ "test": "playwright test"
7
7
  },
8
8
  "repository": {
9
9
  "type": "git",
@@ -23,5 +23,9 @@
23
23
  "bugs": {
24
24
  "url": "https://github.com/yihui/lite.js/issues"
25
25
  },
26
- "homepage": "https://github.com/yihui/lite.js#readme"
26
+ "homepage": "https://github.com/yihui/lite.js#readme",
27
+ "type": "module",
28
+ "devDependencies": {
29
+ "@playwright/test": "^1.64.1"
30
+ }
27
31
  }
@@ -1,10 +0,0 @@
1
- version: 2
2
- updates:
3
- - package-ecosystem: "github-actions"
4
- directory: "/"
5
- schedule:
6
- interval: "monthly"
7
- groups:
8
- all-dependencies:
9
- patterns:
10
- - "*"
@@ -1,26 +0,0 @@
1
- name: Node.js Package
2
-
3
- on:
4
- push:
5
- tags:
6
- - 'v*'
7
-
8
- permissions:
9
- id-token: write # Required for OIDC
10
- contents: read
11
-
12
- jobs:
13
- build:
14
- runs-on: ubuntu-latest
15
- steps:
16
- - uses: actions/checkout@v7
17
- with:
18
- fetch-depth: 0
19
- fetch-tags: true
20
- - uses: actions/setup-node@v7
21
- with:
22
- registry-url: 'https://registry.npmjs.org'
23
- - run: sudo npm install -g npm@latest
24
- - run: ./build.sh
25
- - run: npm publish
26
- - run: ./purge.sh