streamdown 0.18.0__tar.gz → 0.19.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 (64) hide show
  1. {streamdown-0.18.0 → streamdown-0.19.0}/PKG-INFO +7 -6
  2. {streamdown-0.18.0 → streamdown-0.19.0}/README.md +6 -5
  3. {streamdown-0.18.0 → streamdown-0.19.0}/pyproject.toml +1 -1
  4. {streamdown-0.18.0 → streamdown-0.19.0}/streamdown/sd.py +13 -6
  5. streamdown-0.19.0/tests/cjj.mv +4 -0
  6. streamdown-0.19.0/tests/cjk-table.md +13 -0
  7. {streamdown-0.18.0 → streamdown-0.19.0}/.gitignore +0 -0
  8. {streamdown-0.18.0 → streamdown-0.19.0}/.vimrc +0 -0
  9. {streamdown-0.18.0 → streamdown-0.19.0}/24-bit-color.sh +0 -0
  10. {streamdown-0.18.0 → streamdown-0.19.0}/LICENSE.MIT +0 -0
  11. {streamdown-0.18.0 → streamdown-0.19.0}/assets/logo.png +0 -0
  12. {streamdown-0.18.0 → streamdown-0.19.0}/assets/logo.svg +0 -0
  13. {streamdown-0.18.0 → streamdown-0.19.0}/configurable.png +0 -0
  14. {streamdown-0.18.0 → streamdown-0.19.0}/copyable.png +0 -0
  15. {streamdown-0.18.0 → streamdown-0.19.0}/dunder.png +0 -0
  16. {streamdown-0.18.0 → streamdown-0.19.0}/error.txt +0 -0
  17. {streamdown-0.18.0 → streamdown-0.19.0}/newdir/file_0.py +0 -0
  18. {streamdown-0.18.0 → streamdown-0.19.0}/newdir/file_1.rb +0 -0
  19. {streamdown-0.18.0 → streamdown-0.19.0}/newdir/file_2.jl +0 -0
  20. {streamdown-0.18.0 → streamdown-0.19.0}/passthrough.py +0 -0
  21. {streamdown-0.18.0 → streamdown-0.19.0}/python-go.png +0 -0
  22. {streamdown-0.18.0 → streamdown-0.19.0}/requirements.txt +0 -0
  23. {streamdown-0.18.0 → streamdown-0.19.0}/somelog.txt +0 -0
  24. {streamdown-0.18.0 → streamdown-0.19.0}/ss-new.py +0 -0
  25. {streamdown-0.18.0 → streamdown-0.19.0}/ss.py +0 -0
  26. {streamdown-0.18.0 → streamdown-0.19.0}/streamdown/__init__.py +0 -0
  27. {streamdown-0.18.0 → streamdown-0.19.0}/streamdown/plugins/README.md +0 -0
  28. {streamdown-0.18.0 → streamdown-0.19.0}/streamdown/plugins/latex.py +0 -0
  29. {streamdown-0.18.0 → streamdown-0.19.0}/streamdown/ss +0 -0
  30. {streamdown-0.18.0 → streamdown-0.19.0}/streamdown/ss1 +0 -0
  31. {streamdown-0.18.0 → streamdown-0.19.0}/table.png +0 -0
  32. {streamdown-0.18.0 → streamdown-0.19.0}/temp.py +0 -0
  33. {streamdown-0.18.0 → streamdown-0.19.0}/test.py +0 -0
  34. {streamdown-0.18.0 → streamdown-0.19.0}/test_input.md +0 -0
  35. {streamdown-0.18.0 → streamdown-0.19.0}/tests/README.md +0 -0
  36. {streamdown-0.18.0 → streamdown-0.19.0}/tests/backtick-with-post-spaces.md +0 -0
  37. {streamdown-0.18.0 → streamdown-0.19.0}/tests/block.md +0 -0
  38. {streamdown-0.18.0 → streamdown-0.19.0}/tests/bold_reset_with_link.md +0 -0
  39. {streamdown-0.18.0 → streamdown-0.19.0}/tests/broken-example.md +0 -0
  40. {streamdown-0.18.0 → streamdown-0.19.0}/tests/chinese.md +0 -0
  41. {streamdown-0.18.0 → streamdown-0.19.0}/tests/chunk-buffer.sh +0 -0
  42. {streamdown-0.18.0 → streamdown-0.19.0}/tests/cjk-wrap.md +0 -0
  43. {streamdown-0.18.0 → streamdown-0.19.0}/tests/code.md +0 -0
  44. {streamdown-0.18.0 → streamdown-0.19.0}/tests/escape.md +0 -0
  45. {streamdown-0.18.0 → streamdown-0.19.0}/tests/example.md +0 -0
  46. {streamdown-0.18.0 → streamdown-0.19.0}/tests/fizzbuzz.md +0 -0
  47. {streamdown-0.18.0 → streamdown-0.19.0}/tests/inline.md +0 -0
  48. {streamdown-0.18.0 → streamdown-0.19.0}/tests/jimmy_webb.md +0 -0
  49. {streamdown-0.18.0 → streamdown-0.19.0}/tests/line-buffer.sh +0 -0
  50. {streamdown-0.18.0 → streamdown-0.19.0}/tests/line-wrap.md +0 -0
  51. {streamdown-0.18.0 → streamdown-0.19.0}/tests/links.md +0 -0
  52. {streamdown-0.18.0 → streamdown-0.19.0}/tests/managerie.md +0 -0
  53. {streamdown-0.18.0 → streamdown-0.19.0}/tests/mandlebrot.md +0 -0
  54. {streamdown-0.18.0 → streamdown-0.19.0}/tests/markdown.md +0 -0
  55. {streamdown-0.18.0 → streamdown-0.19.0}/tests/nested-example.md +0 -0
  56. {streamdown-0.18.0 → streamdown-0.19.0}/tests/outline.md +0 -0
  57. {streamdown-0.18.0 → streamdown-0.19.0}/tests/pvgo_512.jpg +0 -0
  58. {streamdown-0.18.0 → streamdown-0.19.0}/tests/pythonvgo.md +0 -0
  59. {streamdown-0.18.0 → streamdown-0.19.0}/tests/strip-chunks.sh +0 -0
  60. {streamdown-0.18.0 → streamdown-0.19.0}/tests/table-break.md +0 -0
  61. {streamdown-0.18.0 → streamdown-0.19.0}/tests/table_test.md +0 -0
  62. {streamdown-0.18.0 → streamdown-0.19.0}/tests/test.md +0 -0
  63. {streamdown-0.18.0 → streamdown-0.19.0}/tests/test_input.md +0 -0
  64. {streamdown-0.18.0 → streamdown-0.19.0}/tests/wm.md +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: streamdown
3
- Version: 0.18.0
3
+ Version: 0.19.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
@@ -44,12 +44,12 @@ $ pip install streamdown
44
44
  ![Streamdown is Amazing](https://github.com/user-attachments/assets/268cb340-78cc-4df0-a773-c5ac95eceeeb)
45
45
 
46
46
  ### Provides clean copyable code for long code lines
47
- Some *inferior* renderers inject line breaks when copying code that wraps around. We're better and now you are too!
47
+ Other renderers inject line breaks when copying code that wraps around. We're better and now you are too!
48
48
  ![Handle That Mandle](https://github.com/user-attachments/assets/a27aa70c-f691-4796-84f0-c2eb18c7de23)
49
49
  **Tip**: You can make things prettier if you don't mind if this guarantee is broken. See the `PrettyBroken` flag below!
50
50
 
51
51
  ### Supports images
52
- Here's kitty and alacritty. Try to do that in glow...
52
+ Here's kitty and alacritty.
53
53
  ![doggie](https://github.com/user-attachments/assets/81c43983-68cd-40c1-b1d5-aa3a52004504)
54
54
 
55
55
  ### Supports hyperlinks (OSC 8) and clipboard (OSC 52)
@@ -58,11 +58,12 @@ Here's kitty and alacritty. Try to do that in glow...
58
58
  ### Supports tables
59
59
  ![table](https://github.com/user-attachments/assets/dbe3d13e-6bac-4f45-bf30-f1857ed98898)
60
60
 
61
- As well as everything else...
61
+ #### As well as everything else...
62
62
  ![dunder](https://github.com/user-attachments/assets/d41d7fec-6dec-4387-b53d-f2098f269a5e)
63
63
 
64
- Very ... Carefully ... Supported ...
65
- ![cjk1](https://github.com/user-attachments/assets/75162ade-4734-440e-aaa3-5ffc17a0dd46)
64
+ #### ...even CJK
65
+ Compare how streamdown wraps around and spaces this tabular Chinese description of programming languages to the same file using glow.
66
+ ![cjk](https://github.com/user-attachments/assets/b831a5f3-7ef0-48b8-8d17-bb7b605df16a)
66
67
 
67
68
  ### Colors are highly (and quickly) configurable for people who care a lot, or just a little.
68
69
  ![configurable](https://github.com/user-attachments/assets/19ca2ec9-8ea1-4a79-87ca-8352789269fe)
@@ -15,12 +15,12 @@ $ pip install streamdown
15
15
  ![Streamdown is Amazing](https://github.com/user-attachments/assets/268cb340-78cc-4df0-a773-c5ac95eceeeb)
16
16
 
17
17
  ### Provides clean copyable code for long code lines
18
- Some *inferior* renderers inject line breaks when copying code that wraps around. We're better and now you are too!
18
+ Other renderers inject line breaks when copying code that wraps around. We're better and now you are too!
19
19
  ![Handle That Mandle](https://github.com/user-attachments/assets/a27aa70c-f691-4796-84f0-c2eb18c7de23)
20
20
  **Tip**: You can make things prettier if you don't mind if this guarantee is broken. See the `PrettyBroken` flag below!
21
21
 
22
22
  ### Supports images
23
- Here's kitty and alacritty. Try to do that in glow...
23
+ Here's kitty and alacritty.
24
24
  ![doggie](https://github.com/user-attachments/assets/81c43983-68cd-40c1-b1d5-aa3a52004504)
25
25
 
26
26
  ### Supports hyperlinks (OSC 8) and clipboard (OSC 52)
@@ -29,11 +29,12 @@ Here's kitty and alacritty. Try to do that in glow...
29
29
  ### Supports tables
30
30
  ![table](https://github.com/user-attachments/assets/dbe3d13e-6bac-4f45-bf30-f1857ed98898)
31
31
 
32
- As well as everything else...
32
+ #### As well as everything else...
33
33
  ![dunder](https://github.com/user-attachments/assets/d41d7fec-6dec-4387-b53d-f2098f269a5e)
34
34
 
35
- Very ... Carefully ... Supported ...
36
- ![cjk1](https://github.com/user-attachments/assets/75162ade-4734-440e-aaa3-5ffc17a0dd46)
35
+ #### ...even CJK
36
+ Compare how streamdown wraps around and spaces this tabular Chinese description of programming languages to the same file using glow.
37
+ ![cjk](https://github.com/user-attachments/assets/b831a5f3-7ef0-48b8-8d17-bb7b605df16a)
37
38
 
38
39
  ### Colors are highly (and quickly) configurable for people who care a lot, or just a little.
39
40
  ![configurable](https://github.com/user-attachments/assets/19ca2ec9-8ea1-4a79-87ca-8352789269fe)
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "streamdown"
7
- version = "0.18.0"
7
+ version = "0.19.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"
@@ -337,10 +337,10 @@ def ansi_collapse(codelist, inp):
337
337
 
338
338
 
339
339
  def split_text(text):
340
- return re.split(
341
- r'(?<=[\u4E00-\u9FFF\u3400-\u4DBF\uF900-\uFAFF])|(?=[\u4E00-\u9FFF\u3400-\u4DBF\uF900-\uFAFF])|\s+',
340
+ return [x for x in re.split(
341
+ r'(?<=[\u3000-\u303F\u4E00-\u9FFF\u3400-\u4DBF\uF900-\uFAFF])|(?=[\u4E00-\u9FFF\u3400-\u4DBF\uF900-\uFAFF])|\s+',
342
342
  text
343
- )
343
+ ) if x]
344
344
 
345
345
  def text_wrap(text, width = -1, indent = 0, first_line_prefix="", subsequent_line_prefix="", force_truncate=False):
346
346
  if width == -1:
@@ -352,6 +352,7 @@ def text_wrap(text, width = -1, indent = 0, first_line_prefix="", subsequent_lin
352
352
  current_line = ""
353
353
  current_style = []
354
354
 
355
+ oldword = ''
355
356
  for word in words:
356
357
  # we apply the style if we see it at the beginning of the word
357
358
  codes = extract_ansi_codes(word)
@@ -360,8 +361,12 @@ def text_wrap(text, width = -1, indent = 0, first_line_prefix="", subsequent_lin
360
361
  current_style.append(codes.pop(0))
361
362
 
362
363
  if len(word) and visible_length(current_line) + visible_length(word) + 1 <= width: # +1 for space
363
-
364
- current_line += (" " if len(visible(word)) > 0 and current_line and not cjk_count(word) else "") + word
364
+ space = ""
365
+ if len(visible(word)) > 0 and current_line:
366
+ space = " "
367
+ if (":" in visible(word) or cjk_count(word)) and cjk_count(oldword):
368
+ space = ""
369
+ current_line += space + word
365
370
  else:
366
371
  # Word doesn't fit, finalize the previous line
367
372
  prefix = first_line_prefix if not lines else subsequent_line_prefix
@@ -383,6 +388,8 @@ def text_wrap(text, width = -1, indent = 0, first_line_prefix="", subsequent_lin
383
388
  if codes:
384
389
  current_style = ansi_collapse(current_style, codes)
385
390
 
391
+ oldword = word
392
+
386
393
  if len(lines) < 1:
387
394
  return []
388
395
 
@@ -834,7 +841,7 @@ def parse(stream):
834
841
  # This is intentional ... we can get here in llama 4 using
835
842
  # a weird thing
836
843
  if state.in_list:
837
- indent = (len(state.list_item_stack) - 1) * Style.ListIndent + (len(bullet) - 1)
844
+ indent = (len(state.list_item_stack) - 1) * Style.ListIndent #+ (len(bullet) - 1)
838
845
  wrap_width = state.current_width() - indent - (2 * Style.ListIndent)
839
846
 
840
847
  wrapped_lineList = text_wrap(content, wrap_width, Style.ListIndent,
@@ -0,0 +1,4 @@
1
+ | 特性 | Ruby | Python | OCaml |
2
+ |------------------|--------------------------------|--------------------------------|-------------------------------|
3
+ | **适用场景** | 快速开发、Web 应用、自动化脚本 | 数据科学、机器学习、Web 开发、自动化脚本 | 性能关键的应用、编译器开发、金融建模 |
4
+
@@ -0,0 +1,13 @@
1
+ | 特性 | Ruby | Python | OCaml |
2
+ |------------------|--------------------------------|--------------------------------|-------------------------------|
3
+ | **设计哲学** | 使编程更加自然和有趣 | 强调代码的可读性和简洁性 | 提供高效的函数式编程功能 |
4
+ | **应用领域** | Web 开发、自动化脚本、原型开发 | Web 开发、数据科学、机器学习、自动化脚本 | 编译器开发、系统编程、金融建模 |
5
+ | **特点** | 动态类型、面向对象、元编程能力强 | 动态类型、面向对象、大量第三方库支持 | 静态类型、函数式编程、模块化、高性能 |
6
+ | **语法示例** | ```ruby<br>class Greeter<br> def initialize(name)<br> @name = name<br> end<br><br> def greet<br> puts "Hello, #{@name}!"<br> end<br>end<br><br>greeter = Greeter.new("World")<br>greeter.greet``` | ```python<br>class Greeter:<br> def __init__(self, name):<br> self.name = name<br><br> def greet(self):<br> print(f"Hello, {self.name}!")<br><br>greeter = Greeter("World")<br>greeter.greet()``` | ```ocaml<br>type greeter = {<br> name: string;<br>}<br><br>let greet {name} =<br> print_endline ("Hello, " ^ name ^ "!")<br><br>let greeter = {name = "World"}<br>let () = greet greeter``` |
7
+ | **性能** | 相对较低,但通过 JRuby、TruffleRuby 可以提高性能 | 适中,通过 Cython、PyPy 可以显著提高性能 | 高,编译后的代码接近 C 语言的性能 |
8
+ | **优点** | 开发速度快,社区活跃 | 丰富的第三方库,应用广泛 | 适合性能关键的应用,编译器优化能力强 |
9
+ | **生态系统** | Ruby on Rails 是最著名的 Web 框架,其他库和工具也很丰富 | 丰富的第三方库,如 NumPy、Pandas、Django、Flask | 相对较少,但有高质量的库,如 Core 和 Async |
10
+ | **学习曲线** | 较平缓,语法灵活,适合初学者 | 平坦,语法清晰,适合初学者 | 较陡峭,需要理解函数式编程概念 |
11
+ | **文档** | 丰富,社区支持好 | 丰富,有大量的教程和资源 | 适中,但社区提供的资源质量高 |
12
+ | **适用场景** | 快速开发、Web 应用、自动化脚本 | 数据科学、机器学习、Web 开发、自动化脚本 | 性能关键的应用、编译器开发、金融建模 |
13
+
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
File without changes
File without changes
File without changes
File without changes