pageproof 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +90 -0
  3. package/THIRD_PARTY_NOTICES.md +74 -0
  4. package/assets/SKILL.md +58 -0
  5. package/assets/_paged.css +82 -0
  6. package/assets/chicago.csl +6006 -0
  7. package/assets/default.html +496 -0
  8. package/assets/doublespaced.css +8 -0
  9. package/assets/european-journal-of-international-law.csl +404 -0
  10. package/assets/favicon.svg +5 -0
  11. package/assets/footnotes-inline.lua +56 -0
  12. package/assets/latex.css +142 -0
  13. package/assets/msword.css +100 -0
  14. package/assets/numbered.css +75 -0
  15. package/assets/vendor/mathjax/LICENSE +202 -0
  16. package/assets/vendor/mathjax/sre/mathmaps/af.json +146 -0
  17. package/assets/vendor/mathjax/sre/mathmaps/base.json +140 -0
  18. package/assets/vendor/mathjax/sre/mathmaps/ca.json +140 -0
  19. package/assets/vendor/mathjax/sre/mathmaps/da.json +140 -0
  20. package/assets/vendor/mathjax/sre/mathmaps/de.json +146 -0
  21. package/assets/vendor/mathjax/sre/mathmaps/en.json +158 -0
  22. package/assets/vendor/mathjax/sre/mathmaps/es.json +140 -0
  23. package/assets/vendor/mathjax/sre/mathmaps/euro.json +32 -0
  24. package/assets/vendor/mathjax/sre/mathmaps/fr.json +146 -0
  25. package/assets/vendor/mathjax/sre/mathmaps/hi.json +146 -0
  26. package/assets/vendor/mathjax/sre/mathmaps/it.json +146 -0
  27. package/assets/vendor/mathjax/sre/mathmaps/ko.json +146 -0
  28. package/assets/vendor/mathjax/sre/mathmaps/nb.json +146 -0
  29. package/assets/vendor/mathjax/sre/mathmaps/nemeth.json +125 -0
  30. package/assets/vendor/mathjax/sre/mathmaps/nn.json +146 -0
  31. package/assets/vendor/mathjax/sre/mathmaps/sv.json +146 -0
  32. package/assets/vendor/mathjax/sre/speech-worker.js +1 -0
  33. package/assets/vendor/mathjax/tex-mml-chtml-nofont.js +18 -0
  34. package/assets/vendor/mathjax-fonts/LICENSE +202 -0
  35. package/assets/vendor/mathjax-fonts/mathjax-tex-font/chtml/woff2/mjx-tex-b.woff2 +0 -0
  36. package/assets/vendor/mathjax-fonts/mathjax-tex-font/chtml/woff2/mjx-tex-bi.woff2 +0 -0
  37. package/assets/vendor/mathjax-fonts/mathjax-tex-font/chtml/woff2/mjx-tex-brk.woff2 +0 -0
  38. package/assets/vendor/mathjax-fonts/mathjax-tex-font/chtml/woff2/mjx-tex-c.woff2 +0 -0
  39. package/assets/vendor/mathjax-fonts/mathjax-tex-font/chtml/woff2/mjx-tex-cb.woff2 +0 -0
  40. package/assets/vendor/mathjax-fonts/mathjax-tex-font/chtml/woff2/mjx-tex-f.woff2 +0 -0
  41. package/assets/vendor/mathjax-fonts/mathjax-tex-font/chtml/woff2/mjx-tex-fb.woff2 +0 -0
  42. package/assets/vendor/mathjax-fonts/mathjax-tex-font/chtml/woff2/mjx-tex-i.woff2 +0 -0
  43. package/assets/vendor/mathjax-fonts/mathjax-tex-font/chtml/woff2/mjx-tex-lo.woff2 +0 -0
  44. package/assets/vendor/mathjax-fonts/mathjax-tex-font/chtml/woff2/mjx-tex-m.woff2 +0 -0
  45. package/assets/vendor/mathjax-fonts/mathjax-tex-font/chtml/woff2/mjx-tex-mi.woff2 +0 -0
  46. package/assets/vendor/mathjax-fonts/mathjax-tex-font/chtml/woff2/mjx-tex-n.woff2 +0 -0
  47. package/assets/vendor/mathjax-fonts/mathjax-tex-font/chtml/woff2/mjx-tex-ob.woff2 +0 -0
  48. package/assets/vendor/mathjax-fonts/mathjax-tex-font/chtml/woff2/mjx-tex-os.woff2 +0 -0
  49. package/assets/vendor/mathjax-fonts/mathjax-tex-font/chtml/woff2/mjx-tex-s3.woff2 +0 -0
  50. package/assets/vendor/mathjax-fonts/mathjax-tex-font/chtml/woff2/mjx-tex-s4.woff2 +0 -0
  51. package/assets/vendor/mathjax-fonts/mathjax-tex-font/chtml/woff2/mjx-tex-so.woff2 +0 -0
  52. package/assets/vendor/mathjax-fonts/mathjax-tex-font/chtml/woff2/mjx-tex-ss.woff2 +0 -0
  53. package/assets/vendor/mathjax-fonts/mathjax-tex-font/chtml/woff2/mjx-tex-ssb.woff2 +0 -0
  54. package/assets/vendor/mathjax-fonts/mathjax-tex-font/chtml/woff2/mjx-tex-ssi.woff2 +0 -0
  55. package/assets/vendor/mathjax-fonts/mathjax-tex-font/chtml/woff2/mjx-tex-v.woff2 +0 -0
  56. package/assets/vendor/mathjax-fonts/mathjax-tex-font/chtml/woff2/mjx-tex-zero.woff2 +0 -0
  57. package/assets/vendor/mathjax-fonts/mathjax-tex-font/chtml.js +1 -0
  58. package/assets/vendor/mathjax-fonts/mathjax-tex-font/package.json +88 -0
  59. package/assets/vendor/paged.polyfill.js +33251 -0
  60. package/bin/mdpreview.js +8 -0
  61. package/bin/pageproof.js +8 -0
  62. package/package.json +42 -0
  63. package/src/assets.js +246 -0
  64. package/src/cli.js +166 -0
  65. package/src/lifecycle.js +445 -0
  66. package/src/pandoc.js +346 -0
  67. package/src/server.js +228 -0
  68. package/src/util.js +43 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Damon Wischik
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,90 @@
1
+ # mdpreview
2
+
3
+ `mdpreview` opens a live, paginated browser preview for a Markdown document. It
4
+ uses Pandoc for Markdown and citeproc citations, then uses Paged.js
5
+ in the browser to render paginated output including footnotes. (Pandoc must be installed.)
6
+
7
+ If all you want is to view a simple Markdown document, it's enough to use a browser extension
8
+ such as [Markdown Viewer](https://github.com/simov/markdown-viewer#table-of-contents).
9
+ This tool is useful if you want paginated output or citations, which many Markdown viewers don't handle.
10
+
11
+ Markdown can include scripts, so only preview Markdown you trust!
12
+
13
+ ## Installation and usage
14
+
15
+ ```sh
16
+ npm install -g mdpreview
17
+
18
+ # install as a skill for codex
19
+ mkdir -p ~/.agents/skills/mdpreview && mdpreview --show-skill > ~/.agents/skills/mdpreview/SKILL.md
20
+
21
+ # install as a skill for Claude Code
22
+ mkdir -p ~/.claude/skills/mdpreview && mdpreview --show-skill > ~/.claude/skills/mdpreview/SKILL.md
23
+ ```
24
+
25
+ ## Usage
26
+
27
+ This tool is designed to be usable by AI coding agents. Just say "Please start a live preview of <yourfile.md>" and it
28
+ should work.
29
+ If there are errors in the document the preview will show them, and make the background pink; you can ask the agent "Please fix the errors in my document"
30
+ and it should know what to do.
31
+
32
+ To use it at the command line,
33
+
34
+ ```sh
35
+ mdpreview FILE.md
36
+ mdpreview --style=doublespaced --citations=chicago FILE.md
37
+ mdpreview --styles
38
+ ```
39
+
40
+ It will start up a browser viewing the compiled document. When the user
41
+ closes the browser, `mdpreview` will automatically shut down.
42
+
43
+
44
+ ## Document and citation styles
45
+
46
+ **Document styles** are applied as an ordered cascade. Any base styles are applied
47
+ first, then each `--style=NAME` option is appended in command-line order.
48
+ The default base-style list consists of just one, `msword`.
49
+ Other bundled mix-in styles include `doublespaced`, and `numbered` for numbered section headings.
50
+ Thus, for example, to get double-spaced output, use
51
+ ```sh
52
+ mdpreview --style=doublespaced FILE.md
53
+ ```
54
+
55
+ **Citations** are handled by Pandoc. Your markdown document should include front-matter such as
56
+ ```
57
+ ---
58
+ title: My Document
59
+ bibliography: myrefs.bib
60
+ ---
61
+ ```
62
+ and then you can cite using `[@citeref]`. To choose the citation format, use e.g.
63
+ ```sh
64
+ mdpreview --citations=chicago FILE.md
65
+ ```
66
+ Available citation formats are listed by `mdpreview --styles`.
67
+
68
+ ## Configuration
69
+
70
+ Add CSS stylesheets or CSL bibliography styles to `~/.mdpreview/`. They will be included
71
+ in the `mdpreview --styles` list, and you can select them with `--style` or `--citations`.
72
+ In the case of name conflict, user-provided files take precedence over the built-in styles.
73
+
74
+ To specify the default document styles and citation style, specify the configuration
75
+ in `~/.mdpreview/config.yaml`:
76
+ ```yaml
77
+ styles: [msword]
78
+ citations: european-journal-of-international-law
79
+ ```
80
+
81
+ ## Third party notices
82
+
83
+ See [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md) for a list of bundled
84
+ third-party components: CSL styles, MathJax, and Paged.js.
85
+
86
+ ## WSL note
87
+
88
+ If running under WSL, it's a good idea to keep your markdown file on the WSL filesystem
89
+ rather than under `/mnt/c`. Apparently, watching files for changes is more reliable
90
+ when they're stored under WSL, though I can't confirm this myself.
@@ -0,0 +1,74 @@
1
+ # Third-Party Notices
2
+
3
+ This project includes third-party assets. The project source code is licensed
4
+ under the license stated in `LICENSE`; the assets below remain
5
+ under their own licenses.
6
+
7
+ ## Paged.js
8
+
9
+ - File: `assets/vendor/paged.polyfill.js`
10
+ - Project: Paged.js
11
+ - Version: 0.4.3
12
+ - Source: https://gitlab.coko.foundation/pagedjs/pagedjs
13
+ - Package reference: https://www.npmjs.com/package/pagedjs
14
+ - License: MIT
15
+
16
+ The vendored browser bundle includes its upstream license banner. Paged.js and
17
+ its bundled dependencies remain under their respective upstream notices. Notices
18
+ observed in the bundle include:
19
+
20
+ - CSS.escape v1.5.1-derived code by Mathias Bynens, MIT License.
21
+ - css-tree 1.1.3 by Roman Dvornov, MIT License.
22
+ - source-map code, copyright 2011 Mozilla Foundation and contributors,
23
+ BSD 3-Clause License.
24
+ - Base64 VLQ code derived from Closure Compiler, copyright 2011 The Closure
25
+ Compiler Authors, BSD 3-Clause License.
26
+
27
+ ## MathJax
28
+
29
+ - Files: `assets/vendor/mathjax/`, `assets/vendor/mathjax-fonts/`
30
+ - Project: MathJax
31
+ - Component package: `mathjax`
32
+ - Font package: `@mathjax/mathjax-tex-font`
33
+ - Version: 4.1.2
34
+ - Source: https://github.com/mathjax/MathJax
35
+ - Font source: https://github.com/mathjax/MathJax-fonts
36
+ - License: Apache License 2.0
37
+ - License copies: `assets/vendor/mathjax/LICENSE`,
38
+ `assets/vendor/mathjax-fonts/LICENSE`
39
+
40
+ The bundled files are bit-identical to upstream, except that the component
41
+ bundle `assets/vendor/mathjax/tex-mml-chtml-nofont.js` carries a prepended
42
+ Apache 2.0 copyright banner; the JavaScript code below the banner is
43
+ unmodified.
44
+
45
+ ## CSL Chicago Notes And Bibliography Style
46
+
47
+ - File: `assets/chicago.csl`
48
+ - Style: Chicago Manual of Style 18th edition (notes and bibliography)
49
+ - Upstream file: `chicago-notes-bibliography.csl`
50
+ - Project: Citation Style Language styles
51
+ - Source: https://github.com/citation-style-language/styles
52
+ - Project site: https://citationstyles.org/
53
+ - Retrieved: 2026-05-12
54
+ - License: Creative Commons Attribution-ShareAlike 3.0 Unported
55
+ - License URL: https://creativecommons.org/licenses/by-sa/3.0/
56
+
57
+ This package redistributes the CSL style with its upstream metadata preserved,
58
+ including the author, links, summary, update timestamp, and rights statement.
59
+
60
+ ## CSL European Journal Of International Law Style
61
+
62
+ - File: `assets/european-journal-of-international-law.csl`
63
+ - Style: European Journal of International Law
64
+ - Upstream file: `european-journal-of-international-law.csl`
65
+ - Project: Citation Style Language styles
66
+ - Source: https://github.com/citation-style-language/styles
67
+ - Project site: https://citationstyles.org/
68
+ - Retrieved: 2026-05-12
69
+ - License: Creative Commons Attribution-ShareAlike 3.0 Unported
70
+ - License URL: https://creativecommons.org/licenses/by-sa/3.0/
71
+
72
+ This package redistributes the CSL style with its upstream metadata preserved,
73
+ including the author, contributor, links, summary, update timestamp, and
74
+ rights statement.
@@ -0,0 +1,58 @@
1
+ ---
2
+ name: mdpreview
3
+ description: Use to open a live browser preview of a Markdown document, especially when the user wants to see it paginated and with citations and footnotes. Do not use for one-off Markdown-to-PDF conversion.
4
+ ---
5
+
6
+ # mdpreview
7
+
8
+ `mdpreview` is a CLI tool that opens a live, paginated browser preview of a Markdown
9
+ file. It handles footnotes and citations, and reloads automatically when the source file changes.
10
+
11
+ ## Opening a preview
12
+
13
+ Use this skill when the user asks to preview a Markdown document.
14
+ Always invoke in detached mode so the shell returns once the preview is up:
15
+ ```sh
16
+ mdpreview --detached "FILE.md"
17
+ ```
18
+ It will launch a browser tab and start an HTTP server
19
+ on a random localhost port. It will also print a status URL.
20
+
21
+ If the user asks about errors in the document, fetch this printed status URL:
22
+ ```sh
23
+ curl http://localhost:<port>/status.json
24
+ ```
25
+ The status includes Pandoc warnings and errors for the current document.
26
+
27
+ ## Styles
28
+
29
+ To choose a different document style, for example double-spaced output:
30
+ ```sh
31
+ mdpreview --detached --style=doublespaced FILE.md
32
+ ```
33
+
34
+ Use this to list available styles:
35
+ ```sh
36
+ mdpreview --styles
37
+ ```
38
+
39
+ There are
40
+ also options to specify the citation format. Use the CLI's `--citations` option
41
+ when the user asks for a specific citation style.
42
+
43
+ ## Permissions and lifecycle
44
+
45
+ `mdpreview` launches a browser tab and binds an HTTP server on a random localhost
46
+ port. Under WSL the browser is opened via `cmd.exe`.
47
+
48
+ The sandbox must permit spawning the browser opener and making localhost HTTP
49
+ requests. If either action is blocked, request approval/escalation with a short
50
+ justification rather than treating the denial as a document or CLI bug.
51
+
52
+ The server should automatically shut down when the user closes the browser tab.
53
+ To check on the health of the server, either monitor the server's PID
54
+ (which is printed on startup), or fetch `/status.json` which reports whether
55
+ a browser is currently attached. To terminate the server, kill the printed PID:
56
+ ```sh
57
+ kill <PID>
58
+ ```
@@ -0,0 +1,82 @@
1
+ /* mdpreview-style: Page geometry, Paged.js support, footnote mechanics, and preview chrome. */
2
+ :root {
3
+ color: black;
4
+ background: #F0F0F0;
5
+ }
6
+
7
+ body {
8
+ margin: 0;
9
+ background: #F0F0F0;
10
+ }
11
+
12
+ @counter-style mdpreview-metadata-symbols {
13
+ system: fixed;
14
+ symbols: "*" "\2020" "\2021" "\00A7" "\2016" "\00B6";
15
+ suffix: "";
16
+ fallback: decimal;
17
+ }
18
+
19
+ .pagedjs_pages {
20
+ display: flex;
21
+ flex-direction: column;
22
+ align-items: center;
23
+ gap: 14pt;
24
+ padding: 18pt 0;
25
+ margin: 0 auto;
26
+ }
27
+
28
+ .pagedjs_page {
29
+ background: white;
30
+ box-shadow: 0 1.5pt 7.5pt rgba(0, 0, 0, 0.16);
31
+ }
32
+
33
+ body.mdpreview-has-diagnostics {
34
+ background: #ead4d9;
35
+ }
36
+
37
+ .mdpreview-empty-preview {
38
+ min-height: 100vh;
39
+ }
40
+
41
+ main.mdpreview-document {
42
+ margin: 0 auto;
43
+ }
44
+
45
+ @page {
46
+ size: A4;
47
+ margin: 72pt 72pt 72pt 72pt;
48
+
49
+ @bottom-center {
50
+ content: counter(page);
51
+ font-family: "Times New Roman", Times, serif;
52
+ font-size: 10pt;
53
+ color: gray;
54
+ }
55
+
56
+ @footnote {
57
+ border-top: 0.5pt solid gray;
58
+ padding-top: 4pt;
59
+ }
60
+ }
61
+
62
+ img {
63
+ max-width: 100%;
64
+ }
65
+
66
+ .footnote {
67
+ float: footnote;
68
+ }
69
+
70
+ [data-footnote-call]::after {
71
+ font-size: 8pt;
72
+ line-height: 1;
73
+ vertical-align: super;
74
+ }
75
+
76
+ [data-footnote-call].mdpreview-metadata-footnote::after {
77
+ content: counter(mdpreview-metadata-footnote, mdpreview-metadata-symbols) !important;
78
+ }
79
+
80
+ [data-footnote-marker].mdpreview-metadata-footnote::marker {
81
+ content: counter(mdpreview-metadata-footnote-marker, mdpreview-metadata-symbols) " " !important;
82
+ }