Commit b5117e72 authored by myhloli's avatar myhloli

feat(model): add HTML minification to StructTableModel

- Import 're' module for regular expression operations
- Implement HTML minification for 'output_format=html'
- Add 'minify_html' method to remove unnecessary whitespace and format HTML
parent 5ee02a99
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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment