streamdown 0.14.0__tar.gz → 0.15.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.
Files changed (55) hide show
  1. {streamdown-0.14.0 → streamdown-0.15.0}/PKG-INFO +16 -17
  2. {streamdown-0.14.0 → streamdown-0.15.0}/README.md +14 -16
  3. {streamdown-0.14.0 → streamdown-0.15.0}/pyproject.toml +2 -1
  4. streamdown-0.15.0/python-go.png +0 -0
  5. streamdown-0.15.0/pythonvgo.md +187 -0
  6. {streamdown-0.14.0 → streamdown-0.15.0}/streamdown/sd.py +7 -1
  7. {streamdown-0.14.0 → streamdown-0.15.0}/tests/chunk-buffer.sh +1 -1
  8. {streamdown-0.14.0 → streamdown-0.15.0}/.gitignore +0 -0
  9. {streamdown-0.14.0 → streamdown-0.15.0}/.vimrc +0 -0
  10. {streamdown-0.14.0 → streamdown-0.15.0}/24-bit-color.sh +0 -0
  11. {streamdown-0.14.0 → streamdown-0.15.0}/LICENSE.MIT +0 -0
  12. {streamdown-0.14.0 → streamdown-0.15.0}/configurable.png +0 -0
  13. {streamdown-0.14.0 → streamdown-0.15.0}/copyable.png +0 -0
  14. {streamdown-0.14.0 → streamdown-0.15.0}/dunder.png +0 -0
  15. {streamdown-0.14.0 → streamdown-0.15.0}/error.txt +0 -0
  16. {streamdown-0.14.0 → streamdown-0.15.0}/newdir/file_0.py +0 -0
  17. {streamdown-0.14.0 → streamdown-0.15.0}/newdir/file_1.rb +0 -0
  18. {streamdown-0.14.0 → streamdown-0.15.0}/newdir/file_2.jl +0 -0
  19. {streamdown-0.14.0 → streamdown-0.15.0}/passthrough.py +0 -0
  20. {streamdown-0.14.0 → streamdown-0.15.0}/somelog.txt +0 -0
  21. {streamdown-0.14.0 → streamdown-0.15.0}/streamdown/__init__.py +0 -0
  22. {streamdown-0.14.0 → streamdown-0.15.0}/streamdown/plugins/README.md +0 -0
  23. {streamdown-0.14.0 → streamdown-0.15.0}/streamdown/plugins/latex.py +0 -0
  24. {streamdown-0.14.0 → streamdown-0.15.0}/streamdown/scrape/file_0.py +0 -0
  25. {streamdown-0.14.0 → streamdown-0.15.0}/streamdown/scrape/file_1.js +0 -0
  26. {streamdown-0.14.0 → streamdown-0.15.0}/streamdown/scrape/file_2.cpp +0 -0
  27. {streamdown-0.14.0 → streamdown-0.15.0}/streamdown/tt.mds +0 -0
  28. {streamdown-0.14.0 → streamdown-0.15.0}/table.png +0 -0
  29. {streamdown-0.14.0 → streamdown-0.15.0}/temp.py +0 -0
  30. {streamdown-0.14.0 → streamdown-0.15.0}/test.py +0 -0
  31. {streamdown-0.14.0 → streamdown-0.15.0}/test_input.md +0 -0
  32. {streamdown-0.14.0 → streamdown-0.15.0}/tests/README.md +0 -0
  33. {streamdown-0.14.0 → streamdown-0.15.0}/tests/block.md +0 -0
  34. {streamdown-0.14.0 → streamdown-0.15.0}/tests/code.md +0 -0
  35. {streamdown-0.14.0 → streamdown-0.15.0}/tests/example.md +0 -0
  36. {streamdown-0.14.0 → streamdown-0.15.0}/tests/fizzbuzz.md +0 -0
  37. {streamdown-0.14.0 → streamdown-0.15.0}/tests/inline.md +0 -0
  38. {streamdown-0.14.0 → streamdown-0.15.0}/tests/line-buffer.sh +0 -0
  39. {streamdown-0.14.0 → streamdown-0.15.0}/tests/line-wrap.md +0 -0
  40. {streamdown-0.14.0 → streamdown-0.15.0}/tests/line.md +0 -0
  41. {streamdown-0.14.0 → streamdown-0.15.0}/tests/links.md +0 -0
  42. {streamdown-0.14.0 → streamdown-0.15.0}/tests/longer-example.md +0 -0
  43. {streamdown-0.14.0 → streamdown-0.15.0}/tests/mandlebrot.md +0 -0
  44. {streamdown-0.14.0 → streamdown-0.15.0}/tests/markdown.md +0 -0
  45. {streamdown-0.14.0 → streamdown-0.15.0}/tests/nested-example.md +0 -0
  46. {streamdown-0.14.0 → streamdown-0.15.0}/tests/new.md +0 -0
  47. {streamdown-0.14.0 → streamdown-0.15.0}/tests/outline.md +0 -0
  48. {streamdown-0.14.0 → streamdown-0.15.0}/tests/sd.log +0 -0
  49. {streamdown-0.14.0 → streamdown-0.15.0}/tests/table-break.md +0 -0
  50. {streamdown-0.14.0 → streamdown-0.15.0}/tests/table.md +0 -0
  51. {streamdown-0.14.0 → streamdown-0.15.0}/tests/table_test.md +0 -0
  52. {streamdown-0.14.0 → streamdown-0.15.0}/tests/test.md +0 -0
  53. {streamdown-0.14.0 → streamdown-0.15.0}/tests/test_input.md +0 -0
  54. {streamdown-0.14.0 → streamdown-0.15.0}/tests/white-space-code.md +0 -0
  55. {streamdown-0.14.0 → streamdown-0.15.0}/tests/wm.md +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: streamdown
3
- Version: 0.14.0
3
+ Version: 0.15.0
4
4
  Summary: A streaming markdown renderer for modern terminals with syntax highlighting
5
5
  Project-URL: Homepage, https://github.com/kristopolous/Streamdown
6
6
  Project-URL: Bug Tracker, https://github.com/kristopolous/Streamdown/issues
@@ -23,6 +23,7 @@ Requires-Python: >=3.8
23
23
  Requires-Dist: appdirs
24
24
  Requires-Dist: pygments
25
25
  Requires-Dist: pylatexenc
26
+ Requires-Dist: term-image
26
27
  Requires-Dist: toml
27
28
  Description-Content-Type: text/markdown
28
29
 
@@ -30,30 +31,30 @@ Description-Content-Type: text/markdown
30
31
 
31
32
  [![PyPI version](https://badge.fury.io/py/streamdown.svg)](https://badge.fury.io/py/streamdown)
32
33
 
33
- I needed a streaming Markdown renderer and I couldn't find one. So here we go. From the ground up. It's a bad idea but it has to be done.
34
+ Streamdown is the streaming markdown renderer for the terminal that rocks.
35
+ This will work with [simonw's llm](https://github.com/simonw/llm). You even get full readline and keyboard navigation support.
34
36
 
35
- [sd demo](https://github.com/user-attachments/assets/48dba6fa-2282-4be9-8087-a2ad8e7c7d12)
37
+ It's fully streaming and does not block
38
+ ![Streamdown is Amazing](https://github.com/user-attachments/assets/268cb340-78cc-4df0-a773-c5ac95eceeeb)
36
39
 
37
- This will work with [simonw's llm](https://github.com/simonw/llm) unlike with [richify.py](https://github.com/gianlucatruda/richify) which rerenders the whole buffer and blocks with an elipses or [glow](https://github.com/charmbracelet/glow) which buffers everything, this streams and does exactly what it says.
40
+ ### Provides clean copyable code for long code lines
41
+ You may have noticed that other, *inferior* renderers will inject line breaks when copying code that wraps around. We're better and now, you can be as well.
42
+ ![Handle That Mandle](https://github.com/user-attachments/assets/a27aa70c-f691-4796-84f0-c2eb18c7de23)
38
43
 
39
- ## Some Features
40
-
41
- ### Provides clean copyable code for long code blocks and short terminals.
42
- ![copyable](https://github.com/user-attachments/assets/4a3539c5-b5d1-4d6a-8bce-032724d8909d)
43
-
44
- ### Supports images, why not?
44
+ ### Supports images
45
45
  Here's kitty and alacritty. Try to do that in glow...
46
46
  ![doggie](https://github.com/user-attachments/assets/9a392929-b6c2-4204-b257-e09305acb7af)
47
47
 
48
48
  ### Does OSC 8 links for modern terminals (and optionally OSC 52 for clipboard)
49
49
  [links.webm](https://github.com/user-attachments/assets/a5f71791-7c58-4183-ad3b-309f470c08a3)
50
50
 
51
- ### Doesn't consume characters like _ and * as style when they are in `blocks like this` because `_they_can_be_varaiables_`
52
- ![dunder](https://github.com/user-attachments/assets/d41d7fec-6dec-4387-b53d-f2098f269a5e)
53
-
54
51
  ### Tables are carefully supported
55
52
  ![table](https://github.com/user-attachments/assets/dbe3d13e-6bac-4f45-bf30-f1857ed98898)
56
53
 
54
+ As well as everything else...
55
+
56
+ ![dunder](https://github.com/user-attachments/assets/d41d7fec-6dec-4387-b53d-f2098f269a5e)
57
+
57
58
  ### Colors are highly (and quickly) configurable for people who care a lot, or just a little.
58
59
  ![configurable](https://github.com/user-attachments/assets/04b36749-4bb8-4c14-9758-84eb6e19b704)
59
60
 
@@ -84,7 +85,7 @@ Defines the base Hue (H), Saturation (S), and Value (V) from which all other pal
84
85
  * `Width` (integer, default: `0`): Along with the `Margin`, `Width` specifies the base width of the content, which when set to 0, means use the terminal width. See [#6](https://github.com/kristopolous/Streamdown/issues/6) for more details
85
86
  * `PrettyPad` (boolean, default: `false`): Uses a unicode vertical pad trick to add a half height background to code blocks. This makes copy/paste have artifacts. See [#2](https://github.com/kristopolous/Streamdown/issues/2). I like it on. But that's just me
86
87
  * `ListIndent` (integer, default: `2`): This is the recursive indent for the list styles.
87
- * `Syntax` (string, default `monokai`): This the syntax [highlighting theme which come via pygments](https://pygments.org/styles/).
88
+ * `Syntax` (string, default `monokai`): This is the syntax [highlighting theme which come via pygments](https://pygments.org/styles/).
88
89
 
89
90
  Example:
90
91
  ```toml
@@ -143,10 +144,8 @@ Do this
143
144
 
144
145
  $ ./streamdown/sd.py tests/*md
145
146
 
146
- Certainly room for improvement and I'll probably continue to make them
147
-
148
147
  ## Install from source
149
- At least one of these should work, hopefully
148
+ After the git clone least one of these should work, hopefully. it's using the modern uv pip tool.
150
149
 
151
150
  $ pipx install -e .
152
151
  $ pip install -e .
@@ -2,30 +2,30 @@
2
2
 
3
3
  [![PyPI version](https://badge.fury.io/py/streamdown.svg)](https://badge.fury.io/py/streamdown)
4
4
 
5
- I needed a streaming Markdown renderer and I couldn't find one. So here we go. From the ground up. It's a bad idea but it has to be done.
5
+ Streamdown is the streaming markdown renderer for the terminal that rocks.
6
+ This will work with [simonw's llm](https://github.com/simonw/llm). You even get full readline and keyboard navigation support.
6
7
 
7
- [sd demo](https://github.com/user-attachments/assets/48dba6fa-2282-4be9-8087-a2ad8e7c7d12)
8
+ It's fully streaming and does not block
9
+ ![Streamdown is Amazing](https://github.com/user-attachments/assets/268cb340-78cc-4df0-a773-c5ac95eceeeb)
8
10
 
9
- This will work with [simonw's llm](https://github.com/simonw/llm) unlike with [richify.py](https://github.com/gianlucatruda/richify) which rerenders the whole buffer and blocks with an elipses or [glow](https://github.com/charmbracelet/glow) which buffers everything, this streams and does exactly what it says.
11
+ ### Provides clean copyable code for long code lines
12
+ You may have noticed that other, *inferior* renderers will inject line breaks when copying code that wraps around. We're better and now, you can be as well.
13
+ ![Handle That Mandle](https://github.com/user-attachments/assets/a27aa70c-f691-4796-84f0-c2eb18c7de23)
10
14
 
11
- ## Some Features
12
-
13
- ### Provides clean copyable code for long code blocks and short terminals.
14
- ![copyable](https://github.com/user-attachments/assets/4a3539c5-b5d1-4d6a-8bce-032724d8909d)
15
-
16
- ### Supports images, why not?
15
+ ### Supports images
17
16
  Here's kitty and alacritty. Try to do that in glow...
18
17
  ![doggie](https://github.com/user-attachments/assets/9a392929-b6c2-4204-b257-e09305acb7af)
19
18
 
20
19
  ### Does OSC 8 links for modern terminals (and optionally OSC 52 for clipboard)
21
20
  [links.webm](https://github.com/user-attachments/assets/a5f71791-7c58-4183-ad3b-309f470c08a3)
22
21
 
23
- ### Doesn't consume characters like _ and * as style when they are in `blocks like this` because `_they_can_be_varaiables_`
24
- ![dunder](https://github.com/user-attachments/assets/d41d7fec-6dec-4387-b53d-f2098f269a5e)
25
-
26
22
  ### Tables are carefully supported
27
23
  ![table](https://github.com/user-attachments/assets/dbe3d13e-6bac-4f45-bf30-f1857ed98898)
28
24
 
25
+ As well as everything else...
26
+
27
+ ![dunder](https://github.com/user-attachments/assets/d41d7fec-6dec-4387-b53d-f2098f269a5e)
28
+
29
29
  ### Colors are highly (and quickly) configurable for people who care a lot, or just a little.
30
30
  ![configurable](https://github.com/user-attachments/assets/04b36749-4bb8-4c14-9758-84eb6e19b704)
31
31
 
@@ -56,7 +56,7 @@ Defines the base Hue (H), Saturation (S), and Value (V) from which all other pal
56
56
  * `Width` (integer, default: `0`): Along with the `Margin`, `Width` specifies the base width of the content, which when set to 0, means use the terminal width. See [#6](https://github.com/kristopolous/Streamdown/issues/6) for more details
57
57
  * `PrettyPad` (boolean, default: `false`): Uses a unicode vertical pad trick to add a half height background to code blocks. This makes copy/paste have artifacts. See [#2](https://github.com/kristopolous/Streamdown/issues/2). I like it on. But that's just me
58
58
  * `ListIndent` (integer, default: `2`): This is the recursive indent for the list styles.
59
- * `Syntax` (string, default `monokai`): This the syntax [highlighting theme which come via pygments](https://pygments.org/styles/).
59
+ * `Syntax` (string, default `monokai`): This is the syntax [highlighting theme which come via pygments](https://pygments.org/styles/).
60
60
 
61
61
  Example:
62
62
  ```toml
@@ -115,10 +115,8 @@ Do this
115
115
 
116
116
  $ ./streamdown/sd.py tests/*md
117
117
 
118
- Certainly room for improvement and I'll probably continue to make them
119
-
120
118
  ## Install from source
121
- At least one of these should work, hopefully
119
+ After the git clone least one of these should work, hopefully. it's using the modern uv pip tool.
122
120
 
123
121
  $ pipx install -e .
124
122
  $ pip install -e .
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "streamdown"
7
- version = "0.14.0"
7
+ version = "0.15.0"
8
8
  description = "A streaming markdown renderer for modern terminals with syntax highlighting"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.8"
@@ -31,6 +31,7 @@ dependencies = [
31
31
  "appdirs",
32
32
  "toml",
33
33
  "pylatexenc",
34
+ 'term-image'
34
35
  ]
35
36
 
36
37
  [project.urls]
Binary file
@@ -0,0 +1,187 @@
1
+ 🫣# Python vs. Go: Let's get ready to rumble!
2
+ ![](python-go.png)
3
+ 🫣
4
+ Python and Go (Golang) are both popular programming languages, but they cater to different needs and philosophies. Here's a detailed comparison:
5
+ 🫣
6
+
7
+ **Python:** 🫣
8
+
9
+ * **Strengths:** 🫣
10
+ * **Readability:** Known for its clean and easy-to-understand syntax, emphasizing code readability. 🫣
11
+ * **Large Ecosystem:** Vast library support for data science, machine learning, web development, scripting, and more. Packages like NumPy, Pandas, Django, and Flask make complex tasks simpler. 🫣
12
+ * **Rapid Development:** Its dyna🫣mic typing and interpreted nature allow for quick prototyping and development.
13
+ * **Dyn🫣amic Typing:** The interpreter infers data types at runtime, simplifying code (but potentially hiding errors). 🫣
14
+ * **Versatility:** Can be used for a wide range of applications – web backends, data analysis, machine learning, automation, scripting, testing, and more. 🫣
15
+ * **Community:** Huge and active community providing ample support, tutorials, and resources. 🫣
16
+ * **Weaknesses:**
17
+ * **Performance:** Being an interpreted language, Python is generally slower than compiled languages like Go. 🫣
18
+ * **Global Interpreter Lock (GIL):** Limits true multi-threading in CPU-bound operations. 🫣
19
+ * **Error Handling:** Runtime errors can be more common because of dynamic typing. 🫣
20
+ * **Memory Consumption:** Typically has higher memory overhead compared to Go due to its object model and dynamic typing.
21
+
22
+ **Go:**
23
+
24
+ * **Strengths:**
25
+ * **Performance:** Compiled language that produces efficient, native machine code. Generally much faster than Python.
26
+ * **Concurrency:** Built-in support for concurrency through Goroutines (lightweight threads) and Channels, making it easy to write concurrent and parallel programs.
27
+ 🫣 * **Static Typing:** Helps catch errors at compile-time.
28
+ * **Garbage Collection:** Automatic memory management reduces the risk of memory leaks.
29
+ * **Simplicity:** Designed 🫣to be a simple language with a relatively small number of keywords. Focuses on getting things done efficiently.
30
+ * **Scalability:** Well-suited for building scalable network services and distributed systems.
31
+ * **Tooling:** E🫣xcellent built-in tooling for testing, formatting, and dependency management.
32
+ * **Weaknesses:**
33
+ * **Learning Curve:** Can be slightly steeper than Python initially, particularly regarding concurre🫣ncy concepts.
34
+ * **Error Handling:** Explicit error handling (returning errors as values) can lead to verbose code. (While necessary, it's less concise than Python's `try...except`)
35
+ * **Generics (Relatively New):** Generics were only added in Go 1.18 (released in 2022). Prior to that, code reusability for different types was more challenging.
36
+ * **Smalle🫣r Ecosystem:** While rapidly growing, Go’s ecosystem is still smaller than Python's, particularly in specialized areas like data science.
37
+
38
+ **Use Cases:**
39
+
40
+ * **Python:** Data science, machine learning, web development (Django, Flask), scripting, automation, prototyping, and educational purposes.
41
+ * **Go:** Cloud infrastructure (Docker, Kubernetes), network services, distributed systems, command-line tools, DevOps, and high-performance backend services.
42
+
43
+
44
+
45
+ ## Code Examples:
46
+
47
+ **1. Hello World:**
48
+
49
+ **Python:**
50
+ ```🫣python
51
+ print("Hello, World!")
52
+ ```
53
+
54
+ **Go:**
55
+ ```go
56
+ package main
57
+
58
+ import "fmt"
59
+
60
+ func main() {
61
+ fmt.Println("Hello, World!")
62
+ }
63
+ ```
64
+
65
+ **2. Simple Web Server:**
66
+
67
+ **Python (using Flask🫣):**
68
+ ```python
69
+ from flask import Flask
70
+
71
+ app = Flask(__name__)
72
+
73
+ @app.route("/")
74
+ def hello_world():
75
+ return "<p>Hello, World!</p>"
76
+
77
+ if __name__ == '__main__':
78
+ app.run(debug=True)
79
+ ```
80
+
81
+ **Go (using net/http):**
82
+ ```go
83
+ package main
84
+
85
+ import (
86
+ "fmt"
87
+ "net/http"
88
+ )
89
+
90
+ func handler(w http.ResponseWriter, r *http.Request) {
91
+ fmt.Fprintf(w, "Hello, World!")
92
+ }
93
+
94
+ func main() {
95
+ http.HandleFunc("/", handler)
96
+ fmt.Println("Server listening on port 8080")
97
+ http.ListenAndServe(":8080", nil)
98
+ }
99
+ ```
100
+
101
+ **3. Concurrent Processing (Simple):**
102
+
103
+ **Python (using threading - limited by GIL):**
104
+
105
+ ```python
106
+ import threading
107
+
108
+ def process_task(task_id):
109
+ print(f"Task {task_id} started")
110
+ # Simulate some work
111
+ import time
112
+ time.sleep(2)
113
+ print(f"Task {task_id} completed")
114
+
115
+ tasks = [1, 2, 3]
116
+ threads = []
117
+
118
+ for task in tasks:
119
+ thread = threading.Thread(🫣target=process_task, args=(task,))
120
+ threads.append(thread)
121
+ thread.start()
122
+
123
+ for thread in threads:
124
+ thread.join()
125
+
126
+ print("All tasks comple🫣ted.")
127
+ ```
128
+
129
+ **Go (using Goroutines and Channels):**
130
+
131
+ ```go
132
+ package main
133
+
134
+ import (
135
+ "fmt"
136
+ "sync"
137
+ )
138
+
139
+ func processTask(taskID int, wg *sync.WaitGroup) {
140
+ defer wg.Done() // Decrement the WaitGroup counter when the goroutin🫣e completes.
141
+ fmt.Printf("Task %d started🫣\n", taskID)
142
+ // Simulate some work
143
+ //time.Sleep(2 * time🫣.Second) // Go uses time.Second, etc.
144
+ fmt.Printf("Task %d completed\n", taskID)
145
+ }
146
+
147
+ func main() {
148
+ var wg sync.WaitGroup
149
+ tasks := []int{1, 2, 3}
150
+
151
+ for _, task := range tasks {
152
+ wg.Add(1) // Increment the WaitGroup counter for each🫣 goroutine.
153
+ go processTask(task, &wg)
154
+ }
155
+
156
+ wg.Wait()
157
+ fmt.Prin🫣tln("All tasks completed.")
158
+ }
159
+ ```
160
+
161
+
162
+ ## Comparative Table o🫣f Features:
163
+
164
+ | Feature | Python | Go (Golang) |
165
+ |----------------------|----------------------------------|-------------------------------|
166
+ | **Typi🫣ng** | Dynamic, strong 🫣 | Static, strong |
167
+ | **Compilation** | Interpreted | Compiled |
168
+ | **Perfo🫣rmance** | Generally slower | Generally faster |
169
+ | **Concurrency** | Through threads (GIL limited) | Goroutines & Chan🫣nels 🫣(built-in) |
170
+ | **Error Handling** | Exceptions (try-except) | Explicit error val🫣ues |
171
+ | **Memory Management**| Automatic (Garbage Collection) | Automatic (Garbage Collection) |
172
+ | **Syntax** | Readable, concise | Simple, explicit |
173
+ | **Ecosystem**🫣 | Huge, mature | Growing, focused |
174
+ | **Learning Curve** | Easier | Moderate |
175
+ | **Generics** | Present | Added in 1.18 (relatively new)|
176
+ | **Typical Use Cases**| Data science, web dev, scripting | Cloud, networking, system programming |
177
+ | **Community** | Very large, active | Growing, dedicated |
178
+ | **Object Orientation**| Full support | Structs with methods, interfaces|
179
+
180
+
181
+
182
+ **In Summary:**
183
+
184
+ * **Choose Python 🫣if:** You need rapid development, a large ecosystem of libraries, or are focused on data science, machine learning, or scripting. Readability and ease of use are priorities.
185
+
186
+ * **Choose Go if:** You need high performance, concurrency, scalability, and are building infrastructure, network services, or command-line tools. Deterministic error handling and a simple, efficient language are key.
187
+ 🫣
@@ -26,6 +26,7 @@ import importlib
26
26
  from io import BytesIO
27
27
  from term_image.image import from_file, from_url
28
28
  import pygments.util
29
+ from functools import reduce
29
30
  from argparse import ArgumentParser
30
31
  from pygments import highlight
31
32
  from pygments.lexers import get_lexer_by_name
@@ -91,8 +92,8 @@ KEYCODE_RE = re.compile(r'\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])')
91
92
 
92
93
  visible = lambda x: re.sub(ANSIESCAPE, "", x)
93
94
  visible_length = lambda x: len(visible(x))
94
-
95
95
  extract_ansi_codes = lambda text: re.findall(ESCAPE, text)
96
+ remove_ansi = lambda line, codeList: reduce(lambda line, code: line.replace(code, ''), codeList, line)
96
97
 
97
98
  def debug_write(text):
98
99
  if state.Logging:
@@ -271,6 +272,7 @@ def code_wrap(text_in):
271
272
 
272
273
  return (indent, res)
273
274
 
275
+
274
276
  # This marvelously obscure code "compacts" long lines of repetitive ANSI format strings by
275
277
  # removing duplicates. Here's how it works
276
278
  def ansi_collapse(codelist, inp):
@@ -665,6 +667,10 @@ def parse(stream):
665
667
  # then naively search back until our visible_lengths() match. This is not fast and there's certainly smarter
666
668
  # ways of doing it but this thing is way trickery than you think
667
669
  highlighted_code = highlight(state.code_buffer + tline, lexer, formatter)
670
+
671
+ # Sometimes the highlighter will do things like a full reset or a background reset.
672
+ # This is not what we want
673
+ highlighted_code = re.sub(r"\033\[39(;00|)m", '', highlighted_code)
668
674
 
669
675
  # Since we are streaming we ignore the resets and newlines at the end
670
676
  if highlighted_code.endswith(FGRESET + "\n"):
@@ -1,5 +1,5 @@
1
1
  #!/bin/bash
2
- TIMEOUT=${TIMEOUT:-0.01}
2
+ TIMEOUT=${TIMEOUT:-0.35}
3
3
 
4
4
  while [[ $# -gt 0 ]]; do
5
5
  echo "## File: $1"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes