telegramify-markdown 1.4.2__tar.gz → 1.4.3__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.
- {telegramify_markdown-1.4.2 → telegramify_markdown-1.4.3}/PKG-INFO +1 -1
- {telegramify_markdown-1.4.2 → telegramify_markdown-1.4.3}/pyproject.toml +1 -1
- {telegramify_markdown-1.4.2 → telegramify_markdown-1.4.3}/src/telegramify_markdown/rich.py +8 -1
- {telegramify_markdown-1.4.2 → telegramify_markdown-1.4.3}/tests/test_rich.py +17 -0
- {telegramify_markdown-1.4.2 → telegramify_markdown-1.4.3}/LICENSE +0 -0
- {telegramify_markdown-1.4.2 → telegramify_markdown-1.4.3}/README.md +0 -0
- {telegramify_markdown-1.4.2 → telegramify_markdown-1.4.3}/src/telegramify_markdown/__init__.py +0 -0
- {telegramify_markdown-1.4.2 → telegramify_markdown-1.4.3}/src/telegramify_markdown/code_file.py +0 -0
- {telegramify_markdown-1.4.2 → telegramify_markdown-1.4.3}/src/telegramify_markdown/config.py +0 -0
- {telegramify_markdown-1.4.2 → telegramify_markdown-1.4.3}/src/telegramify_markdown/content.py +0 -0
- {telegramify_markdown-1.4.2 → telegramify_markdown-1.4.3}/src/telegramify_markdown/converter.py +0 -0
- {telegramify_markdown-1.4.2 → telegramify_markdown-1.4.3}/src/telegramify_markdown/entity.py +0 -0
- {telegramify_markdown-1.4.2 → telegramify_markdown-1.4.3}/src/telegramify_markdown/latex_escape/__init__.py +0 -0
- {telegramify_markdown-1.4.2 → telegramify_markdown-1.4.3}/src/telegramify_markdown/latex_escape/const.py +0 -0
- {telegramify_markdown-1.4.2 → telegramify_markdown-1.4.3}/src/telegramify_markdown/latex_escape/helper.py +0 -0
- {telegramify_markdown-1.4.2 → telegramify_markdown-1.4.3}/src/telegramify_markdown/logger.py +0 -0
- {telegramify_markdown-1.4.2 → telegramify_markdown-1.4.3}/src/telegramify_markdown/mdv2.py +0 -0
- {telegramify_markdown-1.4.2 → telegramify_markdown-1.4.3}/src/telegramify_markdown/mermaid.py +0 -0
- {telegramify_markdown-1.4.2 → telegramify_markdown-1.4.3}/src/telegramify_markdown/pipeline.py +0 -0
- {telegramify_markdown-1.4.2 → telegramify_markdown-1.4.3}/src/telegramify_markdown/py.typed +0 -0
- {telegramify_markdown-1.4.2 → telegramify_markdown-1.4.3}/src/telegramify_markdown/stream/__init__.py +0 -0
- {telegramify_markdown-1.4.2 → telegramify_markdown-1.4.3}/src/telegramify_markdown/stream/core.py +0 -0
- {telegramify_markdown-1.4.2 → telegramify_markdown-1.4.3}/src/telegramify_markdown/stream/draft.py +0 -0
- {telegramify_markdown-1.4.2 → telegramify_markdown-1.4.3}/src/telegramify_markdown/stream/edit.py +0 -0
- {telegramify_markdown-1.4.2 → telegramify_markdown-1.4.3}/src/telegramify_markdown/type.py +0 -0
- {telegramify_markdown-1.4.2 → telegramify_markdown-1.4.3}/src/telegramify_markdown/word_count.py +0 -0
- {telegramify_markdown-1.4.2 → telegramify_markdown-1.4.3}/tests/exp1.md +0 -0
- {telegramify_markdown-1.4.2 → telegramify_markdown-1.4.3}/tests/exp2.md +0 -0
- {telegramify_markdown-1.4.2 → telegramify_markdown-1.4.3}/tests/send_showcase.py +0 -0
- {telegramify_markdown-1.4.2 → telegramify_markdown-1.4.3}/tests/showcase_latex.py +0 -0
- {telegramify_markdown-1.4.2 → telegramify_markdown-1.4.3}/tests/test_converter.py +0 -0
- {telegramify_markdown-1.4.2 → telegramify_markdown-1.4.3}/tests/test_entity.py +0 -0
- {telegramify_markdown-1.4.2 → telegramify_markdown-1.4.3}/tests/test_mdv2.py +0 -0
- {telegramify_markdown-1.4.2 → telegramify_markdown-1.4.3}/tests/test_mermaid.py +0 -0
- {telegramify_markdown-1.4.2 → telegramify_markdown-1.4.3}/tests/test_performance.py +0 -0
- {telegramify_markdown-1.4.2 → telegramify_markdown-1.4.3}/tests/test_pipeline.py +0 -0
- {telegramify_markdown-1.4.2 → telegramify_markdown-1.4.3}/tests/test_server.py +0 -0
- {telegramify_markdown-1.4.2 → telegramify_markdown-1.4.3}/tests/test_stream.py +0 -0
|
@@ -1113,8 +1113,15 @@ def _extract_wrapped_text(html_text: str, tag: str) -> str | None:
|
|
|
1113
1113
|
return None
|
|
1114
1114
|
|
|
1115
1115
|
|
|
1116
|
+
# A code block with a language and one without are matched separately: a single
|
|
1117
|
+
# pattern with a greedy body and an alternated close tag settles on "</pre>" and
|
|
1118
|
+
# leaves "</code>" in the body, which then gets escaped into visible text.
|
|
1119
|
+
_PRE_CODE_RE = re.compile(r'(<pre><code class="[^"]+">)(.*)(</code></pre>)', re.DOTALL)
|
|
1120
|
+
_PRE_RE = re.compile(r"(<pre>)(.*)(</pre>)", re.DOTALL)
|
|
1121
|
+
|
|
1122
|
+
|
|
1116
1123
|
def _extract_pre_text(html_text: str) -> tuple[str, str, str] | None:
|
|
1117
|
-
match =
|
|
1124
|
+
match = _PRE_CODE_RE.fullmatch(html_text) or _PRE_RE.fullmatch(html_text)
|
|
1118
1125
|
if not match:
|
|
1119
1126
|
return None
|
|
1120
1127
|
return match.group(1), match.group(2), match.group(3)
|
|
@@ -312,6 +312,23 @@ class SplitRichTest(unittest.TestCase):
|
|
|
312
312
|
self.assertTrue(html.endswith("</pre>"))
|
|
313
313
|
self.assertLessEqual(len(html.encode("utf-8")), 32768)
|
|
314
314
|
|
|
315
|
+
def test_html_mode_splits_oversized_pre_block_with_language(self):
|
|
316
|
+
"""带语言的超长 code block 每个 chunk 都以 </code></pre> 闭合,且不泄漏 </code> 文本。"""
|
|
317
|
+
code = "\n".join(f"x_{n} = {n}" for n in range(4000))
|
|
318
|
+
result = telegramify_rich(f"```python\n{code}\n```")
|
|
319
|
+
|
|
320
|
+
self.assertGreater(len(result), 1)
|
|
321
|
+
open_tag = '<pre><code class="language-python">'
|
|
322
|
+
recovered = []
|
|
323
|
+
for item in result:
|
|
324
|
+
html = item.to_dict()["html"]
|
|
325
|
+
self.assertTrue(html.startswith(open_tag))
|
|
326
|
+
self.assertTrue(html.endswith("</code></pre>"))
|
|
327
|
+
self.assertNotIn("</code>", html)
|
|
328
|
+
self.assertLessEqual(len(html.encode("utf-8")), 32768)
|
|
329
|
+
recovered.append(unescape(html.removeprefix(open_tag).removesuffix("</code></pre>")))
|
|
330
|
+
self.assertEqual("".join(recovered), code)
|
|
331
|
+
|
|
315
332
|
def test_html_mode_splits_oversized_escaped_pre_block(self):
|
|
316
333
|
"""超长 code block 含 HTML 特殊字符时保持可见文本。"""
|
|
317
334
|
visible = "<&>" * 12000
|
|
File without changes
|
|
File without changes
|
{telegramify_markdown-1.4.2 → telegramify_markdown-1.4.3}/src/telegramify_markdown/__init__.py
RENAMED
|
File without changes
|
{telegramify_markdown-1.4.2 → telegramify_markdown-1.4.3}/src/telegramify_markdown/code_file.py
RENAMED
|
File without changes
|
{telegramify_markdown-1.4.2 → telegramify_markdown-1.4.3}/src/telegramify_markdown/config.py
RENAMED
|
File without changes
|
{telegramify_markdown-1.4.2 → telegramify_markdown-1.4.3}/src/telegramify_markdown/content.py
RENAMED
|
File without changes
|
{telegramify_markdown-1.4.2 → telegramify_markdown-1.4.3}/src/telegramify_markdown/converter.py
RENAMED
|
File without changes
|
{telegramify_markdown-1.4.2 → telegramify_markdown-1.4.3}/src/telegramify_markdown/entity.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{telegramify_markdown-1.4.2 → telegramify_markdown-1.4.3}/src/telegramify_markdown/logger.py
RENAMED
|
File without changes
|
|
File without changes
|
{telegramify_markdown-1.4.2 → telegramify_markdown-1.4.3}/src/telegramify_markdown/mermaid.py
RENAMED
|
File without changes
|
{telegramify_markdown-1.4.2 → telegramify_markdown-1.4.3}/src/telegramify_markdown/pipeline.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{telegramify_markdown-1.4.2 → telegramify_markdown-1.4.3}/src/telegramify_markdown/stream/core.py
RENAMED
|
File without changes
|
{telegramify_markdown-1.4.2 → telegramify_markdown-1.4.3}/src/telegramify_markdown/stream/draft.py
RENAMED
|
File without changes
|
{telegramify_markdown-1.4.2 → telegramify_markdown-1.4.3}/src/telegramify_markdown/stream/edit.py
RENAMED
|
File without changes
|
|
File without changes
|
{telegramify_markdown-1.4.2 → telegramify_markdown-1.4.3}/src/telegramify_markdown/word_count.py
RENAMED
|
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
|