Private
Public Access
0
0

feat(markdown): implement table rendering with imgui.begin_table

This commit is contained in:
2026-06-03 11:08:58 -04:00
parent 4d410c8ff4
commit f72e72c92c
2 changed files with 40 additions and 0 deletions
+20
View File
@@ -1,8 +1,28 @@
import re
from dataclasses import dataclass
from imgui_bundle import imgui
_TABLE_SEPARATOR = re.compile(r"^\|?\s*:?-{2,}:?\s*(\|\s*:?-{2,}:?\s*)+\|?\s*$")
def render_table(block: "TableBlock") -> None:
"""Render a GFM table block via imgui.begin_table.
[C: src/markdown_helper.py:MarkdownRenderer.render]
"""
n_cols = len(block.headers)
if n_cols == 0: return
flags = imgui.TableFlags_.borders | imgui.TableFlags_.row_bg | imgui.TableFlags_.resizable
if not imgui.begin_table("md_table", n_cols, flags): return
imgui.table_headers_row()
for h in block.headers:
imgui.table_next_column()
imgui.text(h)
for row in block.rows:
imgui.table_next_row()
for c in row:
imgui.table_next_column()
imgui.text(c)
imgui.end_table()
@dataclass(frozen=True)
class TableBlock:
"""Frozen GFM table block.