sudoskys / telegramify-markdown

🪄 Markdown To Telegram MarkdownV2 Converter Python| No more worrying about formatting.
MIT License
53 stars 4 forks source link

Incorrect parsing case #28

Open arndey opened 4 hours ago

arndey commented 4 hours ago

Hi! Your lib will split the message into two code blocks: markdown starts to python starts && python finishes to markdown finishes BUT as far as I understand we have to keep one big codeblock of markdown and python should be inside

Try this string:

source = """ Certainly! Below is an example of a Markdown message that includes various formatting features:

# Welcome to the Markdown Guide

Markdown is a lightweight markup language that you can use to add formatting elements to plaintext text documents. Below is an example showcasing various kinds of formatting.

## Basic Elements

**Bold Text**: Use double asterisks or underscores.  
Example: `**Bold**` or `__Bold__`

*Italic Text*: Use single asterisks or underscores.  
Example: `*Italic*` or `_Italic_`

**_Bold and Italic Text_**: Combine both.  
Example: `**_Bold and Italic_**` or `__*Bold and Italic*__`

~~Strikethrough~~: Use double tildes.  
Example: `~~Strikethrough~~`

## Lists

- **Unordered List**: Use asterisks, pluses, or hyphens.
  - Sub-item
  - Sub-item

1. **Ordered List**: Use numbers followed by periods.
   1. Sub-item
   2. Sub-item

## Links and Images

- **Link**: `[Link Text](https://www.example.com)`
- **Image**: `![Alt Text](https://www.example.com/image.jpg)`

## Code

- **Inline Code**: Use backticks.  
  Example: `` `code` ``

- **Code Block**: Use triple backticks.  
  ```python
  def example_function():
      return "Hello, World!"

Blockquotes

This is a blockquote.
It can span multiple lines.

Tables

Header 1 Header 2 Header 3
Row 1 Col 1 Row 1 Col 2 Row 1 Col 3
Row 2 Col 1 Row 2 Col 2 Row 2 Col 3

Horizontal Line

Use three or more hyphens, asterisks, or underscores:


Emoji

Simple emoji examples: 😃 🎉 💻

Task Lists

Footnotes

Here's a sentence with a footnote.[^1]

[^1]: This is the footnote content.

Headers

Use hash symbols for different levels:

H1

H2

H3

H4

H5
H6

Thank you for going through this Markdown guide! Feel free to use it as a reference for writing messages with rich formatting.



This Markdown example covers a wide range of formatting options you can use in Markdown documents or messages.
"""
sudoskys commented 4 hours ago

I have received and am evaluating it.

sudoskys commented 4 hours ago

Do you think there is an expected parsing error? I don't quite understand your question.

What do you think is the correct situation?

arndey commented 4 hours ago

I have received and am evaluating it. temp2.txt

arndey commented 4 hours ago

Do you think there is an expected parsing error? I don't quite understand your question.

I expect the correct output message that won't split the code block in half because it contains another one inside

arndey commented 4 hours ago

expected:

markdown code
markdown code
markdown code
python code
python code
markdown code
markdown code
markdown code

actual:

markdown code
markdown code
markdown code

python code python code

markdown code
markdown code
markdown code
arndey commented 4 hours ago
image
sudoskys commented 4 hours ago

Actually this may not be a bug in the library. We convert characters according to the universal format.

Suggestions that may be helpful This problem may be a problem with the input text: you should not nest code blocks Because Telegram is responsible for rendering them, and Telegram does not support nested code blocks

arndey commented 28 minutes ago

Actually this may not be a bug in the library. We convert characters according to the universal format.

Suggestions that may be helpful This problem may be a problem with the input text: you should not nest code blocks Because Telegram is responsible for rendering them, and Telegram does not support nested code blocks

if it's not too much trouble, can you send a link to the documentation in Telegram, from which it follows that they do not support the embedded code?