Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
wangsen
MinerU
Commits
2c75a375
Unverified
Commit
2c75a375
authored
Nov 04, 2024
by
Xiaomeng Zhao
Committed by
GitHub
Nov 04, 2024
Browse files
Merge pull request #855 from myhloli/add-structeqtable
feat(model): add HTML minification to StructTableModel
parents
dc31c97b
b5117e72
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
0 deletions
+14
-0
magic_pdf/model/pek_sub_modules/structeqtable/StructTableModel.py
...f/model/pek_sub_modules/structeqtable/StructTableModel.py
+14
-0
No files found.
magic_pdf/model/pek_sub_modules/structeqtable/StructTableModel.py
View file @
2c75a375
import
re
import
torch
from
struct_eqtable
import
build_model
...
...
@@ -28,4 +30,16 @@ class StructTableModel:
images
,
output_format
=
output_format
)
if
output_format
==
"html"
:
results
=
[
self
.
minify_html
(
html
)
for
html
in
results
]
return
results
def
minify_html
(
self
,
html
):
# 移除多余的空白字符
html
=
re
.
sub
(
r
'\s+'
,
' '
,
html
)
# 移除行尾的空白字符
html
=
re
.
sub
(
r
'\s*>\s*'
,
'>'
,
html
)
# 移除标签前的空白字符
html
=
re
.
sub
(
r
'\s*<\s*'
,
'<'
,
html
)
return
html
.
strip
()
\ No newline at end of file
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