streamdown 0.23.0__py3-none-any.whl → 0.25.0__py3-none-any.whl

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/sd.py CHANGED
@@ -104,19 +104,22 @@ visible_length = lambda x: len(visible(x)) + dbl_count(x)
104
104
  extract_ansi_codes = lambda text: re.findall(ESCAPE, text)
105
105
  remove_ansi = lambda line, codeList: reduce(lambda line, code: line.replace(code, ''), codeList, line)
106
106
 
107
+ def gettmpdir():
108
+ tmp_dir_all = os.path.join(tempfile.gettempdir(), "sd")
109
+ os.makedirs(tmp_dir_all, mode=0o777, exist_ok=True)
110
+ tmp_dir = os.path.join(tmp_dir_all, str(os.getuid()))
111
+ os.makedirs(tmp_dir, exist_ok=True)
112
+ return tmp_dir
113
+
107
114
  def debug_write(text):
108
115
  if state.Logging:
109
116
  if state.Logging == True:
110
- tmp_dir = os.path.join(tempfile.gettempdir(), "sd")
111
- os.makedirs(tmp_dir, exist_ok=True)
112
- state.Logging = tempfile.NamedTemporaryFile(dir=tmp_dir, prefix="dbg", delete=False, mode="wb")
117
+ state.Logging = tempfile.NamedTemporaryFile(dir=gettmpdir(), prefix="dbg", delete=False, mode="wb")
113
118
  state.Logging.write(text)
114
119
 
115
120
  def savebrace():
116
121
  if state.Savebrace and state.code_buffer_raw:
117
- tmp_dir = os.path.join(tempfile.gettempdir(), "sd")
118
- os.makedirs(tmp_dir, exist_ok=True)
119
- path = os.path.join(tempfile.gettempdir(), "sd", 'savebrace')
122
+ path = os.path.join(gettmpdir(), 'savebrace')
120
123
  with open(path, "a") as f:
121
124
  f.write(state.code_buffer_raw + "\x00")
122
125
  f.flush()
@@ -481,7 +484,12 @@ def line_format(line):
481
484
  tokenList = re.finditer(r"((~~|\*\*_|_\*\*|\*{1,3}|_{1,3}|`+)|[^~_*`]+)", line)
482
485
  result = ""
483
486
 
487
+ last_pos = 0
484
488
  for match in tokenList:
489
+ if match.span()[0] > last_pos:
490
+ result += line[last_pos:match.span()[0]]
491
+
492
+ last_pos = match.span()[1]
485
493
  token = re.sub(r'\s+',' ', match.group(1))
486
494
  next_token = line[match.end()] if match.end() < len(line) else ""
487
495
  prev_token = line[match.start()-1] if match.start() > 0 else ""
@@ -797,8 +805,8 @@ def parse(stream):
797
805
  #print("(",highlighted_code,")")
798
806
 
799
807
  # Sometimes the highlighter will do things like a full reset or a background reset.
800
- # This is not what we want
801
- highlighted_code = re.sub(r"\033\[[34]9(;00|)m", '', highlighted_code)
808
+ # This is mostly not what we want
809
+ highlighted_code = re.sub(r"\033\[[34]9(;00|)m", "\033[23m", highlighted_code)
802
810
 
803
811
  # Since we are streaming we ignore the resets and newlines at the end
804
812
  if highlighted_code.endswith(FGRESET + "\n"):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: streamdown
3
- Version: 0.23.0
3
+ Version: 0.25.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
@@ -0,0 +1,9 @@
1
+ streamdown/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ streamdown/sd.py,sha256=ffr_xygYCNseJ_jkvie88Omiz9aaOhY32_-dDj1LdUY,42326
3
+ streamdown/plugins/README.md,sha256=KWqYELs9WkKJmuDzYv3cvPlZMkArsNCBUe4XDoTLjLA,1143
4
+ streamdown/plugins/latex.py,sha256=xZMGMdx_Sw4X1piZejXFHfEG9qazU4fGeceiMI0h13Y,648
5
+ streamdown-0.25.0.dist-info/METADATA,sha256=H9-T77e6Rs7fN-lJGG07So4uxqv6utRZrN98B8lLPH4,9658
6
+ streamdown-0.25.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
7
+ streamdown-0.25.0.dist-info/entry_points.txt,sha256=HroKFsFMGf_h9PRTE96NjvjJQWupMW5TGP5RGUr1O_Q,74
8
+ streamdown-0.25.0.dist-info/licenses/LICENSE.MIT,sha256=SnY46EPirUsF20dZDR8HpyVgS2_4Tjxuc6f-4OdqO7U,1070
9
+ streamdown-0.25.0.dist-info/RECORD,,
@@ -1,9 +0,0 @@
1
- streamdown/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- streamdown/sd.py,sha256=RgluaZCIs4ehoS-gy7Enieeqa2ohNaIzUnKvXb9I8nk,42143
3
- streamdown/plugins/README.md,sha256=KWqYELs9WkKJmuDzYv3cvPlZMkArsNCBUe4XDoTLjLA,1143
4
- streamdown/plugins/latex.py,sha256=xZMGMdx_Sw4X1piZejXFHfEG9qazU4fGeceiMI0h13Y,648
5
- streamdown-0.23.0.dist-info/METADATA,sha256=57r-IXGwIS2lkrcpXt58CvCl8Ry4tzeKSMmNGyMD62I,9658
6
- streamdown-0.23.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
7
- streamdown-0.23.0.dist-info/entry_points.txt,sha256=HroKFsFMGf_h9PRTE96NjvjJQWupMW5TGP5RGUr1O_Q,74
8
- streamdown-0.23.0.dist-info/licenses/LICENSE.MIT,sha256=SnY46EPirUsF20dZDR8HpyVgS2_4Tjxuc6f-4OdqO7U,1070
9
- streamdown-0.23.0.dist-info/RECORD,,