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
2f1515f7
Commit
2f1515f7
authored
Aug 30, 2017
by
JiuLi Gao
Committed by
GitHub
Aug 30, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6 from aimreant/master
add single img tag and remove center tag
parents
f57d0482
afe84521
Changes
2
Hide 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 @
2f1515f7
...
@@ -11,6 +11,7 @@ string = """
...
@@ -11,6 +11,7 @@ string = """
<p>paragraph
<p>paragraph
<a href="https://github.com">link</a>
<a href="https://github.com">link</a>
<img src="https://github.com" class="dsad">img</img>
<img src="https://github.com" class="dsad">img</img>
<img src="https://github.com" class="dsad"/>
</p>
</p>
<ul>
<ul>
<li>1</li>
<li>1</li>
...
...
tomd.py
View file @
2f1515f7
...
@@ -69,13 +69,14 @@ INLINE_ELEMENTS = {
...
@@ -69,13 +69,14 @@ INLINE_ELEMENTS = {
'ol'
:
'<ol.*?>(.*?)</ol>'
,
'ol'
:
'<ol.*?>(.*?)</ol>'
,
'li'
:
'<li.*?>(.*?)</li>'
,
'li'
:
'<li.*?>(.*?)</li>'
,
'img'
:
'<img.*?src="(.*?)".*?>(.*?)</img>'
,
'img'
:
'<img.*?src="(.*?)".*?>(.*?)</img>'
,
'img_single'
:
'<img.*?src="(.*?)".*?/>'
,
'a'
:
'<a.*?href="(.*?)".*?>(.*?)</a>'
,
'a'
:
'<a.*?href="(.*?)".*?>(.*?)</a>'
,
'em'
:
'<em.*?>(.*?)</em>'
,
'em'
:
'<em.*?>(.*?)</em>'
,
'strong'
:
'<strong.*?>(.*?)</strong>'
,
'strong'
:
'<strong.*?>(.*?)</strong>'
,
'tbody'
:
'<tbody.*?>((.|
\n
)*)</tbody>'
,
'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
:
class
Element
:
def
__init__
(
self
,
start_pos
,
end_pos
,
content
,
tag
,
folder
,
is_block
=
False
):
def
__init__
(
self
,
start_pos
,
end_pos
,
content
,
tag
,
folder
,
is_block
=
False
):
...
@@ -143,6 +144,8 @@ class Element:
...
@@ -143,6 +144,8 @@ class Element:
self
.
content
=
re
.
sub
(
pattern
,
'[
\
g<2>](
\
g<1>)'
,
self
.
content
)
self
.
content
=
re
.
sub
(
pattern
,
'[
\
g<2>](
\
g<1>)'
,
self
.
content
)
elif
tag
==
'img'
:
elif
tag
==
'img'
:
self
.
content
=
re
.
sub
(
pattern
,
'![
\
g<2>](
\
g<1>)'
,
self
.
content
)
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'
:
elif
self
.
tag
==
'ul'
and
tag
==
'li'
:
self
.
content
=
re
.
sub
(
pattern
,
'-
\
g<1>'
,
self
.
content
)
self
.
content
=
re
.
sub
(
pattern
,
'-
\
g<1>'
,
self
.
content
)
elif
self
.
tag
==
'ol'
and
tag
==
'li'
:
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