Skip to content

Commit

Permalink
Merge pull request #22 from sudoskys/dev
Browse files Browse the repository at this point in the history
feat: Delete extra space added after quote character
sudoskys authored Aug 29, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
2 parents d0f125c + e1c1980 commit d7e23f8
Showing 7 changed files with 27 additions and 4 deletions.
Binary file added .github/result-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion .nerve.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
contributor = "adedbffc-5231-40a8-a10b-d329564160a6"
contributor = "ae289f82-bfe1-4c68-8198-85b14cfc43d7"
language = "English"
issue_auto_label = true
issue_auto_tidy = true
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -67,8 +67,13 @@ customize.markdown_symbol.head_level_1 = "📌" # If you want, Customizing the
customize.markdown_symbol.link = "🔗" # If you want, Customizing the link symbol
customize.strict_markdown = True # If you want to use __underline__ as underline, set it to False or it will be converted to bold.
markdown_text = """
# Title
## Subtitle
### Subsubtitle
#### Subsubsubtitle
'\_', '\*', '\[', '\]', '\(', '\)', '\~', '\`', '\>', '\#', '\+', '\-', '\=', '\|', '\{', '\}', '\.', '\!'
_ , * , [ , ] , ( , ) , ~ , ` , > , # , + , - , = , | , { , } , . , !
We will remove the \ symbol from the original text.
**bold text**
*bold text*
_italic text_
@@ -82,13 +87,16 @@ __underline italic bold__
- [ ] Uncompleted task list item
- [x] Completed task list item
> Quote
> Multiline Quote In Markdown it's not possible to send multiline quote in telegram without using code block or html tag but telegramify_markdown can do it.
```python
print("Hello, World!")
```
This is `inline code`
1. First ordered list item
2. Another item
- Unordered sub-list.
- Another item.
1. Actual numbers don't matter, just that it's a number
"""
converted = telegramify_markdown.markdownify(
@@ -102,4 +110,4 @@ print(converted)

output as follows:

![.github/result.png](.github/result-2.png)
![.github/result.png](.github/result-3.png)
4 changes: 4 additions & 0 deletions playground/show_send.py
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@
#### Subsubsubtitle
'\_', '\*', '\[', '\]', '\(', '\)', '\~', '\`', '\>', '\#', '\+', '\-', '\=', '\|', '\{', '\}', '\.', '\!'
_ , * , [ , ] , ( , ) , ~ , ` , > , # , + , - , = , | , { , } , . , !
We will remove the \ symbol from the original text.
**bold text**
*bold text*
_italic text_
@@ -30,13 +31,16 @@
- [ ] Uncompleted task list item
- [x] Completed task list item
> Quote
> Multiline Quote In Markdown it's not possible to send multiline quote in telegram without using code block or html tag but telegramify_markdown can do it.
```python
print("Hello, World!")
```
This is `inline code`
1. First ordered list item
2. Another item
- Unordered sub-list.
- Another item.
1. Actual numbers don't matter, just that it's a number
"""
converted = telegramify_markdown.convert(md)
3 changes: 2 additions & 1 deletion playground/use_case.py
Original file line number Diff line number Diff line change
@@ -8,12 +8,13 @@
md = """*bold _italic bold ~italic bold strikethrough ||italic bold strikethrough spoiler||~ __underline italic bold___ bold*
~strikethrough~
"""
quote = """>test"""

test_md = """
**bold text**
||spoiler||
"""
converted = telegramify_markdown.convert(md)
converted = telegramify_markdown.convert(quote)
print(converted)

rule = re.compile(r"(?<!\\)(?:\\\\)*\|\|(.+?)\|\|", re.DOTALL)
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "telegramify-markdown"
version = "0.1.10"
version = "0.1.11"
description = "Convert Markdown to a format usable by Telegram."
authors = [
{ name = "sudoskys", email = "coldlando@hotmail.com" },
10 changes: 10 additions & 0 deletions src/telegramify_markdown/render.py
Original file line number Diff line number Diff line change
@@ -51,6 +51,16 @@ def __init__(self, *extras, **kwargs):
)
self.render_map["Spoiler"] = self.render_spoiler

def render_quote(
self, token: block_token.Quote, max_line_length: int
) -> Iterable[str]:
max_child_line_length = max_line_length - 2 if max_line_length else None
lines = self.blocks_to_lines(
token.children, max_line_length=max_child_line_length
)
# NOTE: Remove the space after the > , but it is not standard markdown
return self.prefix_lines(lines or [""], ">")

def render_heading(
self, token: block_token.Heading, max_line_length: int
) -> Iterable[str]:

0 comments on commit d7e23f8

Please sign in to comment.