Skip to content

Commit 1ddd4c4

Browse files
committed
Minor improvements
1 parent 8641192 commit 1ddd4c4

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

src/liblet/const.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@
55
GV_FONT_NAME = FONT_NAME
66
GV_FONT_SIZE = '12' # must be a string
77
CUSTOM_CSS = f"""
8-
@import url('https://fonts.googleapis.com/css2?family=Fira+Code&display=swap');
8+
@import url('https://fonts.googleapis.com/css2?family={"+".join(FONT_NAME.split())}&display=swap');
9+
10+
pre, code {{
11+
font-family: '{FONT_NAME}', monospace;
12+
font-variant-ligatures: contextual common-ligatures;
13+
line-height: 1;
14+
}}
915
1016
table.liblet {{
1117
border-collapse: collapse;
@@ -17,7 +23,7 @@
1723
table.liblet td {{
1824
border: 1px solid black;
1925
padding: 0.5em;
20-
text-align: center;
26+
text-align: left;
2127
}}
2228
2329
table.liblet th {{

src/liblet/display.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,7 @@ def _fmt(r, c):
701701
+ '<td>'.join(_fmt(r, c) for c in cols)
702702
for r in rows
703703
)
704-
return liblet_table(f'{head}\n{body}')
704+
return liblet_table(f'{head}\n{body}', True)
705705
rows = list(self.data.keys())
706706
if self.fmt['rows_sort']:
707707
rows = sorted(rows)
@@ -712,7 +712,7 @@ def _fmt(r, c):
712712
letstr(self.data[r], self.fmt['elem_sep'], sort=self.fmt['letstr_sort'], remove_outer=True),
713713
)
714714
for r in rows
715-
)
715+
), True
716716
)
717717

718718

@@ -735,7 +735,7 @@ def _repr_html_(self):
735735
)
736736
+ '</pre></td>'
737737
for l in range(N, L - 1, -1) # noqa: E741
738-
)
738+
), True
739739
)
740740

741741

@@ -777,9 +777,8 @@ def embed_css(custom_css=CUSTOM_CSS):
777777
return HTML(f'<style>{custom_css}</style>')
778778

779779

780-
def liblet_table(content):
781-
return HTML(f'<table class=liblet>{content}</table>')
782-
780+
def liblet_table(content, as_str = False):
781+
return f'<table class="liblet" data-quarto-disable-processing="true">{content}</table>' if as_str else HTML(f'<table class=liblet>{content}</table>')
783782

784783
def resized_svg_repr(obj, width=800, height=600):
785784
if hasattr(obj, '_repr_image_svg_xml'):

src/liblet/grammar.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,13 +197,13 @@ def _repr_html_(self): # pragma: no cover
197197
rows.append(
198198
(
199199
min(_[0] for _ in rhssl),
200-
'<th><pre>{}</pre><td style="text-align:left"><pre>{}</pre>'.format(
200+
'<th><pre>{}</pre></th><td><pre>{}</pre></td>'.format(
201201
_letlrhstostr(lhs),
202202
' | '.join(f'{_letlrhstostr(_[1].rhs)}<sub>({_[0]})</sub>' for _ in rhssl),
203203
),
204204
)
205205
)
206-
return liblet_table('<tr>' + '<tr>'.join(_[1] for _ in sorted(rows)))
206+
return liblet_table('<tr>' + '</tr><tr>'.join(_[1] for _ in sorted(rows)) + '</tr>', True)
207207

208208

209209
@total_ordering

0 commit comments

Comments
 (0)