chatgpt-md-converter 0.3.11__tar.gz → 0.3.12__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.
- {chatgpt_md_converter-0.3.11 → chatgpt_md_converter-0.3.12}/PKG-INFO +1 -1
- {chatgpt_md_converter-0.3.11 → chatgpt_md_converter-0.3.12}/chatgpt_md_converter/html_markdown/handlers.py +3 -2
- {chatgpt_md_converter-0.3.11 → chatgpt_md_converter-0.3.12}/chatgpt_md_converter/telegram_markdown/preprocess.py +4 -0
- {chatgpt_md_converter-0.3.11 → chatgpt_md_converter-0.3.12}/chatgpt_md_converter/telegram_markdown/renderer.py +1 -2
- {chatgpt_md_converter-0.3.11 → chatgpt_md_converter-0.3.12}/chatgpt_md_converter.egg-info/PKG-INFO +1 -1
- {chatgpt_md_converter-0.3.11 → chatgpt_md_converter-0.3.12}/setup.py +1 -1
- {chatgpt_md_converter-0.3.11 → chatgpt_md_converter-0.3.12}/tests/test_parser.py +35 -0
- {chatgpt_md_converter-0.3.11 → chatgpt_md_converter-0.3.12}/tests/test_roundtrip_markdown.py +7 -0
- {chatgpt_md_converter-0.3.11 → chatgpt_md_converter-0.3.12}/LICENSE +0 -0
- {chatgpt_md_converter-0.3.11 → chatgpt_md_converter-0.3.12}/README.md +0 -0
- {chatgpt_md_converter-0.3.11 → chatgpt_md_converter-0.3.12}/chatgpt_md_converter/__init__.py +0 -0
- {chatgpt_md_converter-0.3.11 → chatgpt_md_converter-0.3.12}/chatgpt_md_converter/html_markdown/escaping.py +0 -0
- {chatgpt_md_converter-0.3.11 → chatgpt_md_converter-0.3.12}/chatgpt_md_converter/html_markdown/renderer.py +0 -0
- {chatgpt_md_converter-0.3.11 → chatgpt_md_converter-0.3.12}/chatgpt_md_converter/html_markdown/state.py +0 -0
- {chatgpt_md_converter-0.3.11 → chatgpt_md_converter-0.3.12}/chatgpt_md_converter/html_markdown/tree.py +0 -0
- {chatgpt_md_converter-0.3.11 → chatgpt_md_converter-0.3.12}/chatgpt_md_converter/html_splitter.py +0 -0
- {chatgpt_md_converter-0.3.11 → chatgpt_md_converter-0.3.12}/chatgpt_md_converter/html_to_markdown.py +0 -0
- {chatgpt_md_converter-0.3.11 → chatgpt_md_converter-0.3.12}/chatgpt_md_converter/telegram_formatter.py +0 -0
- {chatgpt_md_converter-0.3.11 → chatgpt_md_converter-0.3.12}/chatgpt_md_converter/telegram_markdown/__init__.py +0 -0
- {chatgpt_md_converter-0.3.11 → chatgpt_md_converter-0.3.12}/chatgpt_md_converter/telegram_markdown/code_blocks.py +0 -0
- {chatgpt_md_converter-0.3.11 → chatgpt_md_converter-0.3.12}/chatgpt_md_converter/telegram_markdown/inline.py +0 -0
- {chatgpt_md_converter-0.3.11 → chatgpt_md_converter-0.3.12}/chatgpt_md_converter/telegram_markdown/postprocess.py +0 -0
- {chatgpt_md_converter-0.3.11 → chatgpt_md_converter-0.3.12}/chatgpt_md_converter.egg-info/SOURCES.txt +0 -0
- {chatgpt_md_converter-0.3.11 → chatgpt_md_converter-0.3.12}/chatgpt_md_converter.egg-info/dependency_links.txt +0 -0
- {chatgpt_md_converter-0.3.11 → chatgpt_md_converter-0.3.12}/chatgpt_md_converter.egg-info/top_level.txt +0 -0
- {chatgpt_md_converter-0.3.11 → chatgpt_md_converter-0.3.12}/setup.cfg +0 -0
- {chatgpt_md_converter-0.3.11 → chatgpt_md_converter-0.3.12}/tests/test_html_to_markdown_inline_spacing.py +0 -0
- {chatgpt_md_converter-0.3.11 → chatgpt_md_converter-0.3.12}/tests/test_splitter.py +0 -0
|
@@ -169,11 +169,12 @@ def _handle_blockquote(node: Node, state: RenderState) -> str:
|
|
|
169
169
|
expandable = "expandable" in node.attrs
|
|
170
170
|
rendered: list[str] = []
|
|
171
171
|
for index, line in enumerate(lines):
|
|
172
|
-
prefix = "**>" if expandable and index == 0 else ">"
|
|
173
172
|
stripped = line.rstrip("\r")
|
|
174
173
|
if expandable:
|
|
175
|
-
|
|
174
|
+
marker = ">**" if index == 0 else ">"
|
|
175
|
+
rendered.append(f"{marker} {stripped}" if stripped else marker)
|
|
176
176
|
else:
|
|
177
|
+
prefix = ">"
|
|
177
178
|
rendered.append(f"{prefix} {stripped}" if stripped else prefix)
|
|
178
179
|
return "\n".join(rendered)
|
|
179
180
|
|
|
@@ -14,6 +14,10 @@ def combine_blockquotes(text: str) -> str:
|
|
|
14
14
|
in_blockquote = True
|
|
15
15
|
is_expandable = True
|
|
16
16
|
blockquote_lines.append(line[3:].strip())
|
|
17
|
+
elif line.startswith(">**") and (len(line) == 3 or line[3].isspace()):
|
|
18
|
+
in_blockquote = True
|
|
19
|
+
is_expandable = True
|
|
20
|
+
blockquote_lines.append(line[3:].strip())
|
|
17
21
|
elif line.startswith(">"):
|
|
18
22
|
if not in_blockquote:
|
|
19
23
|
in_blockquote = True
|
|
@@ -12,9 +12,8 @@ from .preprocess import combine_blockquotes
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
def telegram_format(text: str) -> str:
|
|
15
|
-
text = combine_blockquotes(text)
|
|
16
|
-
|
|
17
15
|
output, block_map = extract_and_convert_code_blocks(text)
|
|
16
|
+
output = combine_blockquotes(output)
|
|
18
17
|
output, inline_snippets = extract_inline_code_snippets(output)
|
|
19
18
|
|
|
20
19
|
output = convert_html_chars(output)
|
|
@@ -716,6 +716,41 @@ Continued</blockquote>"""
|
|
|
716
716
|
assert output == expected_output, "Failed handling spoiler inside blockquote"
|
|
717
717
|
|
|
718
718
|
|
|
719
|
+
def test_blockquote_lines_inside_code_block():
|
|
720
|
+
input_text = """```text
|
|
721
|
+
>** заголовок довгої цитати
|
|
722
|
+
> рядок 2
|
|
723
|
+
> рядок 3
|
|
724
|
+
> рядок 4
|
|
725
|
+
> і ще хоч сто рядків
|
|
726
|
+
```"""
|
|
727
|
+
expected_output = (
|
|
728
|
+
'<pre><code class="language-text">>** заголовок довгої цитати\n'
|
|
729
|
+
'> рядок 2\n'
|
|
730
|
+
'> рядок 3\n'
|
|
731
|
+
'> рядок 4\n'
|
|
732
|
+
'> і ще хоч сто рядків\n'
|
|
733
|
+
"</code></pre>"
|
|
734
|
+
)
|
|
735
|
+
output = telegram_format(input_text)
|
|
736
|
+
assert output == expected_output, f"Got: {output}"
|
|
737
|
+
|
|
738
|
+
|
|
739
|
+
def test_blockquote_double_asterisk_prefix():
|
|
740
|
+
input_text = """>** заголовок довгої цитати
|
|
741
|
+
> рядок 2
|
|
742
|
+
> рядок 3
|
|
743
|
+
> рядок 4
|
|
744
|
+
> і ще хоч сто рядків"""
|
|
745
|
+
expected_output = """<blockquote expandable>заголовок довгої цитати
|
|
746
|
+
рядок 2
|
|
747
|
+
рядок 3
|
|
748
|
+
рядок 4
|
|
749
|
+
і ще хоч сто рядків</blockquote>"""
|
|
750
|
+
output = telegram_format(input_text)
|
|
751
|
+
assert output == expected_output, f"Got: {output}"
|
|
752
|
+
|
|
753
|
+
|
|
719
754
|
def test_multiple_spoilers():
|
|
720
755
|
input_text = "First ||spoiler|| and then another ||spoiler with *italic*||"
|
|
721
756
|
expected_output = 'First <span class="tg-spoiler">spoiler</span> and then another <span class="tg-spoiler">spoiler with <i>italic</i></span>'
|
{chatgpt_md_converter-0.3.11 → chatgpt_md_converter-0.3.12}/tests/test_roundtrip_markdown.py
RENAMED
|
@@ -30,3 +30,10 @@ def test_markdown_html_markdown_cycle_is_idempotent(_case, markdown_input, _):
|
|
|
30
30
|
assert '<br' not in html_first
|
|
31
31
|
assert '<br' not in html_third
|
|
32
32
|
assert html_first == html_third
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def test_html_to_markdown_expandable_blockquote():
|
|
36
|
+
html_text = "<blockquote expandable>заголовок\nрядок 2\nрядок 3</blockquote>"
|
|
37
|
+
expected_markdown = ">** заголовок\n> рядок 2\n> рядок 3"
|
|
38
|
+
markdown = html_to_telegram_markdown(html_text)
|
|
39
|
+
assert markdown == expected_markdown
|
|
File without changes
|
|
File without changes
|
{chatgpt_md_converter-0.3.11 → chatgpt_md_converter-0.3.12}/chatgpt_md_converter/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{chatgpt_md_converter-0.3.11 → chatgpt_md_converter-0.3.12}/chatgpt_md_converter/html_splitter.py
RENAMED
|
File without changes
|
{chatgpt_md_converter-0.3.11 → chatgpt_md_converter-0.3.12}/chatgpt_md_converter/html_to_markdown.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
|