Repository navigation
fix(html2md): preserve mathematical and inline formatting semantics - #1335
lanyue-llk wants to merge 4 commits into
Conversation
Spider Bench A/B✅ All benchmark browser service runs completed; results are informational. Public HEAD: 189 / 240 rows; 39 / 48 sites produced rows; 9 unexpected empty sites. ✅ Deterministic fixture contract is clean. Common ancestor Public 48-site run · informational
Public-site content, timing, and memory are noisy. This single A/B run reports evidence only; site outcome counts explain missing rows without treating them as a deterministic regression. CPU and memory timelinesThese are bounded 40-point views of the same complete process-tree samples used by the HTML report. CPU uses 100% per occupied logical core; memory lines are RSS first and PSS second when complete PSS samples are available. Basexychart-beta
title "Base CPU"
x-axis "Elapsed seconds" [1.564, 2.566, 3.067, 4.569, 6.069, 7.572, 9.073, 10.075, 11.577, 13.079, 14.581, 16.084, 17.584, 18.585, 19.086, 20.588, 22.09, 23.591, 25.093, 26.595, 27.597, 29.098, 30.599, 31.601, 32.102, 33.604, 35.106, 36.607, 38.108, 39.609, 41.11, 42.612, 44.114, 45.115, 46.616, 48.118, 49.62, 51.122]
y-axis "CPU percent" 0 --> 500
line [25.96, 119.78, 127.78, 115.85, 191.97, 159.56, 91.96, 147.65, 155.82, 113.89, 135.65, 119.87, 8, 0, 3.99, 0, 1.99, 115.86, 15.99, 55.95, 125.84, 123.82, 139.85, 107.79, 107.79, 133.85, 29.96, 127.84, 143.88, 95.92, 5.99, 117.89, 91.89, 13.99, 22, 129.96, 25.96, 101.82]
xychart-beta
title "Base memory: RSS then PSS"
x-axis "Elapsed seconds" [0.062, 1.564, 2.566, 3.067, 4.569, 6.069, 7.572, 9.073, 10.075, 11.577, 13.079, 14.581, 16.084, 17.584, 18.585, 19.086, 20.588, 22.09, 23.591, 25.093, 26.595, 27.597, 29.098, 30.599, 31.601, 32.102, 33.604, 35.106, 36.607, 38.108, 39.609, 41.11, 42.612, 44.114, 45.115, 46.616, 48.118, 49.62, 51.122, 52.367]
y-axis "Memory MiB" 0 --> 500
line [12.44, 82.72, 118.51, 134.78, 130.39, 166.22, 171.58, 179.73, 182.87, 166.68, 187.49, 201.75, 164.07, 151.59, 147.31, 147.7, 147.59, 148.57, 177.2, 143.65, 153.55, 181.42, 164.26, 174.8, 288.9, 235.82, 207.65, 168.54, 182.72, 179.8, 149.19, 154.55, 243.81, 275.88, 217.42, 182.84, 208.5, 156.93, 194.16, 0]
line [9.18, 79.11, 115.05, 131.32, 126.75, 162.44, 168.2, 175.99, 179.32, 162.98, 183.95, 196.06, 160.53, 148.08, 143.7, 144.1, 143.98, 144.97, 173.71, 140.09, 150.05, 178.08, 157.4, 171.34, 285.8, 231.91, 204.14, 165.03, 179.21, 176.32, 143.62, 151.04, 240.48, 272.44, 213.91, 178.92, 204.81, 153.31, 190.54, 0]
HEADxychart-beta
title "HEAD CPU"
x-axis "Elapsed seconds" [2.045, 4.049, 5.551, 7.553, 9.554, 11.557, 13.06, 15.062, 17.066, 19.07, 20.571, 21.572, 22.573, 24.576, 26.578, 28.081, 30.082, 31.084, 32.084, 34.088, 35.589, 37.592, 39.593, 41.596, 43.156, 45.16, 47.161, 54.794, 56.293, 58.297, 60.299, 62.301, 63.803, 64.804, 65.806, 67.806, 69.808, 71.311]
y-axis "CPU percent" 0 --> 500
line [133.71, 121.91, 143.86, 165.79, 157.9, 149.78, 9.97, 155.8, 47.88, 155.55, 57.98, 0, 2, 0, 101.91, 85.87, 155.83, 103.87, 109.86, 157.59, 161.87, 145.92, 87.99, 57.9, 116.14, 79.81, 31.95, 99.85, 32.01, 35.93, 40, 7.99, 5.99, 203.81, 75.92, 0, 0, 25.97]
xychart-beta
title "HEAD memory: RSS then PSS"
x-axis "Elapsed seconds" [0.042, 2.045, 4.049, 5.551, 7.553, 9.554, 11.557, 13.06, 15.062, 17.066, 19.07, 20.571, 21.572, 22.573, 24.576, 26.578, 28.081, 30.082, 31.084, 32.084, 34.088, 35.589, 37.592, 39.593, 41.596, 43.156, 45.16, 47.161, 54.794, 56.293, 58.297, 60.299, 62.301, 63.803, 64.804, 65.806, 67.806, 69.808, 71.311, 72.839]
y-axis "Memory MiB" 0 --> 500
line [12.41, 124.45, 148.25, 145.15, 191.13, 177.18, 168.69, 156.55, 171.15, 143.77, 165.37, 152.99, 147.96, 146.67, 146.71, 155.32, 145.17, 174.79, 294.77, 215.98, 159.66, 166.59, 176.77, 166.94, 163.68, 185.17, 168.63, 155.39, 192.45, 179.88, 181.64, 182.19, 139.65, 144.34, 163.17, 149.91, 157.34, 153.93, 153.95, 0]
line [9.2, 121, 144.97, 141.68, 187.68, 173.91, 165.23, 152.89, 167.5, 140.08, 161.68, 149.3, 144.27, 142.98, 143.02, 151.7, 141.92, 171.1, 291.06, 212.28, 156.06, 163.02, 172.84, 163.33, 159.84, 181.3, 164.83, 151.53, 188.59, 176.02, 177.83, 178.35, 135.83, 140.52, 161.86, 146.25, 153.67, 150.25, 150.37, 0]
Deterministic fixture · required contractThe fixture exercises 15 routes: 8 are expected to emit rows and 7 intentionally exercise empty, loading, or timeout behavior.
Full HTML, JSON, CSV, logs, and page snapshots: workflow run and full The public-web A/B is informational. The exact HEAD fixture contract runs as a separate required CI check; timing and public-site content deltas remain non-blocking. |
CI Regression ReportSource CI run · source state at render:
Release regression — ✅ HEAD/base failures 0/0; raw binary +0.011718%Package and image size
Startup latency and PSS
Concurrency matrix
Frontend differential — ✅ 1,020/1,020 cases matched; 0 issues; 1 Chromium reference recoveries
Recovered Chromium reference infrastructure failures
Agent episodes · Moli vs Chromium — ✅ 8/8 Moli episodes passed; 0 failures
Runtime and CDP session contracts — ✅ 26 contract cases; 0 failures
CDP smoke — ✅ 52/52 groups passed; 621 scenariosWorkers: 4 · cumulative group time: 196.06 s · failed groups: 0
WebMainBench · 545 pages — ✅ 545/545 completed; 0 unexpected failures
Frozen HTML · Linux · Diagnostics: All artifact fields are parsed by the trusted default-branch renderer; missing or invalid inputs remain visible as unavailable. |
c57d52b to
f3cceb4
Compare
Sequential Navigation Soak A/B✅ HEAD completed the 200-navigation resilience and memory observation. One browser process, one target, and one CDP session navigate CSDN → SegmentFault → Huaban → example.com repeatedly. This run issued 200 Common ancestor Session resilience
A public-page failure is reported separately from an unrecoverable session. The soak requires all navigation attempts, zero failed recovery, zero lifecycle/network ordering violations, and complete resource evidence. Process-tree memory
HEAD memory by 50-navigation quarter
Raw reports and per-navigation boundary samples: workflow run and full Public-site timing and memory are observational. Use the A/B deltas and trend shape as evidence, not as a deterministic performance threshold. |
8928f56 to
0f62c65
Compare
0f62c65 to
d5b0e56
Compare
d5b0e56 to
cd0193d
Compare
|
Closing after the consolidation audit. This belongs to an earlier experimental Markdown stack and was not part of the measured fixed build. Current failure evidence does not justify carrying its broad formatting expansion into #1501, so it is intentionally not merged. |
问题与方案
原转换会把 TeX 的反斜杠、下标和矩阵分隔符当成普通 Markdown 转义;公式跨越无格式的内联包装时还会被拆断。上下标、MathML 结构和部分嵌套格式也会丢失语义。
本 PR 在真正的格式边界处处理连续文字,保留完整 TeX;货币、未闭合公式和代码仍按各自语义处理。MathML 保留结构,只输出一份语义公式,排除其视觉副本。上下标使用对应 HTML 元素。代码文字排除嵌入的复制按钮及脚本,图片标签和链接标题的换行不再意外变成 Markdown 标题。
根因、方案与验收
本组基于 #1334,作为原生 stack 的第二层。公式与格式修复有独立的场景测试;本 PR 的 diff 只包含这组增量。
修复机制图
flowchart LR A[连续文字与透明内联包装] --> B[收集同一文字流] B --> C{完整且有效的公式边界?} C -->|是| D[保留 TeX 语义] C -->|否| E[普通 Markdown 转义] F[MathML 与视觉副本] --> G[保留唯一语义结构] D --> H[Markdown 输出] E --> H G --> H范围与依赖
这是 #919 的公式与格式部分,基于 #1334 的媒体与表单规则。#1336 的复杂表格复用这两组规则,#1337 提供运行时 CSS 适配。
验证
cargo fmt --all --check:通过。cargo test -p moli-html2md --locked:独立基线的 314 个场景通过。cargo clippy -p moli-html2md --all-targets --locked -- -D warnings:通过。8928f56ab92b550b7cbfcb0048ff1781ac5c1cfc,集成快照已包含 main 的 gamepad 与 credential 测试修复。<sup>/<sub>。场景覆盖透明包装中的公式、段落/标题/列表/普通表格、货币与代码、嵌套上下标、MathML 分式和根式、重复视觉表达、恶意文字与嵌套格式。完整仓库测试交由 CI。
与 #1305 的关系
#1305 直接基于 main,负责执行调用者明确指定的脚本,等待 Promise 和导航后走标准导出路径。这四组修复负责导出内容的完整性与语义。双方没有代码前置依赖;组合后,交互后的 DOM 会使用这些共享转换规则。
默认只读采集和明确交互采集是不同的测量协议。报告中的历史成绩仍绑定原调用协议;不能给单一方法补交互后替换同一行成绩。
报告
完整 WebMainBench 报告 保留 #919 已发布的运行,源码为
721bd2e329f96c06573db6e6b257a149cf17a6fe;该测量不对应本拆分分支。最新 main 的 gamepad 测试编译问题已由独立的 #1343 修复并合入。该测试文件不在本组差异中。
PR stack
GitHub 原生依赖链:#1334 → #1335 → #1336 → #1337 → #1380 → #1428 → #1431 → #1432。
每个 PR 的 GitHub base 都是左侧紧邻分支,因此 Files changed 只显示本层增量。按从左到右的顺序合入。#919 是保留的历史完整组合,不是这条链的依赖;#1429 独立面向
main,只提供通用 CI 评测入口。