Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Add]able to del \n\t #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions test2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from tomd import Tomd

table='''
<table>
<thead>
<tr>
<th>head1</th>
<th>head2</th>
<th>head3</th>
</tr>
</thead>
<tbody>
<tr>
<td>content1</td>
<td>content2</td>
<td>content3</td>
</tr>
</tbody>
</table>
'''


md = Tomd(table).markdown
print("~~~~~~~~~~~~~")
print(md)
print("~~~~~~~~~~~~~")

'''
output
|head1|head2|head3
|------
|content1|content2|content3|
'''

1 change: 1 addition & 0 deletions tomd.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ def convert(self, html="", options=None):
if html == "":
html = self.html
# main function here
html = re.sub("\s+",'', html) #del \n\t
elements = []
for tag, pattern in BlOCK_ELEMENTS.items():
for m in re.finditer(pattern, html, re.I | re.S | re.M):
Expand Down