Summary Files Commits Branches @commit @diff @stats
path: root / src
diff options
context:
space:
mode:
Commitcfc0264b41728c6b2f5dda142d57dc1d1d30b975 (patch)
Author
 Syndamia <kamen@syndamia.com>
2023-11-26 19:26:29 +0200
Committer
 Syndamia <kamen@syndamia.com>
2023-11-26 19:26:29 +0200
Files00febb6a8d57daacbedf878db60ce01dc2b55a39 /src
syndamia.com-latex.tar
syndamia.com-latex.tar.gz
syndamia.com-latex.zip
Parent11a6c3776e148e89387fdda7e90867661cecded5 (diff)
[math] Added initial setup for a simple LaTeX renderer latex
8 files changed, 140 insertions, 0 deletions
-rw-r--r--src/_header.html1
-rw-r--r--src/font/cm-unicode-0.7.0/Fontmap.CMU33
-rw-r--r--src/font/cm-unicode-0.7.0/README40
-rw-r--r--src/font/cmunrm.ttfbin0 -> 639132 bytes
-rw-r--r--src/font/cmunti.ttfbin0 -> 486980 bytes
-rw-r--r--src/index.md2
-rw-r--r--src/scripts/math.js21
-rw-r--r--src/styles.csma43
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 @@
<article>
<script type="text/javascript" src="/scripts/page-width.js" crossorigin="anonymous" defer></script>
+ <script type="text/javascript" src="/scripts/math.js" crossorigin="anonymous" defer></script>
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
--- /dev/null
+++ b/src/font/cmunrm.ttf
Binary files differ
diff --git a/src/font/cmunti.ttf b/src/font/cmunti.ttf
new file mode 100644
index 0000000..993d5c0
--- /dev/null
+++ b/src/font/cmunti.ttf
Binary files 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}$$
+
<br>
<a class="borderless" href="https://www.vim.org/"><img class="oldschool-badge unzoomable" src="./img/created.with.vim.gif" alt="Created With VIM"></a>
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, '<span class="operator">$&</span>')
+ .replaceAll(/\\frac{(.*)}{(.*)}/g, '<span class="divide"><span><span class="dividend">$1</span></span><span><span class="divisor">$2</span></span></span>')
+ .replaceAll(/\^{(.*)}/g, '<sup>$1</sup>');
+ equation = equation
+ .replaceAll(/\\frac{(.*)}{(.*)}/g, '<span class="divide"><span><span class="dividend">$1</span></span><span><span class="divisor">$2</span></span></span>')
+ .replaceAll(/\^{(.*)}/g, '<sup>$1</sup>');
+
+ return '<div class="equation">' + equation + '</div>';
+}
+
+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 @@
<Pagenav> {}
<Paragraphs with icons> {}
<Page specific> {}
+ <Math> {}
<Headers>
<Anchor>
@@ -353,6 +354,48 @@
}
}
+<Article> {
+<Math>
+{
+ @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;
+ }
+
+ <Division> {
+ .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;
+ }
+}
+}
+
<Headers> {
h1, h2, h3, h4, h5, h6 {
color: var(--header-color);