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
diff --git a/README.md b/README.md
index f60ef47..a5f4258 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)
@@ -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
* `` - unordered list
* `` - ordered list with optional attributes
* `reversed` - to reverse numbers order
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
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",):