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.
|
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
|
### Hints
|
||||||
|
|
||||||
Use the **magnifier** icon 🔍 to search for fediverse handles and follow people.
|
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.
|
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:
|
def _markdownEmphasisHtml(markdown: str) -> str:
|
||||||
"""Add italics and bold html markup to the given markdown
|
"""Add italics and bold html markup to the given markdown
|
||||||
"""
|
"""
|
||||||
punctuation = ('.', ';', ':')
|
replacements = {
|
||||||
noPunctuation = markdown
|
' **': ' <b>',
|
||||||
for ch in punctuation:
|
'** ': '</b> ',
|
||||||
noPunctuation = noPunctuation.replace(ch, ' ')
|
'**.': '</b>.',
|
||||||
wordList = noPunctuation.split(' ')
|
'**:': '</b>:',
|
||||||
replacements = {}
|
'**;': '</b>;',
|
||||||
for word in wordList:
|
'**,': '</b>,',
|
||||||
if word.startswith('**') and word.endswith('**'):
|
'**\n': '</b>\n',
|
||||||
replacements[word] = \
|
' *': ' <i>',
|
||||||
'<b>' + word.replace('*', '') + '</b>'
|
'* ': '</i> ',
|
||||||
elif word.startswith('*') and word.endswith('*'):
|
'*.': '</i>.',
|
||||||
replacements[word] = \
|
'*:': '</i>:',
|
||||||
'<i>' + word.replace('*', '') + '</i>'
|
'*;': '</i>;',
|
||||||
elif word.startswith('_') and word.endswith('_'):
|
'*,': '</i>,',
|
||||||
replacements[word] = \
|
'*\n': '</i>\n',
|
||||||
'<ul>' + word.replace('_', '') + '</ul>'
|
' _': ' <ul>',
|
||||||
|
'_ ': '</ul> ',
|
||||||
|
'_.': '</ul>.',
|
||||||
|
'_:': '</ul>:',
|
||||||
|
'_;': '</ul>;',
|
||||||
|
'_,': '</ul>,',
|
||||||
|
'_\n': '</ul>\n'
|
||||||
|
}
|
||||||
for md, html in replacements.items():
|
for md, html in replacements.items():
|
||||||
markdown = markdown.replace(md, html)
|
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
|
return markdown
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue