streamdown 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- streamdown-0.1.0/.gitignore +2 -0
- streamdown-0.1.0/24-bit-color.sh +99 -0
- streamdown-0.1.0/LICENSE.MIT +21 -0
- streamdown-0.1.0/PKG-INFO +63 -0
- streamdown-0.1.0/README.md +38 -0
- streamdown-0.1.0/error.txt +0 -0
- streamdown-0.1.0/links.md +3 -0
- streamdown-0.1.0/pyproject.toml +42 -0
- streamdown-0.1.0/streamdown/__init__.py +0 -0
- streamdown-0.1.0/streamdown/sd.py +547 -0
- streamdown-0.1.0/test_input.md +8 -0
- streamdown-0.1.0/tester.sh +10 -0
- streamdown-0.1.0/tests/code.md +32 -0
- streamdown-0.1.0/tests/example.md +55 -0
- streamdown-0.1.0/tests/fizzbuzz.md +162 -0
- streamdown-0.1.0/tests/inline.md +2 -0
- streamdown-0.1.0/tests/links.md +12 -0
- streamdown-0.1.0/tests/longer-example.md +18 -0
- streamdown-0.1.0/tests/mandlebrot.md +117 -0
- streamdown-0.1.0/tests/nested-example.md +23 -0
- streamdown-0.1.0/tests/outline.md +43 -0
- streamdown-0.1.0/tests/test_input.md +5 -0
- streamdown-0.1.0/todo.md +8 -0
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
#
|
|
3
|
+
# This file echoes a bunch of 24-bit color codes
|
|
4
|
+
# to the terminal to demonstrate its functionality.
|
|
5
|
+
# The foreground escape sequence is ^[38;2;<r>;<g>;<b>m
|
|
6
|
+
# The background escape sequence is ^[48;2;<r>;<g>;<b>m
|
|
7
|
+
# <r> <g> <b> range from 0 to 255 inclusive.
|
|
8
|
+
# The escape sequence ^[0m returns output to default
|
|
9
|
+
|
|
10
|
+
setBackgroundColor()
|
|
11
|
+
{
|
|
12
|
+
echo -en "\x1b[48;2;$1;$2;$3""m"
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
resetOutput()
|
|
16
|
+
{
|
|
17
|
+
echo -en "\x1b[0m\n"
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
# Gives a color $1/255 % along HSV
|
|
21
|
+
# Who knows what happens when $1 is outside 0-255
|
|
22
|
+
# Echoes "$red $green $blue" where
|
|
23
|
+
# $red $green and $blue are integers
|
|
24
|
+
# ranging between 0 and 255 inclusive
|
|
25
|
+
rainbowColor()
|
|
26
|
+
{
|
|
27
|
+
let h=$1/43
|
|
28
|
+
let f=$1-43*$h
|
|
29
|
+
let t=$f*255/43
|
|
30
|
+
let q=255-t
|
|
31
|
+
|
|
32
|
+
if [ $h -eq 0 ]
|
|
33
|
+
then
|
|
34
|
+
echo "255 $t 0"
|
|
35
|
+
elif [ $h -eq 1 ]
|
|
36
|
+
then
|
|
37
|
+
echo "$q 255 0"
|
|
38
|
+
elif [ $h -eq 2 ]
|
|
39
|
+
then
|
|
40
|
+
echo "0 255 $t"
|
|
41
|
+
elif [ $h -eq 3 ]
|
|
42
|
+
then
|
|
43
|
+
echo "0 $q 255"
|
|
44
|
+
elif [ $h -eq 4 ]
|
|
45
|
+
then
|
|
46
|
+
echo "$t 0 255"
|
|
47
|
+
elif [ $h -eq 5 ]
|
|
48
|
+
then
|
|
49
|
+
echo "255 0 $q"
|
|
50
|
+
else
|
|
51
|
+
# execution should never reach here
|
|
52
|
+
echo "0 0 0"
|
|
53
|
+
fi
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
for i in `seq 0 127`; do
|
|
57
|
+
setBackgroundColor $i 0 0
|
|
58
|
+
echo -en " "
|
|
59
|
+
done
|
|
60
|
+
resetOutput
|
|
61
|
+
for i in `seq 255 128`; do
|
|
62
|
+
setBackgroundColor $i 0 0
|
|
63
|
+
echo -en " "
|
|
64
|
+
done
|
|
65
|
+
resetOutput
|
|
66
|
+
|
|
67
|
+
for i in `seq 0 127`; do
|
|
68
|
+
setBackgroundColor 0 $i 0
|
|
69
|
+
echo -n " "
|
|
70
|
+
done
|
|
71
|
+
resetOutput
|
|
72
|
+
for i in `seq 255 128`; do
|
|
73
|
+
setBackgroundColor 0 $i 0
|
|
74
|
+
echo -n " "
|
|
75
|
+
done
|
|
76
|
+
resetOutput
|
|
77
|
+
|
|
78
|
+
for i in `seq 0 127`; do
|
|
79
|
+
setBackgroundColor 0 0 $i
|
|
80
|
+
echo -n " "
|
|
81
|
+
done
|
|
82
|
+
resetOutput
|
|
83
|
+
for i in `seq 255 128`; do
|
|
84
|
+
setBackgroundColor 0 0 $i
|
|
85
|
+
echo -n " "
|
|
86
|
+
done
|
|
87
|
+
resetOutput
|
|
88
|
+
|
|
89
|
+
for i in `seq 0 127`; do
|
|
90
|
+
setBackgroundColor `rainbowColor $i`
|
|
91
|
+
echo -n " "
|
|
92
|
+
done
|
|
93
|
+
resetOutput
|
|
94
|
+
for i in `seq 255 128`; do
|
|
95
|
+
setBackgroundColor `rainbowColor $i`
|
|
96
|
+
echo -n " "
|
|
97
|
+
done
|
|
98
|
+
resetOutput
|
|
99
|
+
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Chris McKenzie
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: streamdown
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A streaming markdown renderer for modern terminals with syntax highlighting
|
|
5
|
+
Project-URL: Homepage, https://github.com/kristopolous/Streamdown
|
|
6
|
+
Project-URL: Bug Tracker, https://github.com/kristopolous/Streamdown/issues
|
|
7
|
+
Author-email: Chris McKenzie <kristopolous@yahoo.com>
|
|
8
|
+
License: MIT
|
|
9
|
+
License-File: LICENSE.MIT
|
|
10
|
+
Keywords: cli,markdown,renderer,syntax-highlighting,terminal
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Topic :: Text Processing :: Markup
|
|
21
|
+
Classifier: Topic :: Utilities
|
|
22
|
+
Requires-Python: >=3.8
|
|
23
|
+
Requires-Dist: pygments
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
|
|
26
|
+
# Streamdown
|
|
27
|
+
|
|
28
|
+
[](https://badge.fury.io/py/streamdown)
|
|
29
|
+
|
|
30
|
+
I needed a streaming Markdown TUI CLI shell parser and honestly all the ones I found lacking. They were broken or janky in some kind of way. So here we go. From the ground up. It's a bad idea but it has to be done.
|
|
31
|
+
|
|
32
|
+
[sd demo](https://github.com/user-attachments/assets/48dba6fa-2282-4be9-8087-a2ad8e7c7d12)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
This will work with [simonw's llm](https://github.com/simonw/llm) unlike with [richify.py](https://github.com/gianlucatruda/richify) which jumps around the page or blocks with an elipses or [glow](https://github.com/charmbracelet/glow) which buffers everything, this streams and does exactly what you want.
|
|
36
|
+
|
|
37
|
+
## Some Features
|
|
38
|
+
|
|
39
|
+
#### Provides clean copyable code for long code blocks and short terminals.
|
|
40
|
+

|
|
41
|
+
|
|
42
|
+
#### Does OSC 8 links for modern terminals.
|
|
43
|
+
|
|
44
|
+
[links.webm](https://github.com/user-attachments/assets/a5f71791-7c58-4183-ad3b-309f470c08a3)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
#### Doesn't consume characters like _ and * as style when they are in `blocks like this` because `_they_can_be_varaiables_`
|
|
48
|
+

|
|
49
|
+
|
|
50
|
+
## Demo
|
|
51
|
+
Do this
|
|
52
|
+
|
|
53
|
+
$ ./tester.sh tests/*md | ./sd.py
|
|
54
|
+
|
|
55
|
+
Certainly room for improvement and I'll probably continue to make them
|
|
56
|
+
|
|
57
|
+
* tables don't currently stream. it's actually a sophisticated problem. i've got a solution but I want to just have the llm do it without having to think about it. I am theoretically not always this lazy.
|
|
58
|
+
|
|
59
|
+
* ingest the first 2 rows. compute the division from there and do wrap on the cells
|
|
60
|
+
|
|
61
|
+
* alternatively do equal width and permit sub optimal widths.
|
|
62
|
+
|
|
63
|
+
* lastly, this is inspired from sqlite, we can do key/value rows as individual tables, which changes the layout but makes large row tables not cascade down the screen in some wraparound mess.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Streamdown
|
|
2
|
+
|
|
3
|
+
[](https://badge.fury.io/py/streamdown)
|
|
4
|
+
|
|
5
|
+
I needed a streaming Markdown TUI CLI shell parser and honestly all the ones I found lacking. They were broken or janky in some kind of way. So here we go. From the ground up. It's a bad idea but it has to be done.
|
|
6
|
+
|
|
7
|
+
[sd demo](https://github.com/user-attachments/assets/48dba6fa-2282-4be9-8087-a2ad8e7c7d12)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
This will work with [simonw's llm](https://github.com/simonw/llm) unlike with [richify.py](https://github.com/gianlucatruda/richify) which jumps around the page or blocks with an elipses or [glow](https://github.com/charmbracelet/glow) which buffers everything, this streams and does exactly what you want.
|
|
11
|
+
|
|
12
|
+
## Some Features
|
|
13
|
+
|
|
14
|
+
#### Provides clean copyable code for long code blocks and short terminals.
|
|
15
|
+

|
|
16
|
+
|
|
17
|
+
#### Does OSC 8 links for modern terminals.
|
|
18
|
+
|
|
19
|
+
[links.webm](https://github.com/user-attachments/assets/a5f71791-7c58-4183-ad3b-309f470c08a3)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
#### Doesn't consume characters like _ and * as style when they are in `blocks like this` because `_they_can_be_varaiables_`
|
|
23
|
+

|
|
24
|
+
|
|
25
|
+
## Demo
|
|
26
|
+
Do this
|
|
27
|
+
|
|
28
|
+
$ ./tester.sh tests/*md | ./sd.py
|
|
29
|
+
|
|
30
|
+
Certainly room for improvement and I'll probably continue to make them
|
|
31
|
+
|
|
32
|
+
* tables don't currently stream. it's actually a sophisticated problem. i've got a solution but I want to just have the llm do it without having to think about it. I am theoretically not always this lazy.
|
|
33
|
+
|
|
34
|
+
* ingest the first 2 rows. compute the division from there and do wrap on the cells
|
|
35
|
+
|
|
36
|
+
* alternatively do equal width and permit sub optimal widths.
|
|
37
|
+
|
|
38
|
+
* lastly, this is inspired from sqlite, we can do key/value rows as individual tables, which changes the layout but makes large row tables not cascade down the screen in some wraparound mess.
|
|
File without changes
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "streamdown"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "A streaming markdown renderer for modern terminals with syntax highlighting"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.8"
|
|
11
|
+
license = {text = "MIT"}
|
|
12
|
+
authors = [
|
|
13
|
+
{name = "Chris McKenzie", email = "kristopolous@yahoo.com"},
|
|
14
|
+
]
|
|
15
|
+
keywords = ["markdown", "terminal", "renderer", "cli", "syntax-highlighting"]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 4 - Beta",
|
|
18
|
+
"Environment :: Console",
|
|
19
|
+
"Intended Audience :: Developers",
|
|
20
|
+
"License :: OSI Approved :: MIT License",
|
|
21
|
+
"Programming Language :: Python :: 3",
|
|
22
|
+
"Programming Language :: Python :: 3.8",
|
|
23
|
+
"Programming Language :: Python :: 3.9",
|
|
24
|
+
"Programming Language :: Python :: 3.10",
|
|
25
|
+
"Programming Language :: Python :: 3.11",
|
|
26
|
+
"Topic :: Text Processing :: Markup",
|
|
27
|
+
"Topic :: Utilities",
|
|
28
|
+
]
|
|
29
|
+
dependencies = [
|
|
30
|
+
"pygments",
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
[project.urls]
|
|
34
|
+
"Homepage" = "https://github.com/kristopolous/Streamdown"
|
|
35
|
+
"Bug Tracker" = "https://github.com/kristopolous/Streamdown/issues"
|
|
36
|
+
|
|
37
|
+
[project.scripts]
|
|
38
|
+
streamdown = "streamdown.sd:main"
|
|
39
|
+
sd = "streamdown.sd:main"
|
|
40
|
+
|
|
41
|
+
[tool.hatch.build.targets.wheel]
|
|
42
|
+
packages = ["streamdown"]
|
|
File without changes
|