From 573049ed529c82d82291b1dc68d65456107019c7 Mon Sep 17 00:00:00 2001 From: Ilya Nikolaev <65247719+ilya-nikolaev@users.noreply.github.com> Date: Thu, 11 Jan 2024 23:40:50 +0300 Subject: [PATCH 1/5] Fixed typos in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f60ef47..978887c 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ But this is how it is rendered in Telegram with `parse_mode="html"`: ![](https://github.com/tishka17/sulguk/blob/master/images/problem_telegram.png?raw=True) -T osolve this we can convert HTML to telegram entites with `sulguk`. So that's how it looks now: +To solve this we can convert HTML to telegram entities with `sulguk`. So that's how it looks now: ![](https://github.com/tishka17/sulguk/blob/master/images/problem_sulguk.png?raw=True) From 087d0d958a6a814c7b52ffdb10864fa4cd3937c1 Mon Sep 17 00:00:00 2001 From: Ilya Nikolaev <65247719+ilya-nikolaev@users.noreply.github.com> Date: Thu, 11 Jan 2024 23:41:34 +0300 Subject: [PATCH 2/5] Added build folder to gitignore --- .gitignore | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 62392ce..5e3e758 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ __pycache__ .idea/* -*.egg-info \ No newline at end of file +*.egg-info + +build/* \ No newline at end of file From 8acd246f7d42ce299c7f1e1066daa5334f13ed75 Mon Sep 17 00:00:00 2001 From: Ilya Nikolaev <65247719+ilya-nikolaev@users.noreply.github.com> Date: Fri, 12 Jan 2024 00:20:39 +0300 Subject: [PATCH 3/5] Added support of wbr tag --- src/sulguk/entities/__init__.py | 3 ++- src/sulguk/entities/no_contents.py | 5 +++++ src/sulguk/transformer.py | 5 ++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/sulguk/entities/__init__.py b/src/sulguk/entities/__init__.py index cff8766..00c7151 100644 --- a/src/sulguk/entities/__init__.py +++ b/src/sulguk/entities/__init__.py @@ -19,6 +19,7 @@ "ListItem", "NewLine", "HorizontalLine", + "ZeroWidthSpace", "Progress", "Stub", "Text", @@ -41,7 +42,7 @@ ) from .emoji import Emoji from .list import ListGroup, ListItem -from .no_contents import HorizontalLine, NewLine +from .no_contents import HorizontalLine, NewLine, ZeroWidthSpace from .progress import Progress from .stub import Stub from .text import Text diff --git a/src/sulguk/entities/no_contents.py b/src/sulguk/entities/no_contents.py index a031de1..82e0944 100644 --- a/src/sulguk/entities/no_contents.py +++ b/src/sulguk/entities/no_contents.py @@ -19,3 +19,8 @@ def render(self, state: State) -> None: state.canvas.add_new_line_soft() state.canvas.add_text("⎯" * 10) state.canvas.add_new_line_soft() + + +class ZeroWidthSpace(NoContents): + def render(self, state: State) -> None: + state.canvas.add_text("\u200b") diff --git a/src/sulguk/transformer.py b/src/sulguk/transformer.py index 4cf4ff4..92d69fc 100644 --- a/src/sulguk/transformer.py +++ b/src/sulguk/transformer.py @@ -25,6 +25,7 @@ Text, Underline, Uppercase, + ZeroWidthSpace, ) Attrs = List[Tuple[str, Optional[str]]] @@ -39,7 +40,7 @@ LANG_CLASS_PREFIX = "language-" -NO_CLOSING_TAGS = ("br", "hr", "meta", "link", "img") +NO_CLOSING_TAGS = ("br", "wbr", "hr", "meta", "link", "img") class Transformer(HTMLParser): @@ -196,6 +197,8 @@ def _get_tg_emoji(self, attrs: Attrs) -> Entity: def handle_startendtag(self, tag: str, attrs: Attrs) -> None: if tag == "br": entity = NewLine() + elif tag == "wbr": + entity = ZeroWidthSpace() elif tag == "hr": entity = HorizontalLine() elif tag in ("img",): From fde3f8ea43cb9573abd1b7ff19869b371fc0907e Mon Sep 17 00:00:00 2001 From: Ilya Nikolaev <65247719+ilya-nikolaev@users.noreply.github.com> Date: Fri, 12 Jan 2024 00:20:54 +0300 Subject: [PATCH 4/5] Updated example --- example.html | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/example.html b/example.html index 3bba9d1..bf9ecdb 100644 --- a/example.html +++ b/example.html @@ -9,4 +9,7 @@

Lists and formatting are supported


Other features

This is block quote
-

This is paragraph!

And one more with quote.

\ No newline at end of file +

This is paragraph!

And one more with quote.

+

The longest word in the German language: Donaudampfschifffahrtsgesellschaftskapitaenswitwe

+

And again, the longest word in the German language: + Donaudampfschifffahrtsgesellschaftskapitaenswitwe

From 16822d1678a6590fd54ac9752df9fb5399ee26e7 Mon Sep 17 00:00:00 2001 From: Ilya Nikolaev <65247719+ilya-nikolaev@users.noreply.github.com> Date: Fri, 12 Jan 2024 00:23:43 +0300 Subject: [PATCH 5/5] Updated docs --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 978887c..a5f4258 100644 --- a/README.md +++ b/README.md @@ -131,6 +131,7 @@ The same behavior is supported in sulguk. Otherwise, you can set the language on #### Additional tags: * `
` - new line * `
` - horizontal line +* `` - word break opportunity * `