Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
tomd
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Jobs
Commits
Open sidebar
Чумбаев Максим
tomd
Commits
afe84521
Commit
afe84521
authored
Aug 29, 2017
by
aimer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add single img tag
parent
f57d0482
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
1 deletion
+5
-1
test_tomd.py
test_tomd.py
+1
-0
tomd.py
tomd.py
+4
-1
No files found.
test_tomd.py
View file @
afe84521
...
...
@@ -11,6 +11,7 @@ string = """
<p>paragraph
<a href="https://github.com">link</a>
<img src="https://github.com" class="dsad">img</img>
<img src="https://github.com" class="dsad"/>
</p>
<ul>
<li>1</li>
...
...
tomd.py
View file @
afe84521
...
...
@@ -69,13 +69,14 @@ INLINE_ELEMENTS = {
'ol'
:
'<ol.*?>(.*?)</ol>'
,
'li'
:
'<li.*?>(.*?)</li>'
,
'img'
:
'<img.*?src="(.*?)".*?>(.*?)</img>'
,
'img_single'
:
'<img.*?src="(.*?)".*?/>'
,
'a'
:
'<a.*?href="(.*?)".*?>(.*?)</a>'
,
'em'
:
'<em.*?>(.*?)</em>'
,
'strong'
:
'<strong.*?>(.*?)</strong>'
,
'tbody'
:
'<tbody.*?>((.|
\n
)*)</tbody>'
,
}
DELETE_ELEMENTS
=
[
'<span.*?>'
,
'</span>'
,
'<div.*?>'
,
'</div>'
,
'<br clear="none"/>'
]
DELETE_ELEMENTS
=
[
'<span.*?>'
,
'</span>'
,
'<div.*?>'
,
'</div>'
,
'<br clear="none"/>'
,
'<center.*?>'
,
'</center>'
]
class
Element
:
def
__init__
(
self
,
start_pos
,
end_pos
,
content
,
tag
,
folder
,
is_block
=
False
):
...
...
@@ -143,6 +144,8 @@ class Element:
self
.
content
=
re
.
sub
(
pattern
,
'[
\
g<2>](
\
g<1>)'
,
self
.
content
)
elif
tag
==
'img'
:
self
.
content
=
re
.
sub
(
pattern
,
'![
\
g<2>](
\
g<1>)'
,
self
.
content
)
elif
tag
==
'img_single'
:
self
.
content
=
re
.
sub
(
pattern
,
'![](
\
g<1>)'
,
self
.
content
)
elif
self
.
tag
==
'ul'
and
tag
==
'li'
:
self
.
content
=
re
.
sub
(
pattern
,
'-
\
g<1>'
,
self
.
content
)
elif
self
.
tag
==
'ol'
and
tag
==
'li'
:
...
...
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