mirror of https://gitlab.com/bashrc2/epicyon
Fix markdown emphasis
parent
4b584f6648
commit
377b6a9be3
|
@ -2,7 +2,6 @@
|
|||
You are now ready to begin using Epicyon. This is a moderated social space, so please make sure to abide by our [terms of service](/terms), and have fun.
|
||||
|
||||
### Hints
|
||||
|
||||
Use the **magnifier** icon 🔍 to search for fediverse handles and follow people.
|
||||
|
||||
Selecting the **banner at the top** of the screen switches between timeline view and your profile.
|
||||
|
|
|
@ -24,24 +24,45 @@ from content import replaceEmojiFromTags
|
|||
def _markdownEmphasisHtml(markdown: str) -> str:
|
||||
"""Add italics and bold html markup to the given markdown
|
||||
"""
|
||||
punctuation = ('.', ';', ':')
|
||||
noPunctuation = markdown
|
||||
for ch in punctuation:
|
||||
noPunctuation = noPunctuation.replace(ch, ' ')
|
||||
wordList = noPunctuation.split(' ')
|
||||
replacements = {}
|
||||
for word in wordList:
|
||||
if word.startswith('**') and word.endswith('**'):
|
||||
replacements[word] = \
|
||||
'<b>' + word.replace('*', '') + '</b>'
|
||||
elif word.startswith('*') and word.endswith('*'):
|
||||
replacements[word] = \
|
||||
'<i>' + word.replace('*', '') + '</i>'
|
||||
elif word.startswith('_') and word.endswith('_'):
|
||||
replacements[word] = \
|
||||
'<ul>' + word.replace('_', '') + '</ul>'
|
||||
replacements = {
|
||||
' **': ' <b>',
|
||||
'** ': '</b> ',
|
||||
'**.': '</b>.',
|
||||
'**:': '</b>:',
|
||||
'**;': '</b>;',
|
||||
'**,': '</b>,',
|
||||
'**\n': '</b>\n',
|
||||
' *': ' <i>',
|
||||
'* ': '</i> ',
|
||||
'*.': '</i>.',
|
||||
'*:': '</i>:',
|
||||
'*;': '</i>;',
|
||||
'*,': '</i>,',
|
||||
'*\n': '</i>\n',
|
||||
' _': ' <ul>',
|
||||
'_ ': '</ul> ',
|
||||
'_.': '</ul>.',
|
||||
'_:': '</ul>:',
|
||||
'_;': '</ul>;',
|
||||
'_,': '</ul>,',
|
||||
'_\n': '</ul>\n'
|
||||
}
|
||||
for md, html in replacements.items():
|
||||
markdown = markdown.replace(md, html)
|
||||
|
||||
if markdown.startswith('**'):
|
||||
markdown = markdown[2:] + '<b>'
|
||||
elif markdown.startswith('*'):
|
||||
markdown = markdown[1:] + '<i>'
|
||||
elif markdown.startswith('_'):
|
||||
markdown = markdown[1:] + '<ul>'
|
||||
|
||||
if markdown.endswith('**'):
|
||||
markdown = markdown[:len(markdown) - 2] + '</b>'
|
||||
elif markdown.endswith('*'):
|
||||
markdown = markdown[:len(markdown) - 1] + '</i>'
|
||||
elif markdown.endswith('_'):
|
||||
markdown = markdown[:len(markdown) - 1] + '</ul>'
|
||||
return markdown
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue