fix: indent and remove empty <p>
This commit is contained in:
@ -4,6 +4,8 @@ from collections.abc import Callable
|
||||
|
||||
from . import default_converters
|
||||
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
class Bozodown():
|
||||
|
||||
def __init__(self):
|
||||
@ -19,7 +21,7 @@ class Bozodown():
|
||||
text, converter = self._get_first_converter(to_parse)
|
||||
content += self._render_element(text, converter)
|
||||
to_parse = to_parse[len(text):]
|
||||
return content
|
||||
return BeautifulSoup(content, 'html.parser').prettify()
|
||||
|
||||
|
||||
def _render_element(self, text: str, converter: dict[str, str]) -> str:
|
||||
@ -30,6 +32,8 @@ class Bozodown():
|
||||
return func(id, text)
|
||||
start: int = len(converter["from_prefix"])
|
||||
stop: int = len(text) - len(converter.get("from_suffix", ""))
|
||||
if (text[start:stop] == "\n" and converter is self._text_converter):
|
||||
return ""
|
||||
return f"{converter['to_prefix']}{text[start:stop]}{converter['to_suffix']}"
|
||||
|
||||
def _bozodown_render(self, id: str, text: str) -> str:
|
||||
|
Reference in New Issue
Block a user