Skip to main content

wrap_tables

Function wrap_tables 

Source
fn wrap_tables(html: &str) -> String
Expand description

把每个 <table>...</table> 包进可横向滚动的 <div class="table-wrap">

移动端窄屏下宽表格无法横向滚动:pulldown-cmark 产出裸 table,外层 <main> 又是 overflow-hidden 会把超宽内容直接裁掉。这里给 table 套一层 table-wrap(CSS 配 overflow-x: auto),让表格在容器内滚动而非撑破页面。

正则匹配 pulldown-cmark 输出的 <table ...>...</table>(非贪婪、跨行),包裹整个 table 标签。对已包裹的 HTML 幂等(不会二次嵌套)——table-wrap div 内的 table 仍会被正则命中并再次包裹,故调用方仅在渲染管线调用一次。