Skip to content

Commit

Permalink
Try fixing the KaTeX renderingg
Browse files Browse the repository at this point in the history
  • Loading branch information
lukstafi committed Oct 26, 2023
1 parent c30b307 commit 1cc23d9
Show file tree
Hide file tree
Showing 10 changed files with 1,070 additions and 1,030 deletions.
19 changes: 19 additions & 0 deletions MD_metadata.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
title: Curious OCaml
author: Lukasz Stafiniak
header-includes:
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css"
integrity="sha384-n8MVd4RsNIU0tAv4ct0nTaAbDJwPJzDEaqSD1odI+WdtXRGWt2kTvGFasHpSy3SV" crossorigin="anonymous">
- <script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.js"
integrity="sha384-XjKyOOlGwcjNTAIQHIpgOno0Hl1YQqzUOEleOLALmuqehneUG+vnGctmUb0ZY0l8"
crossorigin="anonymous"></script>
- <script>document.addEventListener("DOMContentLoaded", function () {
var mathElements = document.getElementsByClassName("math");
var macros = [];
for (var i = 0; i < mathElements.length; i++) {
var texText = mathElements[i].firstChild;
if (mathElements[i].tagName == "SPAN") {
katex.render(texText.data, mathElements[i], {
displayMode:mathElements[i].classList.contains('display'), throwOnError:false, macros:macros, fleqn:false}); }}});
</script>
---
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
---
title: Curious OCaml
author: Lukasz Stafiniak
header-includes:
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css"
integrity="sha384-n8MVd4RsNIU0tAv4ct0nTaAbDJwPJzDEaqSD1odI+WdtXRGWt2kTvGFasHpSy3SV" crossorigin="anonymous">
- <script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.js"
integrity="sha384-XjKyOOlGwcjNTAIQHIpgOno0Hl1YQqzUOEleOLALmuqehneUG+vnGctmUb0ZY0l8"
crossorigin="anonymous"></script>
- <script>document.addEventListener("DOMContentLoaded", function () {
var mathElements = document.getElementsByClassName("math");
var macros = [];
for (var i = 0; i < mathElements.length; i++) {
var texText = mathElements[i].firstChild;
if (mathElements[i].tagName == "SPAN") {
katex.render(texText.data, mathElements[i], {
displayMode:mathElements[i].classList.contains('display'), throwOnError:false, macros:macros, fleqn:false}); }}});
</script>
---
<!-- Do NOT modify this file, it is automatically generated -->
# Curious OCaml
# From logic rules to programming constructs
Expand Down
3 changes: 3 additions & 0 deletions dune
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
(target README.md)
(mode promote)
(deps
MD_metadata.md
chapter1/README.md
chapter2/README.md
chapter3/README.md
Expand All @@ -17,6 +18,7 @@
(with-stdout-to
README.md
(progn
(cat MD_metadata.md)
(echo
"<!-- Do NOT modify this file, it is automatically generated -->\n")
(echo "# Curious OCaml\n")
Expand Down Expand Up @@ -66,6 +68,7 @@
(with-stdout-to
old_lectures_as_book.md
(progn
(cat MD_metadata.md)
(echo
"<!-- Do NOT modify this file, it is automatically generated -->\n")
(echo "# Curious OCaml\n")
Expand Down
19 changes: 19 additions & 0 deletions old_lectures_as_book.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
---
title: Curious OCaml
author: Lukasz Stafiniak
header-includes:
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css"
integrity="sha384-n8MVd4RsNIU0tAv4ct0nTaAbDJwPJzDEaqSD1odI+WdtXRGWt2kTvGFasHpSy3SV" crossorigin="anonymous">
- <script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.js"
integrity="sha384-XjKyOOlGwcjNTAIQHIpgOno0Hl1YQqzUOEleOLALmuqehneUG+vnGctmUb0ZY0l8"
crossorigin="anonymous"></script>
- <script>document.addEventListener("DOMContentLoaded", function () {
var mathElements = document.getElementsByClassName("math");
var macros = [];
for (var i = 0; i < mathElements.length; i++) {
var texText = mathElements[i].firstChild;
if (mathElements[i].tagName == "SPAN") {
katex.render(texText.data, mathElements[i], {
displayMode:mathElements[i].classList.contains('display'), throwOnError:false, macros:macros, fleqn:false}); }}});
</script>
---
<!-- Do NOT modify this file, it is automatically generated -->
# Curious OCaml
# Chapter 1
Expand Down
4 changes: 2 additions & 2 deletions pdfs/dune
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
(target new_book.pdf)
(deps README.md)
(action
(system "pandoc -s %{deps} -o %{target} --metadata title='Curious OCaml'")))
(system "pandoc -s %{deps} -o %{target}")))

(rule
(alias old_lectures_as_book)
(mode promote)
(target old_lectures_as_book.pdf)
(deps old_lectures_as_book.md)
(action
(system "pandoc -s %{deps} -o %{target} --metadata title='Functional Programming Course'")))
(system "pandoc -s %{deps} -o %{target}")))
Binary file modified pdfs/new_book.pdf
Binary file not shown.
4 changes: 2 additions & 2 deletions site/dune
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
(target new_book.html)
(deps README.md)
(action
(system "pandoc -s %{deps} -o %{target} --katex --metadata title='Curious OCaml'")))
(system "pandoc -s %{deps} -o %{target}")))

(rule
(alias old_lectures_as_book)
Expand All @@ -40,4 +40,4 @@
(deps old_lectures_as_book.md)
(action
(system
"pandoc -s %{deps} -o %{target} --katex --metadata title='Functional Programming Course'")))
"pandoc -s %{deps} -o %{target}")))
38 changes: 1 addition & 37 deletions site/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,7 @@

<head>
<title>A Curious OCaml Book</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css"
integrity="sha384-n8MVd4RsNIU0tAv4ct0nTaAbDJwPJzDEaqSD1odI+WdtXRGWt2kTvGFasHpSy3SV" crossorigin="anonymous">

<!-- The loading of KaTeX is deferred to speed up page rendering -->
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.js"
integrity="sha384-XjKyOOlGwcjNTAIQHIpgOno0Hl1YQqzUOEleOLALmuqehneUG+vnGctmUb0ZY0l8"
crossorigin="anonymous"></script>
<script>document.addEventListener("DOMContentLoaded", function () {
var mathElements = document.getElementsByClassName("math");
var macros = [];
for (var i = 0; i < mathElements.length; i++) {
var texText = mathElements[i].firstChild;
if (mathElements[i].tagName == "SPAN") {
katex.render(texText.data, mathElements[i], {
displayMode: mathElements[i].classList.contains('display'),
throwOnError: false,
macros: macros,
fleqn: false
});
}}});
</script>

<author>Lukasz Stafiniak</author>
</head>

<body>
Expand All @@ -34,21 +13,6 @@ <h4>Curious OCaml</h4>
<h4>Functional Programming 2012-2013</h4>
<a href="old_lectures_as_book.html">Functional Programming Course 2012-2013</a> slides converted to a book format --
conversion cleanup in progress.
<h4>Test math rendering</h4>
<p>How can we define them? Think in terms of <em>derivation trees</em>:
</p>
<p><span class="math display"> \frac{\begin{array}{ll}
\frac{\begin{array}{ll}
\frac{\,}{\text{a premise}} &amp; \frac{\,}{\text{another premise}}
\end{array}}{\text{some fact}} &amp; \frac{\frac{\,}{\text{this we have by default}}}{\text{another fact}}
\end{array}}{\text{final conclusion}} </span></p>
<p>Define by providing rules for using the connectives: for example, a
rule <span class="math inline">\frac{\begin{array}{ll} a &amp; b
\end{array}}{c}</span> matches parts of the tree that have two premises,
represented by variables <span class="math inline">a</span> and <span class="math inline">b</span>, and have any
conclusion, represented by
variable <span class="math inline">c</span>.
</p>
</body>

</html>
68 changes: 28 additions & 40 deletions site/new_book.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<meta name="author" content="Lukasz Stafiniak" />
<title>Curious OCaml</title>
<style>
html {
Expand Down Expand Up @@ -152,29 +153,16 @@
div.column{display: inline-block; vertical-align: top; width: 50%;}
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
ul.task-list{list-style: none;}
.display.math{display: block; text-align: center; margin: 0.5rem auto;}
</style>
<script defer=""
src="/usr/share/javascript/katex/katex.min.js"></script>
<script>document.addEventListener("DOMContentLoaded", function () {
var mathElements = document.getElementsByClassName("math");
var macros = [];
for (var i = 0; i < mathElements.length; i++) {
var texText = mathElements[i].firstChild;
if (mathElements[i].tagName == "SPAN") {
katex.render(texText.data, mathElements[i], {
displayMode: mathElements[i].classList.contains('display'),
throwOnError: false,
macros: macros,
fleqn: false
});
}}});
</script>
<link rel="stylesheet"
href="/usr/share/javascript/katex/katex.min.css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css" integrity="sha384-n8MVd4RsNIU0tAv4ct0nTaAbDJwPJzDEaqSD1odI+WdtXRGWt2kTvGFasHpSy3SV" crossorigin="anonymous">
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.js" integrity="sha384-XjKyOOlGwcjNTAIQHIpgOno0Hl1YQqzUOEleOLALmuqehneUG+vnGctmUb0ZY0l8" crossorigin="anonymous"></script>
<script>document.addEventListener("DOMContentLoaded", function () { var mathElements = document.getElementsByClassName("math"); var macros = []; for (var i = 0; i < mathElements.length; i++) { var texText = mathElements[i].firstChild; if (mathElements[i].tagName == "SPAN") { katex.render(texText.data, mathElements[i], { displayMode:mathElements[i].classList.contains('display'), throwOnError:false, macros:macros, fleqn:false}); }}}); </script>
</head>
<body>
<header id="title-block-header">
<h1 class="title">Curious OCaml</h1>
<p class="author">Lukasz Stafiniak</p>
</header>
<!-- Do NOT modify this file, it is automatically generated -->
<h1 id="curious-ocaml">Curious OCaml</h1>
Expand All @@ -191,20 +179,20 @@ <h1 id="from-logic-rules-to-programming-constructs">From logic rules to
</colgroup>
<thead>
<tr class="header">
<th><span class="math inline">\top</span></th>
<th><span class="math inline">\bot</span></th>
<th><span class="math inline">\wedge</span></th>
<th><span class="math inline">\vee</span></th>
<th><span class="math inline">\rightarrow</span></th>
<th><span class="math inline"></span></th>
<th><span class="math inline"></span></th>
<th><span class="math inline"></span></th>
<th><span class="math inline"></span></th>
<th><span class="math inline"></span></th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td></td>
<td></td>
<td><span class="math inline">a \wedge b</span></td>
<td><span class="math inline">a \vee b</span></td>
<td><span class="math inline">a \rightarrow b</span></td>
<td><span class="math inline"><em>a</em> ∧ <em>b</em></span></td>
<td><span class="math inline"><em>a</em> ∨ <em>b</em></span></td>
<td><span class="math inline"><em>a</em> → <em>b</em></span></td>
</tr>
<tr class="even">
<td>truth</td>
Expand All @@ -216,39 +204,39 @@ <h1 id="from-logic-rules-to-programming-constructs">From logic rules to
<tr class="odd">
<td>“trivial”</td>
<td>“impossible”</td>
<td><span class="math inline">a</span> and <span
class="math inline">b</span></td>
<td><span class="math inline">a</span> or <span
class="math inline">b</span></td>
<td><span class="math inline">a</span> gives <span
class="math inline">b</span></td>
<td><span class="math inline"><em>a</em></span> and <span
class="math inline"><em>b</em></span></td>
<td><span class="math inline"><em>a</em></span> or <span
class="math inline"><em>b</em></span></td>
<td><span class="math inline"><em>a</em></span> gives <span
class="math inline"><em>b</em></span></td>
</tr>
<tr class="even">
<td></td>
<td>shouldn’t get</td>
<td>got both</td>
<td>got at least one</td>
<td>given <span class="math inline">a</span>, we get <span
class="math inline">b</span></td>
<td>given <span class="math inline"><em>a</em></span>, we get <span
class="math inline"><em>b</em></span></td>
</tr>
</tbody>
</table>
<p>How can we define them? Think in terms of <em>derivation
trees</em>:</p>
<p><span class="math display">
<p><span class="math display">$$
\frac{
\frac{\frac{\,}{\text{a premise}} \; \frac{\,}{\text{another
premise}}}{\frac{\,}{\text{some fact}}} \;
\frac{\frac{\,}{\text{a premise}} \; \frac{\,}{\text{another
premise}}}{\frac{\,}{\text{another fact}}}}
{\text{final conclusion}}
</span></p>
$$</span></p>
<p>To define the connectives, we provide rules for using them: for
example, a rule <span class="math inline">\frac{a \; b}{c}</span>
example, a rule <span class="math inline">$\frac{a \; b}{c}$</span>
matches parts of the tree that have two premises, represented by
variables <span class="math inline">a</span> and <span
class="math inline">b</span>, and have any conclusion, represented by
variable <span class="math inline">c</span>.</p>
variables <span class="math inline"><em>a</em></span> and <span
class="math inline"><em>b</em></span>, and have any conclusion,
represented by variable <span class="math inline"><em>c</em></span>.</p>
<h2 id="rules-for-logical-connectives">Rules for Logical
Connectives</h2>
<p>Introduction rules say how to produce a connective. Elimination rules
Expand Down
Loading

0 comments on commit 1cc23d9

Please sign in to comment.