@awni/mdplus 0.0.0-stage → 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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Awni Altabaa
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 CHANGED
@@ -1,3 +1,178 @@
1
- # Temporary Holding Version
1
+ <p align="center"><img src="assets/icon.svg" width="96" alt="mdplus icon"></p>
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ # mdplus
4
+
5
+ Markdown, plus math, theorems, callouts, cross-references, citations and comments, rendered to
6
+ one self-contained HTML page in a fraction of a second.
7
+
8
+ <p align="center"><img src="docs/images/demo-vscode.gif" width="720" alt="Typing a note in VS Code: the mdplus preview beside it updates as you type, with a numbered theorem, cross-references, a citation and hover tips"></p>
9
+
10
+ ## Why I made this
11
+
12
+ I like having simple Markdown notes in my projects, both for myself and as persistent
13
+ information for agents working in the project. But raw Markdown is missing some important
14
+ features I need to produce nice-looking, rich, interactive documents. Projects like Quarto
15
+ have these features, but they are too slow and clunky. `mdplus` is a tool I created for
16
+ myself to produce nice-looking, customizable documents from Markdown, while being fast and
17
+ lightweight.
18
+
19
+ ## Speed
20
+
21
+ On a typical note (300 lines, about 250 math expressions, theorems, references and
22
+ citations):
23
+
24
+ | | mdplus | Quarto |
25
+ |---|---:|---:|
26
+ | Render from the command line | 0.18 s | 2.5 s |
27
+ | Live update after a save | 0.08 s | 1.0 s |
28
+ | Output | 1 file, works offline | 13 files, needs CDNs |
29
+
30
+ On a 3,000-line note, a live update takes 0.25 s against 5.5 s. Method and full results:
31
+ [docs/benchmarks.md](docs/benchmarks.md).
32
+
33
+ The same note in both live previews, with the same four saves (the Quarto copy is translated
34
+ from the note on each save):
35
+
36
+ <p align="center"><img src="docs/images/demo-vs-quarto.gif" width="720" alt="Side by side: the note in VS Code, the mdplus serve page and the quarto preview page; after each save mdplus updates at once while Quarto re-renders over a few seconds"></p>
37
+
38
+ ## Install
39
+
40
+ Requires Node 20 or later.
41
+
42
+ ```bash
43
+ npm i -g @awni/mdplus
44
+ ```
45
+
46
+ All libraries are bundled at build time, so the installed tool has no dependencies.
47
+
48
+ **From source** (for development, and for the agent skill below):
49
+
50
+ ```bash
51
+ git clone https://github.com/Awni00/mdplus && cd mdplus && npm install && npm i -g .
52
+ ```
53
+
54
+ **VS Code.** The extension adds mdplus to VS Code's built-in Markdown preview (scroll sync and
55
+ live updates included), and has its own preview panel showing the full page, where you can
56
+ also comment. It ships with the package, so it always matches your version of mdplus:
57
+
58
+ ```bash
59
+ mdplus vscode
60
+ ```
61
+
62
+ Run it again after an upgrade. For another editor, name its command: `mdplus vscode --editor cursor`.
63
+ Details are in [vscode/README.md](vscode/README.md).
64
+
65
+ **Claude Code.** An agent skill for writing and checking notes is in
66
+ [skill/mdplus](skill/mdplus/SKILL.md). From a clone, link it into your skills folder:
67
+
68
+ ```bash
69
+ ln -s "$PWD/skill/mdplus" ~/.claude/skills/mdplus
70
+ ```
71
+
72
+ ## Use
73
+
74
+ ```bash
75
+ mdplus render note.md # → note.html, one self-contained file
76
+ mdplus serve note.md # live preview; updates in place on save; select text to comment
77
+ mdplus check notes/ # errors with file:line; exit 1 if any; writes nothing
78
+ mdplus comments note.md # the comment threads, with their lines
79
+ mdplus config note.md # the settings that apply and where each comes from
80
+ mdplus vscode # install or update the VS Code extension
81
+ ```
82
+
83
+ `-o out.html` picks the output file, and `--set key=value` overrides a setting (e.g.
84
+ `--set toc=true`); `mdplus --help` lists the rest.
85
+
86
+ ## Syntax
87
+
88
+ GitHub-flavoured Markdown, plus:
89
+
90
+ ````markdown
91
+ ---
92
+ title: Gradient descent
93
+ bibliography: refs.bib
94
+ ---
95
+
96
+ ::: theorem (Descent lemma) {#thm:descent}
97
+ If $f$ is $L$-smooth and $\eta \le 1/L$, then
98
+ $$ f(x - \eta \nabla f(x)) \le f(x) - \tfrac{\eta}{2} \|\nabla f(x)\|^2. $$ {#eq:descent}
99
+ :::
100
+
101
+ ::: proof
102
+ Expand $f$ around $x$ ...
103
+ :::
104
+
105
+ By @thm:descent and [-@eq:descent], the loss decreases [see @nesterov, ch. 2].
106
+
107
+ > [!tip] Choosing the step size
108
+ > Any $\eta \le 1/L$ works.
109
+ ````
110
+
111
+ <picture>
112
+ <source media="(prefers-color-scheme: dark)" srcset="docs/images/example-dark.png">
113
+ <img src="docs/images/example-light.png" width="640" alt="The example rendered by mdplus: a numbered theorem with a labelled equation, a proof, linked references and a citation, a tip callout and the reference list">
114
+ </picture>
115
+
116
+ - **Math:** `$...$` and `$$...$$`, typeset at build time with KaTeX.
117
+ - **Theorem-like blocks:** theorem, lemma, definition, proof, remark and others, numbered.
118
+ - **References**, in cleveref style: `@thm:descent` → "Theorem 1",
119
+ `[@thm:a; @lem:b]` → "Theorem 1 and Lemma 2".
120
+ - **Citations** from BibTeX: author-year or numbered. Hovering a citation or reference shows
121
+ the entry or the block.
122
+ - **Callouts** in Obsidian/GitHub style, with custom kinds from the config.
123
+ - **Comments** in CriticMarkup: `{==text==}{>>@you: a comment<<}` (see [Comments](#comments)).
124
+ - **Also:** figures and tables with captions, footnotes, task lists, a table of contents, and
125
+ code highlighting.
126
+
127
+ The full syntax is in [skill/mdplus/SKILL.md](skill/mdplus/SKILL.md).
128
+
129
+ ## Comments
130
+
131
+ Comments let you and an agent discuss a specific place in a note. They are written in the
132
+ source, in [CriticMarkup](https://criticmarkup.com), so both of you read and write them there:
133
+
134
+ ```markdown
135
+ a bound that {==holds for every $n$==}{>>@you: Say "non-asymptotic"?<<}{>>@claude: Agreed, changed.<<}
136
+ ```
137
+
138
+ - **Shown** as a highlight with the thread on a card: in the right margin on a wide page, below
139
+ the paragraph on a narrow one. A comment alone, `{>>@you: ...<<}`, marks a point.
140
+ - **Added** in three ways, all writing the same syntax:
141
+ - on a page shown by `mdplus serve`, or in the VS Code preview panel: select text and press
142
+ **Comment**; a card has **Reply** and **Resolve**;
143
+ - in the VS Code editor: **mdplus: Add comment** (`Cmd+Alt+M` / `Ctrl+Alt+M`);
144
+ - by typing it.
145
+ - **Listed** by `mdplus comments note.md`, with file and line, which is how an agent finds what
146
+ to answer.
147
+ - **Resolved** by deleting the thread; the highlighted text stays.
148
+ - **Hidden** for a clean page with `comments: hide` in the config, or `--set comments=hide`.
149
+
150
+ ## Configuration
151
+
152
+ None is needed to start. The nearest `.mdplus/config.yaml` (or `mdplus.yaml`) above a note
153
+ applies to it:
154
+
155
+ ```yaml
156
+ macros: { sty: [tex/macros.sty] } # your LaTeX macros, read from .sty files
157
+ bibliography: tex/refs.bib
158
+ numbering: { sections: true } # Theorem 2.1, Equation (2.3)
159
+ toc: true
160
+ ```
161
+
162
+ Macros are read from `.sty` files: `\newcommand`, `\def`, `\DeclareMathOperator`,
163
+ `\DeclarePairedDelimiter`, and xparse `\NewDocumentCommand` with starred and optional
164
+ arguments. Front matter and `--set key=value` override the config for one note.
165
+
166
+ ## Develop
167
+
168
+ ```bash
169
+ npm test # golden files, check and unit tests, VS Code plugin, speed budgets
170
+ UPDATE=1 npm test # rewrite the golden HTML after an intended change
171
+ ```
172
+
173
+ Design and decisions: [docs/design.md](docs/design.md). How the demo clips are recorded:
174
+ [demo/README.md](demo/README.md).
175
+
176
+ ## Licence
177
+
178
+ [MIT](LICENSE).
package/dist/base.css ADDED
@@ -0,0 +1,213 @@
1
+ /* mdplus base stylesheet. A theme overrides the variables below (or adds rules).
2
+ Light is the default; dark applies when the system prefers it (unless the reader chose
3
+ light) or when the toggle sets data-theme="dark". */
4
+ :root {
5
+ color-scheme: light;
6
+ --bg: #fdfcf9;
7
+ --fg: #1d1d1f;
8
+ --muted: #6b6f76;
9
+ --rule: #dedbd3;
10
+ --accent: #3b5bab;
11
+ --code-bg: #f1efe9;
12
+ --font-body: "Charter", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
13
+ --font-ui: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Segoe UI", sans-serif;
14
+ --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
15
+ --width: 44rem;
16
+ --c-note: #3b6fd1; --c-tip: #2b8a5b; --c-important: #7a5bd1; --c-warning: #b7791f; --c-caution: #c53b3b;
17
+ --tok-keyword: #a1356f; --tok-string: #2f7a3d; --tok-number: #9a5b13; --tok-comment: #8a8d93;
18
+ --tok-title: #3b5bab; --tok-type: #7a5bd1; --tok-meta: #6b6f76;
19
+ --icon-sun: none; --icon-moon: block;
20
+ }
21
+ @media (prefers-color-scheme: dark) {
22
+ :root:not([data-theme="light"]) {
23
+ color-scheme: dark;
24
+ --bg: #1b1c1f; --fg: #e6e4df; --muted: #9da0a7; --rule: #3a3c42; --accent: #8fa8e8; --code-bg: #26272b;
25
+ --c-note: #7ea3ee; --c-tip: #5cc28d; --c-important: #a98ff0; --c-warning: #e0a84a; --c-caution: #ee7d7d;
26
+ --tok-keyword: #e48fbd; --tok-string: #8fcf8f; --tok-number: #e5b16b; --tok-comment: #80848c;
27
+ --tok-title: #8fa8e8; --tok-type: #b8a2f2; --tok-meta: #9da0a7;
28
+ --icon-sun: block; --icon-moon: none;
29
+ }
30
+ }
31
+ :root[data-theme="dark"] {
32
+ color-scheme: dark;
33
+ --bg: #1b1c1f; --fg: #e6e4df; --muted: #9da0a7; --rule: #3a3c42; --accent: #8fa8e8; --code-bg: #26272b;
34
+ --c-note: #7ea3ee; --c-tip: #5cc28d; --c-important: #a98ff0; --c-warning: #e0a84a; --c-caution: #ee7d7d;
35
+ --tok-keyword: #e48fbd; --tok-string: #8fcf8f; --tok-number: #e5b16b; --tok-comment: #80848c;
36
+ --tok-title: #8fa8e8; --tok-type: #b8a2f2; --tok-meta: #9da0a7;
37
+ --icon-sun: block; --icon-moon: none;
38
+ }
39
+
40
+ * { box-sizing: border-box; }
41
+ html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
42
+ body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--font-body); font-size: 17px; line-height: 1.65; }
43
+
44
+ /* Layout: one centred column; with a ToC, a sticky sidebar on wide screens. */
45
+ .layout { max-width: var(--width); margin: 0 auto; padding: 2.5rem 16px 4rem; }
46
+ .layout > main { min-width: 0; }
47
+ /* The text stays centred as without a ToC; the ToC sits in the left margin next to it (11 to 14rem
48
+ wide), and the text moves right only when that margin is too narrow. The empty right column and
49
+ gap keep equation numbers off the window edge and clear of the theme toggle. */
50
+ .layout.with-toc {
51
+ max-width: none; display: grid; grid-template-columns: minmax(11rem, 1fr) minmax(0, var(--width)) minmax(0, 1fr);
52
+ grid-template-areas: "toc header ." "toc main ."; grid-template-rows: auto 1fr; column-gap: 2.5rem; padding: 0 1.5rem 4rem;
53
+ }
54
+ .with-toc > .title-block { grid-area: header; padding-top: 2.5rem; }
55
+ .with-toc > main { grid-area: main; }
56
+ .with-toc > .toc { grid-area: toc; justify-self: end; width: 100%; max-width: 14rem; }
57
+
58
+ .theme-toggle {
59
+ position: fixed; top: 12px; right: 12px; z-index: 10; display: grid; place-items: center; width: 34px; height: 34px; padding: 0;
60
+ border: 1px solid var(--rule); border-radius: 8px; background: var(--bg); color: var(--muted); cursor: pointer;
61
+ }
62
+ .theme-toggle:hover { color: var(--fg); }
63
+ .theme-toggle .icon-sun { display: var(--icon-sun); }
64
+ .theme-toggle .icon-moon { display: var(--icon-moon); }
65
+
66
+ /* Title block. */
67
+ .title-block { margin-bottom: 2rem; padding-bottom: 1rem; border-bottom: 1px solid var(--rule); }
68
+ .title-block .title { margin: 0; padding: 0; border: 0; font-size: 1.75rem; }
69
+ .subtitle { margin: 0.4rem 0 0; font-size: 1.1rem; color: var(--muted); }
70
+ .byline { margin: 0.6rem 0 0; font-family: var(--font-ui); font-size: 0.85rem; color: var(--muted); }
71
+
72
+ h1, h2, h3, h4, h5 { font-family: var(--font-ui); line-height: 1.25; margin: 2rem 0 0.75rem; }
73
+ h1 { font-size: 1.5rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; } h4, h5 { font-size: 1rem; }
74
+ main > :first-child { margin-top: 0; }
75
+ h1[id], h2[id], h3[id], h4[id] { scroll-margin-top: 1.5rem; }
76
+ .sec-num { margin-right: 0.6em; color: var(--muted); font-variant-numeric: tabular-nums; }
77
+ p { margin: 0.8rem 0; }
78
+ a { color: var(--accent); }
79
+ hr { border: 0; border-top: 1px solid var(--rule); margin: 2rem 0; }
80
+ ul, ol { padding-left: 1.5rem; }
81
+ li { margin: 0.3rem 0; }
82
+ li.task { list-style: none; margin-left: -1.3rem; }
83
+ li.task input { margin: 0 0.4rem 0 0; vertical-align: -0.1em; accent-color: var(--accent); }
84
+ blockquote { margin: 1rem 0; padding: 0 1rem; border-left: 3px solid var(--rule); color: var(--muted); }
85
+ img { max-width: 100%; height: auto; }
86
+ details > summary { cursor: pointer; }
87
+ code { font-family: var(--font-mono); font-size: 0.86em; background: var(--code-bg); padding: 0.1em 0.3em; border-radius: 4px; }
88
+ pre { background: var(--code-bg); padding: 0.8rem 1rem; border-radius: 6px; overflow-x: auto; line-height: 1.5; }
89
+ pre code { background: none; padding: 0; font-size: 0.84rem; }
90
+
91
+ /* Tables: booktabs style. A table whose top-left header cell is empty treats its first column as row labels. */
92
+ table { border-collapse: collapse; margin: 1.4rem 0; width: 100%; font-size: 0.92rem; line-height: 1.45; font-variant-numeric: tabular-nums; }
93
+ th, td { padding: 0.5rem 0.75rem; border: 0; border-bottom: 1px solid var(--rule); text-align: left; vertical-align: top; }
94
+ th:first-child, td:first-child { padding-left: 0; }
95
+ th:last-child, td:last-child { padding-right: 0; }
96
+ thead th { font-family: var(--font-ui); font-size: 0.78rem; font-weight: 600; letter-spacing: 0.02em; border-top: 1.5px solid var(--fg); border-bottom: 1px solid var(--fg); }
97
+ tbody tr:last-child td { border-bottom: 1.5px solid var(--fg); }
98
+ table:has(thead th:first-child:empty) tbody td:first-child { font-family: var(--font-ui); font-size: 0.78rem; font-weight: 600; color: var(--muted); white-space: nowrap; padding-top: 0.62rem; }
99
+ @media (max-width: 640px) { table { display: block; overflow-x: auto; width: auto; } }
100
+
101
+ /* Figures and table captions. */
102
+ figure { margin: 1.6rem 0; }
103
+ figure.figure { text-align: center; }
104
+ figure.figure img { display: block; margin: 0 auto; }
105
+ figcaption { font-size: 0.92rem; color: var(--muted); line-height: 1.5; margin-top: 0.6rem; text-align: left; }
106
+ figure.figure figcaption { text-align: center; }
107
+ figure.table figcaption { margin: 0 0 -0.6rem; }
108
+ .fig-label { font-weight: 700; color: var(--fg); }
109
+
110
+ /* Math. */
111
+ .math-display { display: block; margin: 1rem 0; overflow-x: auto; overflow-y: hidden; padding: 0.15rem 0; }
112
+ .katex { font-size: 1.08em; }
113
+ .katex-display { margin: 0; }
114
+ .katex-error { color: #d93025 !important; }
115
+
116
+ /* Theorem-like blocks: a thin left rule, no fill; theorem-like results use the accent colour,
117
+ definitions and remarks a neutral rule; proofs no rule and a tombstone at the end. */
118
+ .env { margin: 1.4rem 0; padding: 0.1rem 0 0.1rem 1rem; border-left: 2px solid var(--rule); }
119
+ .env > :first-child { margin-top: 0; }
120
+ .env > :last-child { margin-bottom: 0; }
121
+ .env-head { font-weight: 700; }
122
+ .env-title { font-weight: 400; }
123
+ .env-theorem, .env-lemma, .env-proposition, .env-corollary, .env-claim, .env-conjecture { border-left-color: var(--accent); }
124
+ .env-theorem > p, .env-lemma > p, .env-proposition > p, .env-corollary > p, .env-claim > p, .env-conjecture > p { font-style: italic; }
125
+ .env-theorem .env-head, .env-lemma .env-head, .env-proposition .env-head, .env-corollary .env-head, .env-claim .env-head, .env-conjecture .env-head { font-style: normal; }
126
+ .env-proof { border-left: 0; padding-left: 0; }
127
+ .env-proof > .env-head, .env-proof > p > .env-head { font-style: italic; font-weight: 400; }
128
+ .env-proof > p:last-child::after { content: "\220E"; float: right; color: var(--muted); }
129
+ .env-proof:not(:has(> p:last-child))::after { content: "\220E"; display: block; text-align: right; color: var(--muted); margin-top: -0.4rem; }
130
+ .env-intuition, .env-note { border-left-style: dashed; }
131
+ .env .env { margin: 1rem 0; }
132
+
133
+ /* Callouts (Obsidian syntax; GitHub alert types built in). */
134
+ .callout { --callout: var(--c-note); margin: 1.2rem 0; padding: 0.55rem 0.9rem; border-left: 3px solid var(--callout);
135
+ background: color-mix(in srgb, var(--callout) 7%, transparent); border-radius: 0 6px 6px 0; }
136
+ .callout-tip { --callout: var(--c-tip); } .callout-important { --callout: var(--c-important); }
137
+ .callout-warning { --callout: var(--c-warning); } .callout-caution { --callout: var(--c-caution); }
138
+ .callout-title { display: flex; align-items: center; gap: 0.45rem; font-family: var(--font-ui); font-size: 0.9rem; font-weight: 600; color: var(--callout); }
139
+ .callout-title svg { flex: none; }
140
+ summary.callout-title { list-style: none; }
141
+ summary.callout-title::-webkit-details-marker { display: none; }
142
+ summary.callout-title::after { content: "\203A"; margin-left: auto; font-size: 1.2rem; line-height: 1; transition: transform 0.15s; }
143
+ details.callout[open] > summary.callout-title::after { transform: rotate(90deg); }
144
+ .callout-body > :first-child { margin-top: 0.35rem; }
145
+ .callout-body > :last-child { margin-bottom: 0.1rem; }
146
+ .callout-body:empty { display: none; }
147
+
148
+ /* References and citations. */
149
+ /* Hover, keyboard focus and an open tooltip (aria-describedby, set by tips.js) tint the link;
150
+ the padding is offset by the margin, so the text does not move. */
151
+ a.ref, a.cite { text-decoration: none; white-space: nowrap; padding: 0 2px; margin: 0 -2px; border-radius: 3px; }
152
+ a.ref:hover, a.cite:hover, a.ref:focus-visible, a.cite:focus-visible, a.ref[aria-describedby], a.cite[aria-describedby] {
153
+ background: color-mix(in srgb, var(--accent) 12%, transparent);
154
+ }
155
+ .ref-missing { color: #d93025; font-weight: 600; }
156
+ .references { margin-top: 2.5rem; }
157
+ .references-title { font-size: 1.1rem; }
158
+ ol.bib { padding-left: 0; list-style: none; font-size: 0.92rem; }
159
+ ol.bib li { margin: 0.5rem 0; padding-left: 1.5rem; text-indent: -1.5rem; }
160
+ ol.bib-numbered li { padding-left: 2rem; text-indent: -2rem; }
161
+ ol.bib-numbered li::before { content: "[" attr(data-n) "]"; display: inline-block; width: 2rem; text-indent: 0; color: var(--muted); }
162
+
163
+ /* Footnotes. */
164
+ .footnotes-sep { margin-top: 2.5rem; }
165
+ .footnotes { font-size: 0.9rem; color: var(--muted); }
166
+ .footnote-ref a, .footnote-backref { text-decoration: none; }
167
+
168
+ /* Code tokens (highlight.js classes). */
169
+ .hljs-keyword, .hljs-selector-tag, .hljs-literal, .hljs-built_in { color: var(--tok-keyword); }
170
+ .hljs-string, .hljs-regexp, .hljs-addition, .hljs-attribute { color: var(--tok-string); }
171
+ .hljs-number, .hljs-symbol, .hljs-bullet, .hljs-variable, .hljs-template-variable { color: var(--tok-number); }
172
+ .hljs-comment, .hljs-quote, .hljs-deletion { color: var(--tok-comment); font-style: italic; }
173
+ .hljs-title, .hljs-section, .hljs-name, .hljs-attr { color: var(--tok-title); }
174
+ .hljs-type, .hljs-params, .hljs-class .hljs-title { color: var(--tok-type); }
175
+ .hljs-meta, .hljs-tag, .hljs-punctuation { color: var(--tok-meta); }
176
+ .hljs-emphasis { font-style: italic; } .hljs-strong { font-weight: 700; }
177
+
178
+ /* Table of contents. */
179
+ .toc { position: sticky; top: 0; align-self: start; max-height: 100vh; overflow-y: auto; padding: 2.75rem 0 2rem;
180
+ font-family: var(--font-ui); font-size: 0.84rem; line-height: 1.4; }
181
+ .toc-label { padding-left: 0.7rem; margin-bottom: 0.5rem; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
182
+ .toc ol { list-style: none; margin: 0; padding: 0; }
183
+ .toc li { margin: 0; }
184
+ .toc a { display: block; padding: 0.25rem 0.7rem; border-left: 2px solid var(--rule); color: var(--muted); text-decoration: none; }
185
+ .toc a:hover { color: var(--fg); }
186
+ .toc a.active { color: var(--fg); border-left-color: var(--accent); }
187
+ .toc-l1 a { padding-left: 1.6rem; }
188
+ /* Numbered entries hang: a wrapped line lines up with the title, not the number. */
189
+ .toc a:has(> .sec-num) { padding-left: calc(0.7rem + 1.75em); text-indent: -1.75em; }
190
+ .toc-l1 a:has(> .sec-num) { padding-left: calc(1.6rem + 2.2em); text-indent: -2.2em; }
191
+ .toc .sec-num { display: inline-block; min-width: 1.3em; margin-right: 0.45em; text-indent: 0; }
192
+ .toc-l1 .sec-num { min-width: 1.75em; }
193
+ .toc .katex { font-size: 1em; }
194
+ @media (max-width: 960px) {
195
+ .layout.with-toc { display: block; padding: 0 16px 4rem; max-width: var(--width); }
196
+ .toc, .with-toc > .toc { position: static; max-height: none; max-width: none; padding: 0 0 0.5rem; }
197
+ .toc ol { padding: 0.4rem 0; border: 1px solid var(--rule); border-radius: 6px; }
198
+ .toc a { border-left: 0; }
199
+ .toc a.active { color: var(--muted); }
200
+ }
201
+
202
+ /* Print: no toggle or sidebar, no backgrounds, links in plain colour. */
203
+ @media print {
204
+ :root { --bg: #fff; --fg: #000; --code-bg: #f4f4f4; }
205
+ body { font-size: 11pt; }
206
+ .theme-toggle, .toc { display: none !important; }
207
+ .layout, .layout.with-toc { display: block; max-width: none; padding: 0; }
208
+ a { color: inherit; text-decoration: none; }
209
+ a.ref, a.cite { background: none; }
210
+ .callout { break-inside: avoid; }
211
+ pre, figure, .env, .math-display { break-inside: avoid; }
212
+ h1, h2, h3, h4 { break-after: avoid; }
213
+ }
package/dist/cli.js ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ import module from "node:module";
3
+ try { module.enableCompileCache?.(); } catch {}
4
+ await import("./main.js");
@@ -0,0 +1,55 @@
1
+ /* Comments (CriticMarkup); loaded only on pages that have them. A thread is a card: in the right
2
+ margin on wide pages, below its block otherwise (narrow pages, print, the VS Code preview).
3
+ Both copies are in the page; --cm-inline and --cm-block choose which one shows. */
4
+ :root {
5
+ --cm-w: 15rem; --cm-gap: 1.75rem;
6
+ --cm-hl: light-dark(#f5d76e59, #e0a84a3d); --cm-hl-on: light-dark(#f5d76eb8, #e0a84a85);
7
+ --cm-shadow: light-dark(0 1px 2px rgb(0 0 0 / 0.06), 0 1px 2px rgb(0 0 0 / 0.25));
8
+ --cm-shadow-on: light-dark(0 2px 4px rgb(0 0 0 / 0.07), 0 2px 4px rgb(0 0 0 / 0.25)), light-dark(0 8px 22px rgb(0 0 0 / 0.12), 0 10px 26px rgb(0 0 0 / 0.45));
9
+ }
10
+ mark.cm { background: var(--cm-hl); color: inherit; border-radius: 2px; padding: 0.08em 0; -webkit-box-decoration-break: clone; box-decoration-break: clone; transition: background 0.12s; }
11
+ mark.cm:hover, mark.cm:has(+ .cm-thread:hover) { background: var(--cm-hl-on); }
12
+ mark.cm-point { background: none; padding: 0; }
13
+ mark.cm-point::before { content: ""; display: inline-block; width: 0.45em; height: 0.45em; margin: 0 0.12em; border-radius: 50%; background: var(--cm-c); vertical-align: 0.55em; }
14
+ mark.cm-point:hover, mark.cm-point:has(+ .cm-thread:hover) { background: none; }
15
+ mark.cm-point:hover::before, mark.cm-point:has(+ .cm-thread:hover)::before { box-shadow: 0 0 0 3px var(--cm-hl-on); }
16
+
17
+ /* One colour per author (data-a, from the name); comments without an author are neutral. */
18
+ :where(.cm-thread, .cm-c, mark.cm-point) { --cm-c: var(--muted); }
19
+ [data-a="0"] { --cm-c: var(--c-note); } [data-a="1"] { --cm-c: var(--c-warning); } [data-a="2"] { --cm-c: var(--c-important); }
20
+ [data-a="3"] { --cm-c: var(--c-tip); } [data-a="4"] { --cm-c: var(--c-caution); }
21
+
22
+ .cm-thread {
23
+ display: var(--cm-inline, none); float: right; clear: right; width: var(--cm-w);
24
+ margin: 0 calc(-1 * (var(--cm-w) + var(--cm-gap) + var(--cm-x, 0px))) 0.5rem 0; padding: 0.5rem 0.7rem 0.55rem;
25
+ border: 1px solid var(--rule); border-left: 3px solid var(--cm-c); border-radius: 8px; background: var(--bg); box-shadow: var(--cm-shadow);
26
+ font: 400 13px/1.45 var(--font-ui); color: var(--fg); text-align: left; text-indent: 0; letter-spacing: normal; text-transform: none; white-space: normal;
27
+ transition: box-shadow 0.15s, border-color 0.15s;
28
+ }
29
+ .cm-thread:hover, mark.cm:hover + .cm-thread { box-shadow: var(--cm-shadow-on); border-color: color-mix(in srgb, var(--cm-c) 45%, var(--rule)); border-left-color: var(--cm-c); }
30
+ .cm-c { display: block; }
31
+ .cm-c + .cm-c { margin-top: 0.45rem; padding-top: 0.45rem; border-top: 1px solid var(--rule); }
32
+ .cm-by { display: block; margin-bottom: 1px; font-size: 11.5px; font-weight: 600; letter-spacing: 0.01em; color: var(--cm-c); }
33
+ .cm-below { display: var(--cm-block, block); margin: 0.5rem 0 1rem; }
34
+ .cm-below > .cm-thread { display: block; float: none; width: auto; margin: 0 0 0.5rem; }
35
+ /* Table cells have no margin of their own: their threads always go below the table. */
36
+ td .cm-thread, th .cm-thread { display: none; }
37
+ .cm-below-cell { display: block; }
38
+ /* Copies of a block elsewhere (ToC entries, tooltips) carry no comments. */
39
+ .toc .cm-thread, .mdplus-tip .cm-thread, .mdplus-tip .cm-below { display: none; }
40
+ .toc mark.cm { background: none; } .toc mark.cm-point { display: none; }
41
+
42
+ /* Blocks with padding on the right: keep their cards in the same margin column. */
43
+ .callout { --cm-x: 0.9rem; }
44
+ blockquote { --cm-x: 1rem; }
45
+
46
+ /* Wide screens: cards in the right margin. Without a ToC the text stays centred while the margin
47
+ has room for the cards, then moves left; with a ToC the right-hand grid column holds them. */
48
+ @media screen and (min-width: 64rem) {
49
+ .layout.has-cm:not(.with-toc) { --cm-inline: block; --cm-block: none; margin-right: max(var(--cm-w) + var(--cm-gap) + 1rem, (100% - var(--width)) / 2); }
50
+ }
51
+ @media screen and (min-width: 80rem) {
52
+ .layout.has-cm.with-toc { --cm-inline: block; --cm-block: none; grid-template-columns: minmax(11rem, 1fr) minmax(0, var(--width)) minmax(calc(var(--cm-w) + 0.5rem), 1fr); }
53
+ }
54
+ @media print { mark.cm { background: none; border-bottom: 1px solid var(--muted); } .cm-thread { box-shadow: none; break-inside: avoid; } }
55
+ @media (prefers-reduced-motion: reduce) { mark.cm, .cm-thread { transition: none; } }