Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
AE
Sith
Commits
e5ce9658
Commit
e5ce9658
authored
May 31, 2017
by
Skia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix images and links parsing in doku_to_markdown
Signed-off-by:
Skia
<
skia@libskia.so
>
parent
463e0b70
Pipeline
#1005
failed with stage
in 4 minutes and 29 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
6 deletions
+11
-6
core/utils.py
core/utils.py
+4
-2
migrate.py
migrate.py
+7
-4
No files found.
core/utils.py
View file @
e5ce9658
...
@@ -94,8 +94,10 @@ def doku_to_markdown(text):
...
@@ -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
''
,
text
)
# Images
text
=
re
.
sub
(
r
'\[\[(.*?)\]\]'
,
r
'[\1](\1)'
,
text
)
# Links 2
text
=
re
.
sub
(
r
'{{(.*?)\|(.*?)}}'
,
r
''
,
text
)
# Images
text
=
re
.
sub
(
r
'{{(.*?)(\|(.*?))?}}'
,
r
''
,
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
...
...
migrate.py
View file @
e5ce9658
...
@@ -1276,10 +1276,13 @@ def migrate_forum():
...
@@ -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'
)),
)
)
if
r
[
'syntaxengine_message'
]
==
"doku"
:
try
:
msg
.
message
=
doku_to_markdown
(
to_unicode
(
r
[
'contenu_message'
]))
if
r
[
'syntaxengine_message'
]
==
"doku"
:
else
:
msg
.
message
=
doku_to_markdown
(
to_unicode
(
r
[
'contenu_message'
]))
msg
.
message
=
bbcode_to_markdown
(
to_unicode
(
r
[
'contenu_message'
]))
else
:
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
)))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment