Fix linebreak handling in lxml parser and add better bullets

Fixes #218
This commit is contained in:
Tulir Asokan
2018-09-28 00:45:35 +03:00
parent d71f421981
commit a9cb1bf518
3 changed files with 71 additions and 38 deletions
@@ -22,10 +22,15 @@ from telethon.tl.types import TypeMessageEntity
class MatrixParserCommon:
mention_regex = re.compile("https://matrix.to/#/(@.+:.+)") # type: Pattern
room_regex = re.compile("https://matrix.to/#/(#.+:.+)") # type: Pattern
block_tags = ("br", "p", "pre", "blockquote",
block_tags = ("p", "pre", "blockquote",
"ol", "ul", "li",
"h1", "h2", "h3", "h4", "h5", "h6",
"div", "hr", "table") # type: Tuple[str, ...]
list_bullets = ("", "", "", "")
@classmethod
def list_bullet(cls, depth: int) -> str:
return cls.list_bullets[(depth - 1) % len(cls.list_bullets)]
ParsedMessage = Tuple[str, List[TypeMessageEntity]]