diff --git a/.github/result-3.png b/.github/result-3.png new file mode 100644 index 0000000..2967a65 Binary files /dev/null and b/.github/result-3.png differ diff --git a/.nerve.toml b/.nerve.toml index 1035275..c276e95 100644 --- a/.nerve.toml +++ b/.nerve.toml @@ -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 diff --git a/README.md b/README.md index 01ba50a..1c7e3d6 100644 --- a/README.md +++ b/README.md @@ -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,6 +87,8 @@ __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!") ``` @@ -89,6 +96,7 @@ 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) diff --git a/playground/show_send.py b/playground/show_send.py index eb05d41..64070c8 100644 --- a/playground/show_send.py +++ b/playground/show_send.py @@ -17,6 +17,7 @@ #### Subsubsubtitle '\_', '\*', '\[', '\]', '\(', '\)', '\~', '\`', '\>', '\#', '\+', '\-', '\=', '\|', '\{', '\}', '\.', '\!' _ , * , [ , ] , ( , ) , ~ , ` , > , # , + , - , = , | , { , } , . , ! +We will remove the \ symbol from the original text. **bold text** *bold text* _italic text_ @@ -30,6 +31,8 @@ - [ ] 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!") ``` @@ -37,6 +40,7 @@ 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) diff --git a/playground/use_case.py b/playground/use_case.py index 508e9a7..59dab02 100644 --- a/playground/use_case.py +++ b/playground/use_case.py @@ -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"(? 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]: