Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
radiopanik
panikdb
Commits
b88fdd63
Commit
b88fdd63
authored
Aug 30, 2013
by
fred
Browse files
spip2html: regex to turning straight URLs into links
parent
af527ac7
Changes
1
Hide whitespace changes
Inline
Side-by-side
panikdb/emissions/management/commands/_spip2html.py
View file @
b88fdd63
...
...
@@ -228,6 +228,19 @@ class FormatterHtml(Formatter):
return
''
def
paragraph
(
self
,
text
):
# turn URL into links
def
repl
(
match
):
m
=
match
.
group
(
0
)
if
m
[
0
]
==
'"'
and
m
[
-
1
]
==
'"'
:
return
m
if
m
[
0
]
in
'>'
and
m
[
-
1
]
==
'<'
:
return
m
m
=
m
.
rstrip
(
'<'
).
lstrip
(
'>'
)
return
'<a href="%s">%s</a>'
%
(
m
,
m
)
t1
=
text
text
=
re
.
sub
(
r
'([">]?http[s]?://[a-zA-Z0-9\.\/-]*[<"]?)'
,
repl
,
text
,
re
.
DOTALL
)
if
self
.
states
[
-
1
]
==
'blockLevel'
:
self
.
states
.
pop
()
return
text
...
...
Write
Preview
Supports
Markdown
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