Changed evaluation braces from {...} to {{...}} (breaks backward compatibility), fixed displaying 'None' in gemini links with no label

This commit is contained in:
faildev_mode 2023-07-19 20:02:27 +02:00
parent 1a86cafd38
commit eb9dd047b4
No known key found for this signature in database
GPG Key ID: 70845C70C0F5E205
2 changed files with 5 additions and 2 deletions

View File

@ -19,7 +19,7 @@ from gemtext import GemtextParser # from itself
# regex pre-compilation
REGEX = {
'evaluation': re.compile(r'\{([^\s}]+([^}]*[^\s}])?)\}'),
'evaluation': re.compile(r'{{([^\s}]+([^}]*[^\s}])?)}}'),
'url': re.compile(r'(https?://)([-\w]+[-\w.]*)(/\S*)?'),
'generic_url': re.compile(r'^[\w]+:')
}

View File

@ -91,7 +91,10 @@ class GemtextElement:
if self.type == 'plain':
return self.content
elif self.type == 'link':
return f'=> {self.href} {self.label}'
if self.label:
return f'=> {self.href} {self.label}'
else:
return f'=> {self.href}'
elif self.type == 'preformatted':
opening = '```'
if self.alt: opening += self.alt