From c571267df6a8d32b496155dab12c5e0291578927 Mon Sep 17 00:00:00 2001 From: Andrey Tikhonov Date: Tue, 19 Sep 2023 01:31:34 +0400 Subject: [PATCH 1/6] Support language set in code tag as in telegram --- README.md | 15 +++++++++------ src/sulguk/entities/decoration.py | 18 ++++++++++++++++-- src/sulguk/transformer.py | 14 ++++++++------ 3 files changed, 33 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 9b26e32..3aa59ac 100644 --- a/README.md +++ b/README.md @@ -114,7 +114,7 @@ await bot.send_message( For all supported tags unknown attributes are ignored as well as unknown classes. Unsupported tags are raising an error. -Standard telegram tags (with some changes): +#### Standard telegram tags (with some changes): * `` - a hyperlink with `href` attribute * ``, `` - a bold text * ``, `` - an italic text @@ -125,7 +125,10 @@ Standard telegram tags (with some changes): * `
` with optional `class="language-"` - a preformatted block with code. `` will be sent as a language attribute in telegram.
 * `` - an inline preformatted element. 
 
-Additional tags:
+**Note:** In standard Telegram HTML you can set a preformatted text language nesting `` in `
` tag. This works when it is an only child. But any additional symbol outside of `` breaks it.
+The same behavior is supported in sulguk. Otherwise, you can set the language on `
` tag itself.
+
+#### Additional tags:
 * `
` - new line * `
` - horizontal line * `
    ` - unordered list @@ -144,14 +147,14 @@ Additional tags: * ``, `` - italic * ``, `` are rendered using emoji (🟩🟩🟩🟨⬜️⬜️) * ``, `` - preformatted text +* `` - as a link with picture emoji before. `alt` text is used if provided. -Tags which are treated as block elements (like `
    `): +#### Tags which are treated as block elements (like `
    `): `