9 files changed, +861, -7
541477aRender math in markdown using math-core
Cargo.lock
+192, -0
Cargo.toml
+10, -2
README.md
+3, -2
fonts/GUST-FONT-LICENSE.txt
+29, -0
fonts/lppl.txt
+416, -0
fonts/math-core-MIT.txt
+9, -0
src/markdown.rs
+95, -3
style.css
+107, -0
+192, -0
@@ -109,6 +109,18 @@ dependencies = [
109109 "crypto-common",
110110 ]
111111
112+[[package]]
113+name = "dtoa"
114+version = "1.0.11"
115+source = "registry+https://github.com/rust-lang/crates.io-index"
116+checksum = "4c3cf4824e2d5f025c7b531afcb2325364084a16806f6d47fbc1f5fbd9960590"
117+
118+[[package]]
119+name = "fastrand"
120+version = "2.5.0"
121+source = "registry+https://github.com/rust-lang/crates.io-index"
122+checksum = "da7c62ceae207dd37ea5b845da6a0696c799f85e97da1ab5b7910be3c1c80223"
123+
112124 [[package]]
113125 name = "find-msvc-tools"
114126 version = "0.1.13"
@@ -162,6 +174,18 @@ dependencies = [
162174 "log",
163175 ]
164176
177+[[package]]
178+name = "hashbrown"
179+version = "0.17.2"
180+source = "registry+https://github.com/rust-lang/crates.io-index"
181+checksum = "735eaa21a6a5ffb2e84362faaeb90c05ba8e19797ca30428478cb6ea3a4921bc"
182+
183+[[package]]
184+name = "heck"
185+version = "0.5.0"
186+source = "registry+https://github.com/rust-lang/crates.io-index"
187+checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
188+
165189 [[package]]
166190 name = "hybrid-array"
167191 version = "0.4.15"
@@ -222,6 +246,15 @@ dependencies = [
222246 "wasm-bindgen",
223247 ]
224248
249+[[package]]
250+name = "kstring"
251+version = "2.0.5"
252+source = "registry+https://github.com/rust-lang/crates.io-index"
253+checksum = "7a09b82a7f771ed02dc0dd9b27130a0fa5499fa15ed3027116c1e5e4e591bd9e"
254+dependencies = [
255+ "static_assertions",
256+]
257+
225258 [[package]]
226259 name = "libc"
227260 version = "0.2.189"
@@ -258,6 +291,43 @@ version = "0.4.34"
258291 source = "registry+https://github.com/rust-lang/crates.io-index"
259292 checksum = "f9f8bd3e56ce4dfc153cf470fffbfa98c7620958b312ca5c3a4b8d5181fd13c6"
260293
294+[[package]]
295+name = "math-core"
296+version = "0.9.0"
297+source = "registry+https://github.com/rust-lang/crates.io-index"
298+checksum = "1fbcfafbb044793948a288d2b20bc1cb7d6f07ac0a33232165b2e2e742082127"
299+dependencies = [
300+ "hashbrown",
301+ "kstring",
302+ "math-core-renderer-internal",
303+ "memchr",
304+ "phf",
305+ "rustc-hash",
306+ "serde",
307+ "static_assertions",
308+ "strum",
309+ "strum_macros",
310+]
311+
312+[[package]]
313+name = "math-core-renderer-internal"
314+version = "0.9.0"
315+source = "registry+https://github.com/rust-lang/crates.io-index"
316+checksum = "d2a232c604d4a08a856316ab2e608b884db7b141a36e60e1056911a48116f949"
317+dependencies = [
318+ "bitflags",
319+ "dtoa",
320+ "hashbrown",
321+ "kstring",
322+ "percent-encoding",
323+ "rustc-hash",
324+ "serde",
325+ "stable-arena",
326+ "static_assertions",
327+ "strum",
328+ "strum_macros",
329+]
330+
261331 [[package]]
262332 name = "memchr"
263333 version = "2.8.3"
@@ -279,6 +349,55 @@ version = "1.21.4"
279349 source = "registry+https://github.com/rust-lang/crates.io-index"
280350 checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
281351
352+[[package]]
353+name = "percent-encoding"
354+version = "2.3.2"
355+source = "registry+https://github.com/rust-lang/crates.io-index"
356+checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220"
357+
358+[[package]]
359+name = "phf"
360+version = "0.14.0"
361+source = "registry+https://github.com/rust-lang/crates.io-index"
362+checksum = "010378780309880b08997fae13be7834dba947d36393bd372f2b1556deb2a2f6"
363+dependencies = [
364+ "phf_macros",
365+ "phf_shared",
366+ "serde",
367+]
368+
369+[[package]]
370+name = "phf_generator"
371+version = "0.14.0"
372+source = "registry+https://github.com/rust-lang/crates.io-index"
373+checksum = "aeb62e0959d5a1bebc965f4d15d9e2b7cea002b6b0f5ba8cde6cc26738467100"
374+dependencies = [
375+ "fastrand",
376+ "phf_shared",
377+]
378+
379+[[package]]
380+name = "phf_macros"
381+version = "0.14.0"
382+source = "registry+https://github.com/rust-lang/crates.io-index"
383+checksum = "5fa8d0ca26d424d27630da600c6624696e7dec8bf7b3b492b383c5dc49e5e085"
384+dependencies = [
385+ "phf_generator",
386+ "phf_shared",
387+ "proc-macro2",
388+ "quote",
389+ "syn 2.0.119",
390+]
391+
392+[[package]]
393+name = "phf_shared"
394+version = "0.14.0"
395+source = "registry+https://github.com/rust-lang/crates.io-index"
396+checksum = "c6fd9027e2d9319be6349febd1db4e8d02aa544921200c9b777720ac34a3aa89"
397+dependencies = [
398+ "siphasher",
399+]
400+
282401 [[package]]
283402 name = "pin-project-lite"
284403 version = "0.2.17"
@@ -333,12 +452,48 @@ version = "6.0.0"
333452 source = "registry+https://github.com/rust-lang/crates.io-index"
334453 checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf"
335454
455+[[package]]
456+name = "rustc-hash"
457+version = "2.1.3"
458+source = "registry+https://github.com/rust-lang/crates.io-index"
459+checksum = "6b1e7f9a428571be2dc5bc0505c13fb6bf936822b894ec87abf8a08a4e51742d"
460+
336461 [[package]]
337462 name = "rustversion"
338463 version = "1.0.23"
339464 source = "registry+https://github.com/rust-lang/crates.io-index"
340465 checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f"
341466
467+[[package]]
468+name = "serde"
469+version = "1.0.229"
470+source = "registry+https://github.com/rust-lang/crates.io-index"
471+checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba"
472+dependencies = [
473+ "serde_core",
474+ "serde_derive",
475+]
476+
477+[[package]]
478+name = "serde_core"
479+version = "1.0.229"
480+source = "registry+https://github.com/rust-lang/crates.io-index"
481+checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48"
482+dependencies = [
483+ "serde_derive",
484+]
485+
486+[[package]]
487+name = "serde_derive"
488+version = "1.0.229"
489+source = "registry+https://github.com/rust-lang/crates.io-index"
490+checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348"
491+dependencies = [
492+ "proc-macro2",
493+ "quote",
494+ "syn 3.0.6",
495+]
496+
342497 [[package]]
343498 name = "sha2"
344499 version = "0.11.1"
@@ -356,12 +511,48 @@ version = "2.0.1"
356511 source = "registry+https://github.com/rust-lang/crates.io-index"
357512 checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba"
358513
514+[[package]]
515+name = "siphasher"
516+version = "1.0.4"
517+source = "registry+https://github.com/rust-lang/crates.io-index"
518+checksum = "33f4fe9184a62d842c9ef383018f3306d8ba224fd9d836f56d7288308847c256"
519+
359520 [[package]]
360521 name = "slab"
361522 version = "0.4.12"
362523 source = "registry+https://github.com/rust-lang/crates.io-index"
363524 checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5"
364525
526+[[package]]
527+name = "stable-arena"
528+version = "0.3.0"
529+source = "registry+https://github.com/rust-lang/crates.io-index"
530+checksum = "e016625b2c482bea7d5a301e88c75f40ffb2a3bc9c7f8bc16c68e05156fb6807"
531+
532+[[package]]
533+name = "static_assertions"
534+version = "1.1.0"
535+source = "registry+https://github.com/rust-lang/crates.io-index"
536+checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
537+
538+[[package]]
539+name = "strum"
540+version = "0.28.0"
541+source = "registry+https://github.com/rust-lang/crates.io-index"
542+checksum = "9628de9b8791db39ceda2b119bbe13134770b56c138ec1d3af810d045c04f9bd"
543+
544+[[package]]
545+name = "strum_macros"
546+version = "0.28.0"
547+source = "registry+https://github.com/rust-lang/crates.io-index"
548+checksum = "ab85eea0270ee17587ed4156089e10b9e6880ee688791d45a905f5b1ca36f664"
549+dependencies = [
550+ "heck",
551+ "proc-macro2",
552+ "quote",
553+ "syn 2.0.119",
554+]
555+
365556 [[package]]
366557 name = "syn"
367558 version = "2.0.119"
@@ -520,6 +711,7 @@ dependencies = [
520711 "chrono",
521712 "git2",
522713 "imagesize",
714+ "math-core",
523715 "pulldown-cmark",
524716 "sha2",
525717 ]
+10, -2
@@ -7,6 +7,14 @@ edition = "2024"
7 7 anyhow = "1.0.104"
8 8 chrono = "0.4.45"
9 9 git2 = "0.21.0"
10 -imagesize = { version = "0.15.0", default-features = false, features = ["png", "jpeg", "gif", "webp"] }
11 -pulldown-cmark = { version = "0.13.6", default-features = false, features = ["html"] }
10+imagesize = { version = "0.15.0", default-features = false, features = [
11+ "png",
12+ "jpeg",
13+ "gif",
14+ "webp",
15+] }
16+math-core = "0.9.0"
17+pulldown-cmark = { version = "0.13.6", default-features = false, features = [
18+ "html",
19+] }
1220 sha2 = { version = "0.11.1", default-features = false }
+3, -2
@@ -2,7 +2,7 @@ A lightweight, static Git web frontend written in Rust
2 2
3 3 ## Installation
4 4
5 -Build with Rust's cargo, then install (`PREFIX` defaults to `/usr/local`):
5+Build with Rust's cargo (Rust 1.96 or newer), then install (`PREFIX` defaults to `/usr/local`):
6 6
7 7 ```
8 8 make
@@ -21,6 +21,7 @@ Crate dependencies:
2121 - anyhow
2222 - imagesize
2323 - sha2
24+- math-core
2425
2526 ## Usage:
2627
@@ -69,4 +70,4 @@ wit hardlinks the files into the site, at `<repo>/releases/<tag>/`, so keep the
6970
7071 ## Credits
7172
72 -The icons are from [Phosphor Icons](https://github.com/phosphor-icons/core), Copyright (c) 2023 Phosphor Icons, licensed under the [MIT License](https://github.com/phosphor-icons/core/blob/main/LICENSE) (`fonts/phosphor-icons-MIT.txt`). The font is [Recursive](https://github.com/arrowtype/recursive), Copyright 2019 The Recursive Project Authors, licensed under the SIL Open Font License 1.1 (`fonts/OFL.txt`).
73+The icons are from [Phosphor Icons](https://github.com/phosphor-icons/core), Copyright (c) 2023 Phosphor Icons, licensed under the [MIT License](https://github.com/phosphor-icons/core/blob/main/LICENSE) (`fonts/phosphor-icons-MIT.txt`). The font is [Recursive](https://github.com/arrowtype/recursive), Copyright 2019 The Recursive Project Authors, licensed under the SIL Open Font License 1.1 (`fonts/OFL.txt`). The math font is a subset of [New Computer Modern](https://git.gnu.org.ua/newcm.git/about/) Math, modified by [math-core-fonts](https://github.com/tmke8/math-core-fonts), licensed under the GUST Font License (`fonts/GUST-FONT-LICENSE.txt`, `fonts/lppl.txt`). The CSS fixes for math come from [math-core](https://github.com/tmke8/math-core), Copyright 2020 Hiromu Sugiura, [MIT License](https://github.com/tmke8/math-core/blob/main/LICENSE) (`fonts/math-core-MIT.txt`).
+29, -0
@@ -0,0 +1,29 @@
1+% This is version 1.0, dated 22 June 2009, of the GUST Font License.
2+% (GUST is the Polish TeX Users Group, https://www.gust.org.pl)
3+%
4+% For the most recent version of this license see
5+% https://www.gust.org.pl/fonts/licenses/GUST-FONT-LICENSE.txt
6+% or
7+% https://tug.org/fonts/licenses/GUST-FONT-LICENSE.txt
8+%
9+% This work may be distributed and/or modified under the conditions
10+% of the LaTeX Project Public License, either version 1.3c of this
11+% license or (at your option) any later version.
12+%
13+% Please also observe the following clause:
14+% 1) it is requested, but not legally required, that derived works be
15+% distributed only after changing the names of the fonts comprising this
16+% work and given in an accompanying "manifest", and that the
17+% files comprising the Work, as listed in the manifest, also be given
18+% new names. Any exceptions to this request are also given in the
19+% manifest.
20+%
21+% We recommend the manifest be given in a separate file named
22+% MANIFEST-<fontid>.txt, where <fontid> is some unique identification
23+% of the font family. If a separate "readme" file accompanies the Work,
24+% we recommend a name of the form README-<fontid>.txt.
25+%
26+% The latest version of the LaTeX Project Public License is in
27+% https://www.latex-project.org/lppl.txt and version 1.3c or later
28+% is part of all distributions of LaTeX version 2006/05/20 or later.
29+
+416, -0
@@ -0,0 +1,416 @@
1+The LaTeX Project Public License
2+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
3+
4+LPPL Version 1.3c 2008-05-04
5+
6+Copyright 1999 2002-2008 LaTeX3 Project
7+ Everyone is allowed to distribute verbatim copies of this
8+ license document, but modification of it is not allowed.
9+
10+
11+PREAMBLE
12+========
13+
14+The LaTeX Project Public License (LPPL) is the primary license under
15+which the LaTeX kernel and the base LaTeX packages are distributed.
16+
17+You may use this license for any work of which you hold the copyright
18+and which you wish to distribute. This license may be particularly
19+suitable if your work is TeX-related (such as a LaTeX package), but
20+it is written in such a way that you can use it even if your work is
21+unrelated to TeX.
22+
23+The section `WHETHER AND HOW TO DISTRIBUTE WORKS UNDER THIS LICENSE',
24+below, gives instructions, examples, and recommendations for authors
25+who are considering distributing their works under this license.
26+
27+This license gives conditions under which a work may be distributed
28+and modified, as well as conditions under which modified versions of
29+that work may be distributed.
30+
31+We, the LaTeX3 Project, believe that the conditions below give you
32+the freedom to make and distribute modified versions of your work
33+that conform with whatever technical specifications you wish while
34+maintaining the availability, integrity, and reliability of
35+that work. If you do not see how to achieve your goal while
36+meeting these conditions, then read the document `cfgguide.tex'
37+and `modguide.tex' in the base LaTeX distribution for suggestions.
38+
39+
40+DEFINITIONS
41+===========
42+
43+In this license document the following terms are used:
44+
45+ `Work'
46+ Any work being distributed under this License.
47+
48+ `Derived Work'
49+ Any work that under any applicable law is derived from the Work.
50+
51+ `Modification'
52+ Any procedure that produces a Derived Work under any applicable
53+ law -- for example, the production of a file containing an
54+ original file associated with the Work or a significant portion of
55+ such a file, either verbatim or with modifications and/or
56+ translated into another language.
57+
58+ `Modify'
59+ To apply any procedure that produces a Derived Work under any
60+ applicable law.
61+
62+ `Distribution'
63+ Making copies of the Work available from one person to another, in
64+ whole or in part. Distribution includes (but is not limited to)
65+ making any electronic components of the Work accessible by
66+ file transfer protocols such as FTP or HTTP or by shared file
67+ systems such as Sun's Network File System (NFS).
68+
69+ `Compiled Work'
70+ A version of the Work that has been processed into a form where it
71+ is directly usable on a computer system. This processing may
72+ include using installation facilities provided by the Work,
73+ transformations of the Work, copying of components of the Work, or
74+ other activities. Note that modification of any installation
75+ facilities provided by the Work constitutes modification of the Work.
76+
77+ `Current Maintainer'
78+ A person or persons nominated as such within the Work. If there is
79+ no such explicit nomination then it is the `Copyright Holder' under
80+ any applicable law.
81+
82+ `Base Interpreter'
83+ A program or process that is normally needed for running or
84+ interpreting a part or the whole of the Work.
85+
86+ A Base Interpreter may depend on external components but these
87+ are not considered part of the Base Interpreter provided that each
88+ external component clearly identifies itself whenever it is used
89+ interactively. Unless explicitly specified when applying the
90+ license to the Work, the only applicable Base Interpreter is a
91+ `LaTeX-Format' or in the case of files belonging to the
92+ `LaTeX-format' a program implementing the `TeX language'.
93+
94+
95+
96+CONDITIONS ON DISTRIBUTION AND MODIFICATION
97+===========================================
98+
99+1. Activities other than distribution and/or modification of the Work
100+are not covered by this license; they are outside its scope. In
101+particular, the act of running the Work is not restricted and no
102+requirements are made concerning any offers of support for the Work.
103+
104+2. You may distribute a complete, unmodified copy of the Work as you
105+received it. Distribution of only part of the Work is considered
106+modification of the Work, and no right to distribute such a Derived
107+Work may be assumed under the terms of this clause.
108+
109+3. You may distribute a Compiled Work that has been generated from a
110+complete, unmodified copy of the Work as distributed under Clause 2
111+above, as long as that Compiled Work is distributed in such a way that
112+the recipients may install the Compiled Work on their system exactly
113+as it would have been installed if they generated a Compiled Work
114+directly from the Work.
115+
116+4. If you are the Current Maintainer of the Work, you may, without
117+restriction, modify the Work, thus creating a Derived Work. You may
118+also distribute the Derived Work without restriction, including
119+Compiled Works generated from the Derived Work. Derived Works
120+distributed in this manner by the Current Maintainer are considered to
121+be updated versions of the Work.
122+
123+5. If you are not the Current Maintainer of the Work, you may modify
124+your copy of the Work, thus creating a Derived Work based on the Work,
125+and compile this Derived Work, thus creating a Compiled Work based on
126+the Derived Work.
127+
128+6. If you are not the Current Maintainer of the Work, you may
129+distribute a Derived Work provided the following conditions are met
130+for every component of the Work unless that component clearly states
131+in the copyright notice that it is exempt from that condition. Only
132+the Current Maintainer is allowed to add such statements of exemption
133+to a component of the Work.
134+
135+ a. If a component of this Derived Work can be a direct replacement
136+ for a component of the Work when that component is used with the
137+ Base Interpreter, then, wherever this component of the Work
138+ identifies itself to the user when used interactively with that
139+ Base Interpreter, the replacement component of this Derived Work
140+ clearly and unambiguously identifies itself as a modified version
141+ of this component to the user when used interactively with that
142+ Base Interpreter.
143+
144+ b. Every component of the Derived Work contains prominent notices
145+ detailing the nature of the changes to that component, or a
146+ prominent reference to another file that is distributed as part
147+ of the Derived Work and that contains a complete and accurate log
148+ of the changes.
149+
150+ c. No information in the Derived Work implies that any persons,
151+ including (but not limited to) the authors of the original version
152+ of the Work, provide any support, including (but not limited to)
153+ the reporting and handling of errors, to recipients of the
154+ Derived Work unless those persons have stated explicitly that
155+ they do provide such support for the Derived Work.
156+
157+ d. You distribute at least one of the following with the Derived Work:
158+
159+ 1. A complete, unmodified copy of the Work;
160+ if your distribution of a modified component is made by
161+ offering access to copy the modified component from a
162+ designated place, then offering equivalent access to copy
163+ the Work from the same or some similar place meets this
164+ condition, even though third parties are not compelled to
165+ copy the Work along with the modified component;
166+
167+ 2. Information that is sufficient to obtain a complete,
168+ unmodified copy of the Work.
169+
170+7. If you are not the Current Maintainer of the Work, you may
171+distribute a Compiled Work generated from a Derived Work, as long as
172+the Derived Work is distributed to all recipients of the Compiled
173+Work, and as long as the conditions of Clause 6, above, are met with
174+regard to the Derived Work.
175+
176+8. The conditions above are not intended to prohibit, and hence do not
177+apply to, the modification, by any method, of any component so that it
178+becomes identical to an updated version of that component of the Work as
179+it is distributed by the Current Maintainer under Clause 4, above.
180+
181+9. Distribution of the Work or any Derived Work in an alternative
182+format, where the Work or that Derived Work (in whole or in part) is
183+then produced by applying some process to that format, does not relax or
184+nullify any sections of this license as they pertain to the results of
185+applying that process.
186+
187+10. a. A Derived Work may be distributed under a different license
188+ provided that license itself honors the conditions listed in
189+ Clause 6 above, in regard to the Work, though it does not have
190+ to honor the rest of the conditions in this license.
191+
192+ b. If a Derived Work is distributed under a different license, that
193+ Derived Work must provide sufficient documentation as part of
194+ itself to allow each recipient of that Derived Work to honor the
195+ restrictions in Clause 6 above, concerning changes from the Work.
196+
197+11. This license places no restrictions on works that are unrelated to
198+the Work, nor does this license place any restrictions on aggregating
199+such works with the Work by any means.
200+
201+12. Nothing in this license is intended to, or may be used to, prevent
202+complete compliance by all parties with all applicable laws.
203+
204+
205+NO WARRANTY
206+===========
207+
208+There is no warranty for the Work. Except when otherwise stated in
209+writing, the Copyright Holder provides the Work `as is', without
210+warranty of any kind, either expressed or implied, including, but not
211+limited to, the implied warranties of merchantability and fitness for a
212+particular purpose. The entire risk as to the quality and performance
213+of the Work is with you. Should the Work prove defective, you assume
214+the cost of all necessary servicing, repair, or correction.
215+
216+In no event unless required by applicable law or agreed to in writing
217+will The Copyright Holder, or any author named in the components of the
218+Work, or any other party who may distribute and/or modify the Work as
219+permitted above, be liable to you for damages, including any general,
220+special, incidental or consequential damages arising out of any use of
221+the Work or out of inability to use the Work (including, but not limited
222+to, loss of data, data being rendered inaccurate, or losses sustained by
223+anyone as a result of any failure of the Work to operate with any other
224+programs), even if the Copyright Holder or said author or said other
225+party has been advised of the possibility of such damages.
226+
227+
228+MAINTENANCE OF THE WORK
229+=======================
230+
231+The Work has the status `author-maintained' if the Copyright Holder
232+explicitly and prominently states near the primary copyright notice in
233+the Work that the Work can only be maintained by the Copyright Holder
234+or simply that it is `author-maintained'.
235+
236+The Work has the status `maintained' if there is a Current Maintainer
237+who has indicated in the Work that they are willing to receive error
238+reports for the Work (for example, by supplying a valid e-mail
239+address). It is not required for the Current Maintainer to acknowledge
240+or act upon these error reports.
241+
242+The Work changes from status `maintained' to `unmaintained' if there
243+is no Current Maintainer, or the person stated to be Current
244+Maintainer of the work cannot be reached through the indicated means
245+of communication for a period of six months, and there are no other
246+significant signs of active maintenance.
247+
248+You can become the Current Maintainer of the Work by agreement with
249+any existing Current Maintainer to take over this role.
250+
251+If the Work is unmaintained, you can become the Current Maintainer of
252+the Work through the following steps:
253+
254+ 1. Make a reasonable attempt to trace the Current Maintainer (and
255+ the Copyright Holder, if the two differ) through the means of
256+ an Internet or similar search.
257+
258+ 2. If this search is successful, then enquire whether the Work
259+ is still maintained.
260+
261+ a. If it is being maintained, then ask the Current Maintainer
262+ to update their communication data within one month.
263+
264+ b. If the search is unsuccessful or no action to resume active
265+ maintenance is taken by the Current Maintainer, then announce
266+ within the pertinent community your intention to take over
267+ maintenance. (If the Work is a LaTeX work, this could be
268+ done, for example, by posting to comp.text.tex.)
269+
270+ 3a. If the Current Maintainer is reachable and agrees to pass
271+ maintenance of the Work to you, then this takes effect
272+ immediately upon announcement.
273+
274+ b. If the Current Maintainer is not reachable and the Copyright
275+ Holder agrees that maintenance of the Work be passed to you,
276+ then this takes effect immediately upon announcement.
277+
278+ 4. If you make an `intention announcement' as described in 2b. above
279+ and after three months your intention is challenged neither by
280+ the Current Maintainer nor by the Copyright Holder nor by other
281+ people, then you may arrange for the Work to be changed so as
282+ to name you as the (new) Current Maintainer.
283+
284+ 5. If the previously unreachable Current Maintainer becomes
285+ reachable once more within three months of a change completed
286+ under the terms of 3b) or 4), then that Current Maintainer must
287+ become or remain the Current Maintainer upon request provided
288+ they then update their communication data within one month.
289+
290+A change in the Current Maintainer does not, of itself, alter the fact
291+that the Work is distributed under the LPPL license.
292+
293+If you become the Current Maintainer of the Work, you should
294+immediately provide, within the Work, a prominent and unambiguous
295+statement of your status as Current Maintainer. You should also
296+announce your new status to the same pertinent community as
297+in 2b) above.
298+
299+
300+WHETHER AND HOW TO DISTRIBUTE WORKS UNDER THIS LICENSE
301+======================================================
302+
303+This section contains important instructions, examples, and
304+recommendations for authors who are considering distributing their
305+works under this license. These authors are addressed as `you' in
306+this section.
307+
308+Choosing This License or Another License
309+----------------------------------------
310+
311+If for any part of your work you want or need to use *distribution*
312+conditions that differ significantly from those in this license, then
313+do not refer to this license anywhere in your work but, instead,
314+distribute your work under a different license. You may use the text
315+of this license as a model for your own license, but your license
316+should not refer to the LPPL or otherwise give the impression that
317+your work is distributed under the LPPL.
318+
319+The document `modguide.tex' in the base LaTeX distribution explains
320+the motivation behind the conditions of this license. It explains,
321+for example, why distributing LaTeX under the GNU General Public
322+License (GPL) was considered inappropriate. Even if your work is
323+unrelated to LaTeX, the discussion in `modguide.tex' may still be
324+relevant, and authors intending to distribute their works under any
325+license are encouraged to read it.
326+
327+A Recommendation on Modification Without Distribution
328+-----------------------------------------------------
329+
330+It is wise never to modify a component of the Work, even for your own
331+personal use, without also meeting the above conditions for
332+distributing the modified component. While you might intend that such
333+modifications will never be distributed, often this will happen by
334+accident -- you may forget that you have modified that component; or
335+it may not occur to you when allowing others to access the modified
336+version that you are thus distributing it and violating the conditions
337+of this license in ways that could have legal implications and, worse,
338+cause problems for the community. It is therefore usually in your
339+best interest to keep your copy of the Work identical with the public
340+one. Many works provide ways to control the behavior of that work
341+without altering any of its licensed components.
342+
343+How to Use This License
344+-----------------------
345+
346+To use this license, place in each of the components of your work both
347+an explicit copyright notice including your name and the year the work
348+was authored and/or last substantially modified. Include also a
349+statement that the distribution and/or modification of that
350+component is constrained by the conditions in this license.
351+
352+Here is an example of such a notice and statement:
353+
354+ %% pig.dtx
355+ %% Copyright 2008 M. Y. Name
356+ %
357+ % This work may be distributed and/or modified under the
358+ % conditions of the LaTeX Project Public License, either version 1.3
359+ % of this license or (at your option) any later version.
360+ % The latest version of this license is in
361+ % https://www.latex-project.org/lppl.txt
362+ % and version 1.3c or later is part of all distributions of LaTeX
363+ % version 2008 or later.
364+ %
365+ % This work has the LPPL maintenance status `maintained'.
366+ %
367+ % The Current Maintainer of this work is M. Y. Name.
368+ %
369+ % This work consists of the files pig.dtx and pig.ins
370+ % and the derived file pig.sty.
371+
372+Given such a notice and statement in a file, the conditions
373+given in this license document would apply, with the `Work' referring
374+to the three files `pig.dtx', `pig.ins', and `pig.sty' (the last being
375+generated from `pig.dtx' using `pig.ins'), the `Base Interpreter'
376+referring to any `LaTeX-Format', and both `Copyright Holder' and
377+`Current Maintainer' referring to the person `M. Y. Name'.
378+
379+If you do not want the Maintenance section of LPPL to apply to your
380+Work, change `maintained' above into `author-maintained'.
381+However, we recommend that you use `maintained', as the Maintenance
382+section was added in order to ensure that your Work remains useful to
383+the community even when you can no longer maintain and support it
384+yourself.
385+
386+Derived Works That Are Not Replacements
387+---------------------------------------
388+
389+Several clauses of the LPPL specify means to provide reliability and
390+stability for the user community. They therefore concern themselves
391+with the case that a Derived Work is intended to be used as a
392+(compatible or incompatible) replacement of the original Work. If
393+this is not the case (e.g., if a few lines of code are reused for a
394+completely different task), then clauses 6b and 6d shall not apply.
395+
396+
397+Important Recommendations
398+-------------------------
399+
400+ Defining What Constitutes the Work
401+
402+ The LPPL requires that distributions of the Work contain all the
403+ files of the Work. It is therefore important that you provide a
404+ way for the licensee to determine which files constitute the Work.
405+ This could, for example, be achieved by explicitly listing all the
406+ files of the Work near the copyright notice of each file or by
407+ using a line such as:
408+
409+ % This work consists of all files listed in manifest.txt.
410+
411+ in that place. In the absence of an unequivocal list it might be
412+ impossible for the licensee to determine what is considered by you
413+ to comprise the Work and, in such a case, the licensee would be
414+ entitled to make reasonable conjectures as to which files comprise
415+ the Work.
416+
+9, -0
@@ -0,0 +1,9 @@
1+MIT License
2+
3+Copyright 2020 Hiromu Sugiura
4+
5+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6+
7+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8+
9+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file
binary file, 478 kB
+95, -3
@@ -4,10 +4,13 @@ use crate::html::{
4 4 };
5 5 use crate::repo_info::{RefInfo, RepoInfo};
6 6
7+use math_core::{LatexToMathML, MathCoreConfig, MathDisplay};
7 8 use pulldown_cmark::{
8 - BlockQuoteKind, Event, HeadingLevel, LinkType, Options, Parser, Tag, TagEnd, html::push_html,
9+ BlockQuoteKind, CodeBlockKind, Event, HeadingLevel, LinkType, Options, Parser, Tag, TagEnd,
10+ html::push_html,
9 11 };
10 12 use std::collections::{HashMap, HashSet};
13+use std::thread;
11 14
12 15 const PAGE_IDS: [&str; 7] = [
13 16 "header",
@@ -21,6 +24,10 @@ const PAGE_IDS: [&str; 7] = [
21 24
22 25 const NUMBERED_PAGE_IDS: [&str; 2] = ["ref-more-", "release-"];
23 26
27+const MAX_FORMULA: usize = 2000;
28+
29+const MATH_STACK: usize = 32 << 20;
30+
24 31 struct RawHeading {
25 32 start: usize,
26 33 level: u8,
@@ -53,7 +60,9 @@ pub fn write_markdown(
53 60 | Options::ENABLE_STRIKETHROUGH
54 61 | Options::ENABLE_TASKLISTS
55 62 | Options::ENABLE_FOOTNOTES
56 - | Options::ENABLE_GFM;
63+ | Options::ENABLE_GFM
64+ | Options::ENABLE_MATH;
65+ let text = escape_dollars(text.into_owned(), options);
57 66 let parsed = Parser::new_ext(&text, options).map(|mut event| {
58 67 match &mut event {
59 68 Event::Start(Tag::Link {
@@ -94,8 +103,39 @@ pub fn write_markdown(
94103 let mut ids = heading_ids(&events, footnote_ids).into_iter();
95104 let mut html_events = Vec::with_capacity(events.len());
96105 let mut heading_end: Option<String> = None;
106+ let mut math_block: Option<String> = None;
107+ let mut in_image = false;
97108 for event in events {
98109 match event {
110+ Event::Start(Tag::Image { .. }) | Event::End(TagEnd::Image) => {
111+ in_image = matches!(event, Event::Start(_));
112+ html_events.push(event);
113+ }
114+ Event::InlineMath(latex) if !in_image => {
115+ html_events.push(math_event(&latex, MathDisplay::Inline, "$"));
116+ }
117+ Event::DisplayMath(latex) if !in_image => {
118+ html_events.push(math_event(&latex, MathDisplay::Block, "$$"));
119+ }
120+ Event::Start(Tag::CodeBlock(CodeBlockKind::Fenced(lang))) if &*lang == "math" => {
121+ math_block = Some(String::new());
122+ }
123+ Event::Text(text) if math_block.is_some() => {
124+ math_block.get_or_insert_default().push_str(&text);
125+ }
126+ Event::End(TagEnd::CodeBlock) if math_block.is_some() => {
127+ let latex = math_block.take().unwrap_or_default();
128+ match mathml(&latex, MathDisplay::Block) {
129+ Some(math) => {
130+ html_events.push(Event::Html(format!("<p>{math}</p>\n").into()));
131+ }
132+ None => html_events.extend([
133+ Event::Start(Tag::CodeBlock(CodeBlockKind::Fenced("math".into()))),
134+ Event::Text(latex.into()),
135+ Event::End(TagEnd::CodeBlock),
136+ ]),
137+ }
138+ }
99139 Event::Start(Tag::Heading {
100140 level,
101141 classes,
@@ -187,6 +227,55 @@ pub fn write_markdown(
187227 body.push_str("</div>\n");
188228 }
189229
230+fn escape_dollars(mut text: String, options: Options) -> String {
231+ while text.contains('$') {
232+ let word = |c: Option<char>| c.is_some_and(char::is_alphanumeric);
233+ let found: Vec<usize> = Parser::new_ext(&text, options)
234+ .into_offset_iter()
235+ .filter(|(event, _)| matches!(event, Event::InlineMath(_)))
236+ .filter_map(|(_, range)| {
237+ if word(text[..range.start].chars().next_back()) {
238+ Some(range.start)
239+ } else {
240+ word(text[range.end..].chars().next()).then(|| range.end - 1)
241+ }
242+ })
243+ .collect();
244+ if found.is_empty() {
245+ break;
246+ }
247+ for at in found.into_iter().rev() {
248+ text.insert(at, '\\');
249+ }
250+ }
251+ text
252+}
253+
254+fn mathml(latex: &str, display: MathDisplay) -> Option<String> {
255+ if latex.len() > MAX_FORMULA {
256+ return None;
257+ }
258+ let convert = || {
259+ let converter = LatexToMathML::new(MathCoreConfig::default(), Vec::new()).ok()?;
260+ let math = converter.convert_with_local_state(latex.trim(), display);
261+ Some(math.ok()?.mathml)
262+ };
263+ thread::scope(|scope| {
264+ let thread = thread::Builder::new().stack_size(MATH_STACK);
265+ thread.spawn_scoped(scope, convert).ok()?.join().ok()?
266+ })
267+}
268+
269+fn math_event<'a>(latex: &str, display: MathDisplay, delimiter: &str) -> Event<'a> {
270+ let inner = latex
271+ .strip_prefix('`')
272+ .and_then(|latex| latex.strip_suffix('`'));
273+ match mathml(inner.unwrap_or(latex), display) {
274+ Some(math) => Event::InlineHtml(math.into()),
275+ None => Event::Text(format!("{delimiter}{latex}{delimiter}").into()),
276+ }
277+}
278+
190279 fn gather_footnotes(events: Vec<Event<'_>>) -> (Vec<Event<'_>>, Vec<String>) {
191280 let mut main = Vec::with_capacity(events.len());
192281 let mut definitions: HashMap<String, Vec<Event>> = HashMap::new();
@@ -289,7 +378,10 @@ fn heading_ids(events: &[Event], footnote_ids: Vec<String>) -> Vec<(String, Stri
289378 for event in events {
290379 match event {
291380 Event::Start(Tag::Heading { .. }) => heading = Some(String::new()),
292 - Event::Text(text) | Event::Code(text) => {
381+ Event::Text(text)
382+ | Event::Code(text)
383+ | Event::InlineMath(text)
384+ | Event::DisplayMath(text) => {
293385 if let Some(heading) = &mut heading {
294386 heading.push_str(text);
295387 }
+107, -0
@@ -13,6 +13,12 @@
13 13 unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
14 14 }
15 15
16+@font-face {
17+ font-family: "New Computer Modern Math";
18+ font-display: swap;
19+ src: url(fonts/new-computer-modern-math.woff2) format("woff2");
20+}
21+
16 22 @font-face {
17 23 font-family: Recursive;
18 24 font-style: normal;
@@ -2115,3 +2121,104 @@ a:is(.commit-id, .release-id) {
21152121 padding-top: 0;
21162122 }
21172123 }
2124+
2125+math {
2126+ font-family: "New Computer Modern Math", math;
2127+ font-feature-settings: "dtls" 0;
2128+ font-size: 1.1em;
2129+}
2130+
2131+math:not([display="block"]) {
2132+ white-space: nowrap;
2133+}
2134+
2135+mtext .math-core-sans-serif-font {
2136+ font-family: sans-serif;
2137+}
2138+
2139+.markdown-body mtext code {
2140+ padding: 0;
2141+ font-size: inherit;
2142+ background-color: transparent;
2143+}
2144+
2145+mtd {
2146+ padding: 0.5ex 0.5em;
2147+}
2148+
2149+mtr > mtd:first-child {
2150+ padding-left: 0;
2151+}
2152+
2153+mtr > mtd:last-child {
2154+ padding-right: 0;
2155+}
2156+
2157+@supports (not (-webkit-backdrop-filter: blur(1px))) and
2158+ (not (-moz-appearance: none)) {
2159+ menclose {
2160+ position: relative;
2161+ padding: 0.5ex 0;
2162+ }
2163+ menclose[notation~="box" i] {
2164+ border: 0.04em solid;
2165+ padding: 0.3rem;
2166+ }
2167+ menclose[notation~="actuarial" i] {
2168+ padding: 0.03889rem 0.03889rem 0 0.03889rem;
2169+ border-width: 0.08em 0.08em 0em 0em;
2170+ border-style: solid;
2171+ margin-right: 0.03889rem;
2172+ }
2173+ menclose[notation~="phasorangle" i] {
2174+ border-bottom: 0.067em solid;
2175+ padding: 0.2em 0.2em 0.1em 0.6em;
2176+ }
2177+ mrow.menclose-phasorangle {
2178+ display: inline-block;
2179+ position: absolute;
2180+ left: 0.5px;
2181+ bottom: -0.04em;
2182+ height: 100%;
2183+ aspect-ratio: 0.5;
2184+ background-color: currentcolor;
2185+ clip-path: polygon(
2186+ 0.05em 100%,
2187+ 0 calc(100% - 0.05em),
2188+ calc(100% - 0.05em) 0,
2189+ 100% 0.05em
2190+ );
2191+ }
2192+ mrow.menclose-updiagonalstrike,
2193+ mrow.menclose-downdiagonalstrike {
2194+ display: inline-block;
2195+ position: absolute;
2196+ left: 0.5px;
2197+ bottom: 0;
2198+ width: 100%;
2199+ height: 100%;
2200+ background-color: currentcolor;
2201+ }
2202+ mrow.menclose-updiagonalstrike {
2203+ clip-path: polygon(
2204+ 0.05em 100%,
2205+ 0 calc(100% - 0.05em),
2206+ calc(100% - 0.05em) 0,
2207+ 100% 0.05em
2208+ );
2209+ }
2210+ mrow.menclose-downdiagonalstrike {
2211+ clip-path: polygon(
2212+ 0em 0.05em,
2213+ 0.05em 0em,
2214+ 100% calc(100% - 0.05em),
2215+ calc(100% - 0.05em) 100%
2216+ );
2217+ }
2218+}
2219+
2220+@supports (not (-moz-appearance: none)) {
2221+ mover[accent="true" i] > mo:nth-child(2) {
2222+ margin-bottom: 0.15ex;
2223+ }
2224+}