From cfc0264b41728c6b2f5dda142d57dc1d1d30b975 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sun, 26 Nov 2023 19:26:29 +0200 Subject: [math] Added initial setup for a simple LaTeX renderer --- src/_header.html | 1 + src/font/cm-unicode-0.7.0/Fontmap.CMU | 33 ++++++++++++++++++++++++++ src/font/cm-unicode-0.7.0/README | 40 +++++++++++++++++++++++++++++++ src/font/cmunrm.ttf | Bin 0 -> 639132 bytes src/font/cmunti.ttf | Bin 0 -> 486980 bytes src/index.md | 2 ++ src/scripts/math.js | 21 +++++++++++++++++ src/styles.csma | 43 ++++++++++++++++++++++++++++++++++ 8 files changed, 140 insertions(+) create mode 100644 src/font/cm-unicode-0.7.0/Fontmap.CMU create mode 100644 src/font/cm-unicode-0.7.0/README create mode 100644 src/font/cmunrm.ttf create mode 100644 src/font/cmunti.ttf create mode 100644 src/scripts/math.js diff --git a/src/_header.html b/src/_header.html index 6963c12..9e5b552 100644 --- a/src/_header.html +++ b/src/_header.html @@ -108,3 +108,4 @@
+ diff --git a/src/font/cm-unicode-0.7.0/Fontmap.CMU b/src/font/cm-unicode-0.7.0/Fontmap.CMU new file mode 100644 index 0000000..2cfc0da --- /dev/null +++ b/src/font/cm-unicode-0.7.0/Fontmap.CMU @@ -0,0 +1,33 @@ +/CMUBright-Bold (cmunbbx.ttf) ; +/CMUSerif-BoldItalic (cmunbi.ttf) ; +/CMUSerif-BoldSlanted (cmunbl.ttf) ; +/CMUBright-Oblique (cmunbmo.ttf) ; +/CMUBright-Roman (cmunbmr.ttf) ; +/CMUBright-SemiboldOblique (cmunbso.ttf) ; +/CMUBright-Semibold (cmunbsr.ttf) ; +/CMUTypewriter-Light (cmunbtl.ttf) ; +/CMUTypewriter-LightOblique (cmunbto.ttf) ; +/CMUSerif-Bold (cmunbx.ttf) ; +/CMUBright-BoldOblique (cmunbxo.ttf) ; +/CMUClassicalSerif-Italic (cmunci.ttf) ; +/CMUTypewriter-Italic (cmunit.ttf) ; +/CMUConcrete-BoldItalic (cmunobi.ttf) ; +/CMUConcrete-Bold (cmunobx.ttf) ; +/CMUConcrete-Roman (cmunorm.ttf) ; +/CMUConcrete-Italic (cmunoti.ttf) ; +/CMUSerif-BoldNonextended (cmunrb.ttf) ; +/CMUSerif-Roman (cmunrm.ttf) ; +/CMUSansSerif-Oblique (cmunsi.ttf) ; +/CMUSerif-RomanSlanted (cmunsl.ttf) ; +/CMUSansSerif-BoldOblique (cmunso.ttf) ; +/CMUSansSerif (cmunss.ttf) ; +/CMUSansSerif-DemiCondensed (cmunssdc.ttf) ; +/CMUTypewriter-Oblique (cmunst.ttf) ; +/CMUSansSerif-Bold (cmunsx.ttf) ; +/CMUTypewriter-Bold (cmuntb.ttf) ; +/CMUSerif-Italic (cmunti.ttf) ; +/CMUTypewriter-Regular (cmuntt.ttf) ; +/CMUTypewriter-BoldItalic (cmuntx.ttf) ; +/CMUSerif-UprightItalic (cmunui.ttf) ; +/CMUTypewriterVariable-Italic (cmunvi.ttf) ; +/CMUTypewriterVariable (cmunvt.ttf) ; diff --git a/src/font/cm-unicode-0.7.0/README b/src/font/cm-unicode-0.7.0/README new file mode 100644 index 0000000..c317039 --- /dev/null +++ b/src/font/cm-unicode-0.7.0/README @@ -0,0 +1,40 @@ + Computer Modern Unicode fonts + + Computer Modern Unicode fonts were converted from metafont sources + using mftrace with autotrace backend and fontforge. Some characters + in several fonts are copied from Blue Sky type 1 fonts released by + AMS. Their main purpose is to create free good quality fonts for use + in X applications supporting many languages. Currently the fonts + contain glyphs from Latin (Metafont ec, tc, vnr), Cyrillic (lh), Greek + (cbgreek when available) code sets and IPA extensions (from tipa). + Other alphabets are also welcome. + + These fonts are distributed under the terms of Open Font License. Some + scripts for font generation are distributed under the terms + of GNU General Public License. + + This font set contains 33 fonts. You can download from homepage the + sfd files and pfb fonts. It is better to use these fonts with + antialiasing enabled. + + Of cause, this version has many unresolved questions and bugs. If you + have found any bug inform me by e-mail. + +Acknowledgements + + Thanks to George Williams the author of the fontforge for his + responsiveness in fixing bugs and adding new features. + +References + + 1. http://lilypond.org/mftrace/ + 2. http://fontforge.sf.net/ + 3. http://canopus.iacp.dvo.ru/~panov/cm-unicode/ (homepage) + 4. ftp://cam.ctan.org/tex-archive/fonts/ec/ (ec and tc fonts) + 5. ftp://cam.ctan.org/tex-archive/fonts/cyrillic/lh (lh fonts) + 6. ftp://cam.ctan.org/tex-archive/fonts/greek/cb (cb greek fonts) + 7. ftp://cam.ctan.org/tex-archive/fonts/tipa (tipa fonts) + 8. ftp://cam.ctan.org/tex-archive/language/vietnamese/vntex/unpacked/fonts/source/vntex/vnr/ (vnr fonts) + +Andrey V. Panov +panov /at/ canopus. iacp. dvo. ru \ No newline at end of file diff --git a/src/font/cmunrm.ttf b/src/font/cmunrm.ttf new file mode 100644 index 0000000..1c3fff0 Binary files /dev/null and b/src/font/cmunrm.ttf differ diff --git a/src/font/cmunti.ttf b/src/font/cmunti.ttf new file mode 100644 index 0000000..993d5c0 Binary files /dev/null and b/src/font/cmunti.ttf differ diff --git a/src/index.md b/src/index.md index 6d99115..c6eb8f0 100644 --- a/src/index.md +++ b/src/index.md @@ -13,6 +13,8 @@ Have a look around and enjoy your stay! --- +$$x + y = \frac{a^{\frac{1}{2}}}{b}$$ +
Created With VIM diff --git a/src/scripts/math.js b/src/scripts/math.js new file mode 100644 index 0000000..63b7681 --- /dev/null +++ b/src/scripts/math.js @@ -0,0 +1,21 @@ +function eqToHTML(equation) { + equation = equation.slice(2, -2) + .replaceAll(/ /g, '') + .replaceAll(/[\/+\*-=:]/g, '$&') + .replaceAll(/\\frac{(.*)}{(.*)}/g, '$1$2') + .replaceAll(/\^{(.*)}/g, '$1'); + equation = equation + .replaceAll(/\\frac{(.*)}{(.*)}/g, '$1$2') + .replaceAll(/\^{(.*)}/g, '$1'); + + return '
' + equation + '
'; +} + +for (var par of document.getElementsByTagName('p')) { + var eqs = par.innerText.match(/\\\[[^\]]*\\\]/g); + if (eqs === null) continue; + + for (var equation of eqs) { + par.innerHTML = par.innerHTML.replace(equation, eqToHTML(equation)); + } +} diff --git a/src/styles.csma b/src/styles.csma index 1e3a7d4..d860054 100644 --- a/src/styles.csma +++ b/src/styles.csma @@ -254,6 +254,7 @@ {} {} {} + {} @@ -353,6 +354,48 @@ } } +
{ + +{ + @font-face { + font-family: "Computer Modern"; + src: url('/font/cmunrm.ttf'); + } + + @font-face { + font-family: "Computer Modern"; + font-style: italic; + src: url('/font/cmunti.ttf'); + } + + .equation { + font-family: 'Computer Modern'; + font-style: italic; + letter-spacing: 0.25em; + text-align: center; + font-size: 1.2em; + } + .equation .operator { + font-style: normal; + } + + { + .divide { + display: inline-table; + vertical-align: middle; + } + .divide > * { display: table-row; } + + .dividend, .divisor { padding-left: 5px; } + .dividend { border-bottom: 1px solid var(--fg-color); } + } + + .equation sup { + margin-left: -3px; + } +} +} + { h1, h2, h3, h4, h5, h6 { color: var(--header-color); -- cgit v1.3.1-23-gd82d