MCPcopy Create free account
hub / github.com/Topdu/OpenOCR / extract_table_from_html

Function extract_table_from_html

tools/to_markdown.py:56–68  ·  view source on GitHub ↗

Extract and clean table tags from HTML string

(html_string)

Source from the content-addressed store, hash-verified

54
55
56def extract_table_from_html(html_string):
57 """Extract and clean table tags from HTML string"""
58 try:
59 table_pattern = re.compile(r'<table.*?>.*?</table>', re.DOTALL)
60 tables = table_pattern.findall(html_string)
61 tables = [
62 re.sub(r'<table[^>]*>', '<table>', table) for table in tables
63 ]
64 # tables = [re.sub(r'>\n', '>', table) for table in tables]
65 return '\n'.join(tables)
66 except Exception as e:
67 print(f'extract_table_from_html error: {str(e)}')
68 return f'<table><tr><td>Error extracting table: {str(e)}</td></tr></table>'
69
70
71rules = [

Callers 1

_handle_tableMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected