@@ -126,6 +126,21 @@ def test_markdown_unparse_pre():
126126 assert Markdown .unparse (text = text , entities = entities ) == expected
127127
128128
129+ def test_markdown_unparse_pre_2 ():
130+ expected = """```...```"""
131+
132+ text = """..."""
133+ entities = pyrogram .types .List ([
134+ pyrogram .types .MessageEntity (
135+ type = pyrogram .enums .MessageEntityType .PRE ,
136+ offset = 0 , length = 3 ,
137+ language = ""
138+ )
139+ ])
140+
141+ assert Markdown .unparse (text = text , entities = entities ) == expected
142+
143+
129144def test_markdown_unparse_blockquote ():
130145 expected = """>Block quotation started
131146>Block quotation continued
@@ -162,6 +177,93 @@ def test_markdown_unparse_mixed():
162177 assert Markdown .unparse (text = text , entities = entities ) == expected
163178
164179
180+ def test_markdown_unparse_mixed_2 ():
181+ expected = """**bold**, **bold**
182+ __italic__, __italic__
183+ --underline--, --underline--
184+ ~~strikethrough~~, ~~strikethrough~~, ~~strikethrough~~
185+ ||spoiler||, ||spoiler||
186+ **bold __italic bold ~~italic bold strikethrough ||italic bold strikethrough spoiler||~~ --underline italic bold--__ bold**
187+ [inline URL](http://www.example.com/)
188+ 
189+ 
190+ 
191+ 
192+ 
193+ `inline fixed-width code`
194+ ```
195+ pre-formatted fixed-width code block```
196+ ```python
197+ pre-formatted fixed-width code block written in the Python programming language```
198+ >Block quotation started
199+ >Block quotation continued
200+ >The last line of the block quotation
201+ **>Expandable block quotation started
202+ **>Expandable block quotation continued
203+ **>Expandable block quotation continued
204+ **>Hidden by default part of the block quotation started
205+ **>Expandable block quotation continued
206+ **>The last line of the block quotation"""
207+
208+ text = """bold, bold
209+ italic, italic
210+ underline, underline
211+ strikethrough, strikethrough, strikethrough
212+ spoiler, spoiler
213+ bold italic bold italic bold strikethrough italic bold strikethrough spoiler underline italic bold bold
214+ inline URL
215+ 👍
216+ 22:45 tomorrow
217+ 22:45 tomorrow
218+ 22:45 tomorrow
219+ 22:45 tomorrow
220+ inline fixed-width code
221+
222+ pre-formatted fixed-width code block
223+
224+ pre-formatted fixed-width code block written in the Python programming language
225+ Block quotation started
226+ Block quotation continued
227+ The last line of the block quotation
228+ Expandable block quotation started
229+ Expandable block quotation continued
230+ Expandable block quotation continued
231+ Hidden by default part of the block quotation started
232+ Expandable block quotation continued
233+ The last line of the block quotation"""
234+ entities = entities = pyrogram .types .List ([
235+ pyrogram .types .MessageEntity (type = pyrogram .enums .MessageEntityType .BOLD , offset = 0 , length = 4 ),
236+ pyrogram .types .MessageEntity (type = pyrogram .enums .MessageEntityType .BOLD , offset = 6 , length = 4 ),
237+ pyrogram .types .MessageEntity (type = pyrogram .enums .MessageEntityType .ITALIC , offset = 11 , length = 6 ),
238+ pyrogram .types .MessageEntity (type = pyrogram .enums .MessageEntityType .ITALIC , offset = 19 , length = 6 ),
239+ pyrogram .types .MessageEntity (type = pyrogram .enums .MessageEntityType .UNDERLINE , offset = 26 , length = 9 ),
240+ pyrogram .types .MessageEntity (type = pyrogram .enums .MessageEntityType .UNDERLINE , offset = 37 , length = 9 ),
241+ pyrogram .types .MessageEntity (type = pyrogram .enums .MessageEntityType .STRIKETHROUGH , offset = 47 , length = 13 ),
242+ pyrogram .types .MessageEntity (type = pyrogram .enums .MessageEntityType .STRIKETHROUGH , offset = 62 , length = 13 ),
243+ pyrogram .types .MessageEntity (type = pyrogram .enums .MessageEntityType .STRIKETHROUGH , offset = 77 , length = 13 ),
244+ pyrogram .types .MessageEntity (type = pyrogram .enums .MessageEntityType .SPOILER , offset = 91 , length = 7 ),
245+ pyrogram .types .MessageEntity (type = pyrogram .enums .MessageEntityType .SPOILER , offset = 100 , length = 7 ),
246+ pyrogram .types .MessageEntity (type = pyrogram .enums .MessageEntityType .BOLD , offset = 108 , length = 103 ),
247+ pyrogram .types .MessageEntity (type = pyrogram .enums .MessageEntityType .ITALIC , offset = 113 , length = 93 ),
248+ pyrogram .types .MessageEntity (type = pyrogram .enums .MessageEntityType .STRIKETHROUGH , offset = 125 , length = 59 ),
249+ pyrogram .types .MessageEntity (type = pyrogram .enums .MessageEntityType .SPOILER , offset = 151 , length = 33 ),
250+ pyrogram .types .MessageEntity (type = pyrogram .enums .MessageEntityType .UNDERLINE , offset = 185 , length = 21 ),
251+ pyrogram .types .MessageEntity (type = pyrogram .enums .MessageEntityType .TEXT_LINK , offset = 212 , length = 10 , url = "http://www.example.com/" ),
252+ # TODO
253+ pyrogram .types .MessageEntity (type = pyrogram .enums .MessageEntityType .DATE_TIME , offset = 251 , length = 14 , unix_time = 1647531900 , date_time_format = "wDT" ),
254+ pyrogram .types .MessageEntity (type = pyrogram .enums .MessageEntityType .DATE_TIME , offset = 266 , length = 14 , unix_time = 1647531900 , date_time_format = "t" ),
255+ pyrogram .types .MessageEntity (type = pyrogram .enums .MessageEntityType .DATE_TIME , offset = 281 , length = 14 , unix_time = 1647531900 , date_time_format = "r" ),
256+ pyrogram .types .MessageEntity (type = pyrogram .enums .MessageEntityType .DATE_TIME , offset = 296 , length = 14 , unix_time = 1647531900 , date_time_format = "" ),
257+ pyrogram .types .MessageEntity (type = pyrogram .enums .MessageEntityType .CODE , offset = 311 , length = 23 ),
258+ pyrogram .types .MessageEntity (type = pyrogram .enums .MessageEntityType .PRE , offset = 335 , length = 37 , language = "" ),
259+ pyrogram .types .MessageEntity (type = pyrogram .enums .MessageEntityType .PRE , offset = 373 , length = 80 , language = "python" ),
260+ pyrogram .types .MessageEntity (type = pyrogram .enums .MessageEntityType .BLOCKQUOTE , offset = 454 , length = 86 ),
261+ pyrogram .types .MessageEntity (type = pyrogram .enums .MessageEntityType .EXPANDABLE_BLOCKQUOTE , offset = 541 , length = 236 ),
262+ ])
263+
264+ assert Markdown .unparse (text = text , entities = entities ) == expected
265+
266+
165267def test_markdown_unparse_no_entities ():
166268 expected = "text"
167269 text = "text"
0 commit comments