Skip to content

Commit 59563f1

Browse files
committed
html, css: Use simpler markup for hypotheses
Part of GH-35. This saves quite a bit of space.
1 parent 8fa7b24 commit 59563f1

File tree

4 files changed

+23
-26
lines changed

4 files changed

+23
-26
lines changed

alectryon/assets/alectryon.css

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ In any case, make an exception for comments:
312312
.alectryon-io .alectryon-message,
313313
.alectryon-io .alectryon-goals,
314314
.alectryon-io .alectryon-goal,
315-
.alectryon-io .goal-hyp,
315+
.alectryon-io .goal-hyps > div,
316316
.alectryon-io .goal-conclusion {
317317
border-radius: 0.15em;
318318
}
@@ -343,33 +343,34 @@ In any case, make an exception for comments:
343343
padding-bottom: 0.5em;
344344
}
345345

346-
.alectryon-io .goal-hyp,
346+
.alectryon-io .goal-hyps > div,
347347
.alectryon-io .goal-conclusion {
348348
background: #eeeeec;
349349
display: inline-block;
350350
padding: 0.15em 0.35em;
351351
}
352352

353-
.alectryon-io .goal-hyp {
353+
.alectryon-io .goal-hyps > div {
354354
align-items: baseline;
355355
display: inline-flex;
356356
margin: 0.15em 0.25em;
357357
}
358358

359-
.alectryon-io .hyp-names {
359+
.alectryon-io .goal-hyps > div > var {
360360
font-weight: 600;
361+
font-style: unset;
361362
/* Shrink the list of names, but let it grow as long as space is available. */
362363
flex-basis: min-content;
363364
flex-grow: 1;
364365
}
365366

366-
.alectryon-io .hyp-punct {
367+
.alectryon-io .goal-hyps > div b {
367368
font-weight: 600;
368369
margin: 0 0.5em;
369370
}
370371

371-
.alectryon-io .hyp-body-block,
372-
.alectryon-io .hyp-type-block {
372+
.alectryon-io .hyp-body,
373+
.alectryon-io .hyp-type {
373374
display: flex;
374375
align-items: baseline;
375376
}

alectryon/html.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -83,18 +83,16 @@ def gen_label(toggle, cls, *contents):
8383
def gen_hyps(self, hyps):
8484
with tags.div(cls="goal-hyps"):
8585
for hyp in hyps:
86-
with tags.div(cls="goal-hyp"):
87-
tags.span(", ".join(hyp.names), cls="hyp-names")
88-
with tags.span():
86+
with tags.div():
87+
tags.var(", ".join(hyp.names))
88+
with tags.span(): # For alignment
8989
if hyp.body:
90-
with tags.span(cls="hyp-body-block"):
91-
tags.span(":=", cls="hyp-punct")
92-
with tags.span(cls="hyp-body"):
93-
self.highlight(hyp.body)
94-
with tags.span(cls="hyp-type-block"):
95-
tags.span(":", cls="hyp-punct")
96-
with tags.span(cls="hyp-type"):
97-
self.highlight(hyp.type)
90+
with tags.span(cls="hyp-body"):
91+
tags.b(":=")
92+
self.highlight(hyp.body)
93+
with tags.span(cls="hyp-type"):
94+
tags.b(":")
95+
self.highlight(hyp.type)
9896

9997
def gen_goal(self, goal, toggle=None):
10098
"""Serialize a goal to HTML."""

recipes/mathjax.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,11 @@ Then we set up MathJax to render the proofs properly (look at the page source to
6161
<script type="text/javascript">
6262
function addMathDelimiters() {
6363
// 1. Find all relevant Alectryon tags
64-
var spans = document.querySelectorAll(".goal-conclusion .highlight, .goal-hyp .highlight");
64+
var spans = document.querySelectorAll(".goal-conclusion .highlight, .goal-hyps > div .highlight");
6565
6666
// 2. Wrap the contents of each in \(\) math delimiters
6767
spans.forEach(function (e) {
68-
var math = document.createTextNode('\\[' + e.innerText + '\\]');
69-
e.parentNode.replaceChild(math, e);
68+
e.innerText = '\\[' + e.innerText + '\\]';
7069
});
7170
}
7271
@@ -86,7 +85,7 @@ Then we set up MathJax to render the proofs properly (look at the page source to
8685
</script>
8786

8887
<style type="text/css"> /* Override MathJax margins */
89-
.hyp-type > *, .goal-conclusion > * {
88+
.goal-conclusion .highlight > *, .goal-hyps > div .highlight > * {
9089
margin: 0 !important;
9190
}
9291
</style>

recipes/output/mathjax.html

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,11 @@ <h1 class="title">Using MathJax with Alectryon</h1>
5858
<script type="text/javascript">
5959
function addMathDelimiters() {
6060
// 1. Find all relevant Alectryon tags
61-
var spans = document.querySelectorAll(".goal-conclusion .highlight, .goal-hyp .highlight");
61+
var spans = document.querySelectorAll(".goal-conclusion .highlight, .goal-hyps > div .highlight");
6262

6363
// 2. Wrap the contents of each in \(\) math delimiters
6464
spans.forEach(function (e) {
65-
var math = document.createTextNode('\\[' + e.innerText + '\\]');
66-
e.parentNode.replaceChild(math, e);
65+
e.innerText = '\\[' + e.innerText + '\\]';
6766
});
6867
}
6968

@@ -83,7 +82,7 @@ <h1 class="title">Using MathJax with Alectryon</h1>
8382
</script>
8483

8584
<style type="text/css"> /* Override MathJax margins */
86-
.hyp-type > *, .goal-conclusion > * {
85+
.goal-conclusion .highlight > *, .goal-hyps > div .highlight > * {
8786
margin: 0 !important;
8887
}
8988
</style><p>And finally we write the actual proofs:</p>

0 commit comments

Comments
 (0)