Skip to content

Commit 7071969

Browse files
restore accidentally commented ansi example
1 parent 2ae62ed commit 7071969

File tree

1 file changed

+22
-24
lines changed

1 file changed

+22
-24
lines changed

tests/docs/typst/ansi/ansi-colors.qmd

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,28 @@ format:
88
---
99

1010
```{python}
11-
import ansi2html
12-
# from ansi2html import Ansi2HTMLConverter
11+
from ansi2html import Ansi2HTMLConverter
1312
from IPython.core.display import display, Markdown
1413
15-
print(ansi2html)
16-
# conv = ansi2html.Ansi2HTMLConverter()
17-
# line = ''
18-
# lines = []
19-
# for i in range(256):
20-
# if (i == 8) or (i >=16 and i%6 == 4):
21-
# lines.append(line)
22-
# line = ''
23-
# line += f'\x1b[38;5;{i}m{i:>3} '
24-
# lines.append(line)
25-
# # the center 216 is a 6x6x6 cube
26-
# # pack it in two columns of three 6x6 squares
27-
# lines2 = [lines[0], lines[1]]
28-
# for i in range(0, 6, 2):
29-
# for j in range(6):
30-
# lines2.append(lines[i*6 + j + 2] + lines[i*6 + 6 + j + 2])
31-
# lines2.append(lines[38] + lines[39])
32-
# lines2.append(lines[40] + lines[41])
33-
# display(Markdown(
34-
# '::: {html-pre-tag-processing="parse"}\n\n```{=html}\n'
35-
# + conv.convert('\n'.join(lines2)) +
36-
# '\n```\n:::\n'))
14+
conv = Ansi2HTMLConverter()
15+
line = ''
16+
lines = []
17+
for i in range(256):
18+
if (i == 8) or (i >=16 and i%6 == 4):
19+
lines.append(line)
20+
line = ''
21+
line += f'\x1b[38;5;{i}m{i:>3} '
22+
lines.append(line)
23+
# the center 216 is a 6x6x6 cube
24+
# pack it in two columns of three 6x6 squares
25+
lines2 = [lines[0], lines[1]]
26+
for i in range(0, 6, 2):
27+
for j in range(6):
28+
lines2.append(lines[i*6 + j + 2] + lines[i*6 + 6 + j + 2])
29+
lines2.append(lines[38] + lines[39])
30+
lines2.append(lines[40] + lines[41])
31+
display(Markdown(
32+
'::: {html-pre-tag-processing="parse"}\n\n```{=html}\n'
33+
+ conv.convert('\n'.join(lines2)) +
34+
'\n```\n:::\n'))
3735
```

0 commit comments

Comments
 (0)