mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-26 02:54:20 +00:00
Fix images and links parsing in doku_to_markdown
Signed-off-by: Skia <skia@libskia.so>
This commit is contained in:
parent
463e0b7055
commit
e5ce9658ee
@ -94,8 +94,10 @@ def doku_to_markdown(text):
|
|||||||
|
|
||||||
text = re.sub(r'\\{2,}[\s]', r' \n', text) # Carriage return
|
text = re.sub(r'\\{2,}[\s]', r' \n', text) # Carriage return
|
||||||
|
|
||||||
text = re.sub(r'\[\[(.*?)(\|(.*?))?\]\]', r'[\3](\1)', text) # Links
|
text = re.sub(r'\[\[(.*?)\|(.*?)\]\]', r'[\2](\1)', text) # Links
|
||||||
text = re.sub(r'{{(.*?)(\|(.*?))?}}', r'![\3](\1 "\3")', text) # Images
|
text = re.sub(r'\[\[(.*?)\]\]', r'[\1](\1)', text) # Links 2
|
||||||
|
text = re.sub(r'{{(.*?)\|(.*?)}}', r'![\2](\1 "\2")', text) # Images
|
||||||
|
text = re.sub(r'{{(.*?)(\|(.*?))?}}', r'![\1](\1 "\1")', text) # Images 2
|
||||||
text = re.sub(r'{\[(.*?)(\|(.*?))?\]}', r'[\1](\1)', text) # Video (transform to classic links, since we can't integrate them)
|
text = re.sub(r'{\[(.*?)(\|(.*?))?\]}', r'[\1](\1)', text) # Video (transform to classic links, since we can't integrate them)
|
||||||
|
|
||||||
text = re.sub(r'###(\d*?)###', r'[[[\1]]]', text) # Progress bar
|
text = re.sub(r'###(\d*?)###', r'[[[\1]]]', text) # Progress bar
|
||||||
|
@ -1276,10 +1276,13 @@ def migrate_forum():
|
|||||||
title=to_unicode(r['titre_message'])[:63],
|
title=to_unicode(r['titre_message'])[:63],
|
||||||
date=r['date_message'].replace(tzinfo=timezone('Europe/Paris')),
|
date=r['date_message'].replace(tzinfo=timezone('Europe/Paris')),
|
||||||
)
|
)
|
||||||
|
try:
|
||||||
if r['syntaxengine_message'] == "doku":
|
if r['syntaxengine_message'] == "doku":
|
||||||
msg.message = doku_to_markdown(to_unicode(r['contenu_message']))
|
msg.message = doku_to_markdown(to_unicode(r['contenu_message']))
|
||||||
else:
|
else:
|
||||||
msg.message = bbcode_to_markdown(to_unicode(r['contenu_message']))
|
msg.message = bbcode_to_markdown(to_unicode(r['contenu_message']))
|
||||||
|
except:
|
||||||
|
msg.message = to_unicode(r['contenu_message'])
|
||||||
msg.save()
|
msg.save()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(" FAIL to migrate message: %s" % (repr(e)))
|
print(" FAIL to migrate message: %s" % (repr(e)))
|
||||||
|
Loading…
Reference in New Issue
Block a user