Blockquote newline fix
This commit is contained in:
parent
172f017090
commit
bed30994a8
|
@ -114,12 +114,12 @@ def abs2rel(match: re.Match, path: str) -> str:
|
|||
def gemtext2html(parser: GemtextParser, rotate_extension=True) -> BeautifulSoup:
|
||||
"""Converts gemtext to html format"""
|
||||
|
||||
soup = BeautifulSoup()
|
||||
soup = BeautifulSoup(features='html.parser')
|
||||
|
||||
for item in parser.elements:
|
||||
if item.type == 'plain':
|
||||
paragraphs = item.content.split('\n\n')
|
||||
el = BeautifulSoup()
|
||||
el = BeautifulSoup(features='html.parser')
|
||||
for content in paragraphs:
|
||||
p = soup.new_tag('p')
|
||||
p.append(content)
|
||||
|
@ -133,6 +133,7 @@ def gemtext2html(parser: GemtextParser, rotate_extension=True) -> BeautifulSoup:
|
|||
el.attrs['alt'] = item.label
|
||||
else:
|
||||
href = item.href
|
||||
# html links will typically point to .html files
|
||||
if rotate_extension and href.endswith('.gmi') and not re.match(r'^[\w]+:', href):
|
||||
href = os.path.splitext(href)[0] + '.html'
|
||||
el = soup.new_tag('a', href=href)
|
||||
|
@ -166,7 +167,10 @@ def gemtext2html(parser: GemtextParser, rotate_extension=True) -> BeautifulSoup:
|
|||
|
||||
elif item.type == 'quote':
|
||||
el = soup.new_tag('blockquote')
|
||||
# FIXME: \n to <br>
|
||||
for line in item.content.split('\n'):
|
||||
br = soup.new_tag('br')
|
||||
el.extend((br, line))
|
||||
el.find('br').decompose()
|
||||
|
||||
soup.append(el)
|
||||
return soup
|
||||
|
|
Reference in New Issue