Skip to content

fix(html2md): preserve media resources and readable controls - #1334

Merged
ldm0 merged 13 commits into
mainfrom
codex/content-media-forms
Oct 24, 2026
Merged

ldm0 merged 13 commits into
mainfrom
codex/content-media-forms

Conversation

@lanyue-llk

@lanyue-llk lanyue-llk commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

问题

DOM 转 Markdown 会丢失没有有效 src 的图片标签、响应式图片候选和表单的可读状态。另一方面,按 class 或文件名猜内容也会制造错误:询价区域可能变成引用,空图标可能变成勾号,合法图片可能被私有懒加载地址替换。

一图看懂

标准资源优先,私有懒加载声明仅作后备

修改

  • 标准 srcset/src 优先;标准资源不可用时才读取私有懒加载声明。合法 data image 保留,文件名不作为占位图证据。

  • 图片按 alt、aria-label、title 保留文字替代;无有效视频源时仍保留 poster。媒体链接在段落、强调和表格中保持行内结构。

  • 保留表单文字、选项边界和可访问标签;密码值、隐藏输入和文件输入不导出。转换器保留调用方选定 DOM 的内容,不负责选择文章正文。

  • 删除 quote、图标 class 和 Bootstrap tooltip 属性的特殊语义。标准 blockquote、实际文字和 aria-label/title 继续工作。

  • poster 与视频回退内容分别保留:没有有效 src 时,下载链接和说明仍会导出。

  • 显式空 alt 保持装饰语义;只有缺少 alt 时才考虑 title。空文本字段不把标签输出成已填写的值,按钮仍保留名称。

  • srcset 解析结果公开提供已验证的宽、高和密度,浏览器选择直接读取字段。

非空作者 alt 优先保留;hidden、aria-hidden 与 presentation 只限制合成名称。poster 使用规范化 URL,srcset 的括号状态遵循 HTML 的非嵌套规则。

验证

  • cargo test -p moli-html2md --locked 通过。
  • 名称猜测的两个反例在修复前失败、修复后通过,同时检查标准引用、可访问标签、有效 data image 与无效地址后备。
  • 嵌套可访问标签的节点访问量随输入线性增长;补测每层带大块无文字 SVG 的分支,深度扩大四倍仍保持线性。
  • textarea 的非标准 value 属性覆盖正文问题,修复前失败、修复后通过。纯 HTML 默认读取子文本,浏览器适配器通过 control_value 提供实时值,空值同样有效。
  • 响应式图片的浏览器选择和 Markdown 导出共用 srcset 语法解析器;实际图片选择另有 9 项回归验证,包含非 ASCII 空白描述符。
  • 实时 input、textarea 的非空值及清空值均由可选 DOM 接口测试覆盖。
  • HTTP Date 测试保留:跨秒比较仍验证完整输出,没有放宽断言。

复现

本 PR 的转换库测试可独立运行:cargo test -p moli-html2md --locked。浏览器接入在 #1337,以下 CLI 与冻结页复现使用完整 stack。

最小用例

标准图片地址必须优先于私有懒加载地址;表单标签和值都要保留。

fixture_html=$(cat <<'HTML'
<img src="https://example.test/real.png" data-src="https://example.test/lazy.png" alt="Diagram"><p><label>Name <input value="Ada"></label></p>
HTML
)
"$MOLI_BINARY" fetch "data:text/html;base64,$(printf '%s' "$fixture_html" | base64 | tr -d '\n')" --dump markdown

实际输出:

![Diagram](https://example.test/real.png)

Name Ada

真实 WebMainBench 页面

75b0c1e9… 家具页:保留 Pimlico 图片的替代文字及标准资源地址。

七个相关页面通过 browser-eval 的现有 runner 共用一次定向运行,7/7 正常导出,并核对上述内容;不是 545 页质量重测。查看冻结输入、实际输出与核对结果。

  • Moli:19bfc785;二进制 SHA-256:1c17bba8cb6b0a532144697411d13ec6a3872d1abad96d5872da0ded93d7b8b4。
  • browser-eval:345ea093。
  • 原始数据集 SHA-256:0efaa4b49a45e320a27fe6e5a0b6aad5b57259fc3321ac3448519cacc74c537e,runner 会校验。保留原网址,代理返回冻结 HTML,外部资源禁止访问,无点击或 DOM 改写。
环境准备与可复制命令
# Moli 仓库:构建完整 stack,供下面的 CLI 复现使用。
git fetch origin refs/pull/1337/head
git switch --detach 19bfc785f2e0114d7d88e17457de7c108a54069d
cargo build -p moli --bin moli --locked
export MOLI_BINARY="$PWD/target/debug/moli"

# 在单独目录准备 browser-eval。
git clone https://github.com/lexmount/browser-eval.git
cd browser-eval
git checkout 345ea09370a633e871670fde2de4ec25b53a4d05
uv sync --frozen
mkdir -p "$HOME/.browser-eval/public-benchmarks/webmainbench-545"
curl --fail --location \
  https://huggingface.co/datasets/opendatalab/WebMainBench/resolve/main/WebMainBench_545.jsonl \
  --output "$HOME/.browser-eval/public-benchmarks/webmainbench-545/WebMainBench_545.jsonl"

# 在 browser-eval 仓库运行;使用 macOS 的 loopback-only 沙箱。
# MOLI_BINARY 为上面构建的 Moli 的绝对路径。
export MOLI_BINARY
repro_root=$(mktemp -d)
cat > "$repro_root/cases.txt" <<'CASES'
75b0c1e9-d112-46d0-adc8-d1d09aa48731
bfaf0844-440c-466b-b55a-f82c88a54a4e
34b822a2-f7d6-4b69-b6af-133a1ca21326
8798f93a-240c-46d7-a8d1-a5fb011279fc
d80cf991-ba87-4068-80b4-3e9bd49ac8fd
72dd5ff7-8cb5-4660-8941-c1846a43a15d
ccb6033c-0a12-4f9c-8c68-794f26129841
CASES
uv run --frozen python scripts/run_webmainbench_benchmark.py \
  --provider moli --case-ids-file "$repro_root/cases.txt" \
  --preserve-original-origin --expected-version 1.1.19 \
  --timeout 90 --max-failure-retries 0 \
  --output "$repro_root/results"
printf '结果目录:%s\n' "$repro_root/results"

results.jsonl 记录成功状态、错误和输入/输出哈希,execution.json 记录二进制身份,artifacts/moli/ 保存实际 Markdown。定向运行只用于定位和回归,不进入正式榜单;报告中的历史成绩仍绑定原测量版本。

依赖

基于 main bd8e0b27。#1334 → #1335 → #1336 → #1337 → #1380

@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

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 Page.navigate commands per binary.

Common ancestor f12f497bf1 → HEAD 25215af61f; benchmark order: head-first; workflow: success.

Session resilience

Metric Base HEAD
Attempted / planned 200 / 200 200 / 200
Direct observable pass 200 / 200 199 / 200
Failures / recovered 0 / 0 1 / 1
Recovery failures 0 0
Lifecycle order violations 0 0
Network order violations 0 0
Wall time 471.7 s 446.9 s

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

Metric Base HEAD Δ
Boundary samples 200 200 0
Boundary RSS samples 200 200 0
Boundary PSS samples 200 200 0
Periodic peak RSS 253.1 MiB 256.7 MiB +3.6 MiB
Periodic peak PSS 250.3 MiB 253.2 MiB +3.0 MiB
RSS · first 10 avg 187.3 MiB 176.6 MiB -10.7 MiB
RSS · last 10 avg 180.2 MiB 180.5 MiB +0.3 MiB
RSS · last − first window -7.1 MiB +3.9 MiB +11.0 MiB
RSS · warm slope / 100 nav +3.3 MiB +4.1 MiB +0.8 MiB
PSS · first 10 avg 183.8 MiB 173.2 MiB -10.6 MiB
PSS · last 10 avg 176.9 MiB 176.8 MiB -0.1 MiB
PSS · last − first window -7.0 MiB +3.6 MiB +10.5 MiB
PSS · warm slope / 100 nav +3.0 MiB +4.1 MiB +1.1 MiB
Peak file descriptors 57 56 -1
Peak threads 29 29 0

HEAD memory by 50-navigation quarter

HEAD range Avg RSS Final RSS Peak RSS Avg PSS Final PSS Peak FD
1–50 174.2 MiB 148.8 MiB 207.9 MiB 170.7 MiB 145.5 MiB 52
51–100 178.0 MiB 205.6 MiB 213.5 MiB 174.7 MiB 202.7 MiB 53
101–150 183.5 MiB 184.1 MiB 216.1 MiB 180.7 MiB 180.9 MiB 52
151–200 184.9 MiB 132.6 MiB 226.3 MiB 181.3 MiB 129.0 MiB 52

Raw reports and per-navigation boundary samples: workflow run and full sequential-navigation-soak-results artifact.

Public-site timing and memory are observational. Use the A/B deltas and trend shape as evidence, not as a deterministic performance threshold.

@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Spider Bench A/B

✅ All benchmark browser service runs completed; results are informational.

Public HEAD: 184 / 240 rows; 38 / 48 sites produced rows; 10 unexpected empty sites.

✅ Deterministic fixture contract is clean.

Common ancestor f12f497bf154 → HEAD 25215af61f2d; benchmark order: head-first; workflow: success.

Public 48-site run · informational

Metric Base HEAD Δ
Run status success success —
Extracted rows / contract 184 / 240 184 / 240 0 (0.00%)
Contract fill 76.67% 76.67% 0.00 pp (0.00%)
Sites with rows 38 / 48 38 / 48 0 (0.00%)
Sites meeting row contract 36 / 48 36 / 48 0 (0.00%)
Unexpected empty sites 10 10 0 (0.00%)
Partial-row sites 2 2 0 (0.00%)
Site outcomes extracted: 37; HTTP error + rows: 1; empty: 7; HTTP error + empty: 1; snapshot error + empty: 2 extracted: 36; HTTP error + rows: 2; empty: 7; HTTP error + empty: 1; snapshot error + empty: 2 —
Observed duration 57.64 s 64.38 s +6.74 s (+11.69%)
Estimated CPU 43.39 s 46.88 s +3.49 s (+8.05%)
Peak PSS 268.64 MiB 261.05 MiB -7.59 MiB (-2.83%)
Peak RSS 271.79 MiB 264.81 MiB -6.98 MiB (-2.57%)
Peak threads 27 26 -1 (-3.70%)
Mismatched sites 0 0 0
Timeout with items 0 0 0
Category rows Base HEAD Δ
news 35 / 40 35 / 40 0
stocks 20 / 40 20 / 40 0
tech 35 / 40 35 / 40 0
sports 27 / 40 27 / 40 0
games 37 / 40 37 / 40 0
life 30 / 40 30 / 40 0

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 timelines

These 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.

Base

xychart-beta
    title "Base CPU"
    x-axis "Elapsed seconds" [1.035, 1.536, 3.039, 4.542, 5.042, 6.044, 6.544, 8.045, 9.546, 11.551, 13.051, 14.554, 16.055, 17.558, 19.56, 21.061, 22.563, 24.065, 26.066, 27.566, 29.068, 30.571, 32.073, 34.077, 35.578, 37.079, 38.583, 40.583, 42.085, 43.587, 45.089, 46.592, 48.592, 50.094, 51.596, 53.099, 55.101, 56.604]
    y-axis "CPU percent" 0 --> 200
    line [0, 11.98, 0, 129.76, 117.86, 125.83, 144.02, 129.98, 29.99, 89.79, 133.99, 103.86, 0, 113.81, 0, 4, 0, 3.99, 2, 0, 27.95, 51.9, 113.95, 101.87, 131.78, 141.95, 103.76, 118.16, 103.93, 7.99, 157.76, 91.78, 2, 99.94, 99.91, 137.88, 47.97, 133.6]
Loading
xychart-beta
    title "Base memory: RSS then PSS"
    x-axis "Elapsed seconds" [0.034, 1.035, 1.536, 3.039, 4.542, 5.042, 6.044, 6.544, 8.045, 9.546, 11.551, 13.051, 14.554, 16.055, 17.558, 19.56, 21.061, 22.563, 24.065, 26.066, 27.566, 29.068, 30.571, 32.073, 34.077, 35.578, 37.079, 38.583, 40.583, 42.085, 43.587, 45.089, 46.592, 48.592, 50.094, 51.596, 53.099, 55.101, 56.604, 57.639]
    y-axis "Memory MiB" 0 --> 500
    line [12.92, 54.91, 67.38, 76.74, 113.81, 122.43, 138.54, 140.13, 134.82, 127.08, 132.38, 147.11, 117.18, 119.11, 150.27, 116.44, 116.61, 115.61, 115.61, 115.61, 115.61, 126.75, 154.33, 141.39, 271.79, 181.15, 215.31, 144.73, 150.33, 137.61, 138.33, 180.47, 155.16, 129.38, 151.39, 154.72, 165.27, 137.04, 170.74, 0]
    line [9.58, 51.35, 63.81, 73.15, 110.21, 119.06, 133.74, 136.23, 131.22, 123.62, 128.87, 143.52, 113.55, 115.47, 146.66, 112.81, 112.98, 111.98, 111.98, 111.98, 111.98, 123.12, 150.7, 137.93, 268.64, 177.52, 211.71, 141.16, 146.7, 133.98, 134.71, 176.77, 151.54, 125.87, 147.76, 151.09, 161.68, 133.41, 167.14, 0]
Loading

HEAD

xychart-beta
    title "HEAD CPU"
    x-axis "Elapsed seconds" [1.036, 1.537, 2.038, 3.54, 5.543, 7.044, 9.047, 11.049, 12.551, 14.551, 16.051, 18.051, 19.551, 21.553, 23.556, 25.058, 27.06, 28.561, 30.565, 32.568, 33.068, 34.069, 36.072, 37.575, 39.577, 41.077, 43.08, 45.083, 46.584, 48.586, 50.089, 52.091, 54.094, 55.596, 57.597, 59.099, 61.101, 62.602]
    y-axis "CPU percent" 0 --> 200
    line [0, 2, 0, 17.96, 63.85, 111.94, 121.82, 102.06, 132, 66.02, 112.02, 100.03, 121.96, 3.99, 3.99, 0, 2, 88.02, 63.89, 114.03, 101.92, 121.8, 147.66, 59.86, 109.88, 35.96, 71.96, 27.92, 137.95, 83.85, 31.97, 4, 137.93, 99.89, 101.89, 99.86, 149.85, 119.96]
Loading
xychart-beta
    title "HEAD memory: RSS then PSS"
    x-axis "Elapsed seconds" [0.035, 1.036, 1.537, 2.038, 3.54, 5.543, 7.044, 9.047, 11.049, 12.551, 14.551, 16.051, 18.051, 19.551, 21.553, 23.556, 25.058, 27.06, 28.561, 30.565, 32.568, 33.068, 34.069, 36.072, 37.575, 39.577, 41.077, 43.08, 45.083, 46.584, 48.586, 50.089, 52.091, 54.094, 55.596, 57.597, 59.099, 61.101, 62.602, 64.378]
    y-axis "Memory MiB" 0 --> 500
    line [13.06, 54.67, 54.8, 54.8, 72.68, 91.97, 144.8, 148.69, 156.11, 153.18, 130.8, 157.67, 133.33, 115.27, 113.89, 120.71, 119.75, 119.77, 134.03, 139.48, 203.13, 264.81, 179.21, 220.29, 146.88, 175.85, 132.83, 139.91, 134.95, 190.77, 229.54, 145.43, 127.18, 147.38, 174.2, 174.85, 174.85, 158.2, 144.64, 0]
    line [9.61, 51.06, 51.18, 51.18, 69.05, 88.35, 141.17, 145.03, 152.5, 150.68, 127.17, 154.09, 129.69, 111.62, 110.13, 116.96, 116, 116.02, 130.86, 135.73, 199.4, 261.05, 175.48, 216.34, 143.18, 172.25, 129.18, 136.3, 131.37, 187.26, 226, 141.85, 123.6, 144.33, 170.62, 171.27, 171.27, 154.72, 141.04, 0]
Loading

Deterministic fixture · required contract

The fixture exercises 15 routes: 8 are expected to emit rows and 7 intentionally exercise empty, loading, or timeout behavior.

Metric Base HEAD Δ
Run status success success —
Extracted rows / contract 40 / 40 40 / 40 0 (0.00%)
Contract fill 100.00% 100.00% 0.00 pp (0.00%)
Sites with rows 8 / 15 8 / 15 0 (0.00%)
Sites meeting row contract 15 / 15 15 / 15 0 (0.00%)
Unexpected empty sites 0 0 0
Partial-row sites 0 0 0
Site outcomes extracted: 7; HTTP error + rows: 1; empty: 3; timeout + empty: 4 extracted: 7; HTTP error + rows: 1; empty: 3; timeout + empty: 4 —
Observed duration 19.85 s 19.85 s -0.00 s (0.00%)
Estimated CPU 0.42 s 0.42 s 0.00 s (0.00%)
Peak PSS 66.27 MiB 66.64 MiB +0.37 MiB (+0.56%)
Peak RSS 69.71 MiB 69.96 MiB +0.25 MiB (+0.36%)
Peak threads 18 18 0 (0.00%)
Mismatched sites 0 0 0
Timeout with items 0 0 0

Full HTML, JSON, CSV, logs, and page snapshots: workflow run and full spider-bench-results artifact.

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.

@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

CI Regression Report

Source CI run · source state at render: in_progress · artifacts: 6/6

Check Status Signal
Release regression ✅ HEAD/base failures 0/0; raw binary +0.011095%
Frontend differential ✅ 1,020/1,020 cases matched; 0 issues
Agent episodes ✅ 8/8 Moli episodes passed; 0 failures
Runtime/CDP contracts ✅ 26 contract cases; 0 failures
CDP smoke ✅ 53/53 groups passed; 628 scenarios
WebMainBench ✅ 545/545 completed; 0 unexpected failures
Release regression — ✅ HEAD/base failures 0/0; raw binary +0.011095%

Package and image size

Metric Base HEAD Delta Delta %
Raw binary 150.39 MiB 150.40 MiB +17.09 KiB +0.011095%
Stripped binary 103.44 MiB 103.46 MiB +16.00 KiB +0.015105%
gzip binary 51.65 MiB 51.66 MiB +10.30 KiB +0.019478%
Rootfs 157.29 MiB 157.30 MiB +20.00 KiB +0.012418%
gzip rootfs 60.56 MiB 60.57 MiB +6.16 KiB +0.009932%

Startup latency and PSS

Case Base p50 HEAD p50 Delta Base PSS HEAD PSS Delta
Serve ready 26.75 ms 26.86 ms +0.11 ms 5.23 MiB 5.88 MiB +668.50 KiB
CDP first page 49.03 ms 48.75 ms −0.28 ms 5.20 MiB 5.30 MiB +107.50 KiB
CDP warm page 12.48 ms 12.28 ms −0.20 ms 50.99 MiB 51.23 MiB +239.00 KiB
CLI about:blank 15.49 ms 15.10 ms −0.39 ms 3.84 MiB 4.81 MiB +986.50 KiB
CLI local JS 19.53 ms 18.67 ms −0.87 ms 4.58 MiB 4.08 MiB −517.00 KiB

Concurrency matrix

Concurrency Base p50 HEAD p50 Delta Base PSS HEAD PSS Delta HEAD failures Unstable B/H
1 17.42 ms 17.72 ms +0.30 ms 734.00 KiB 738.00 KiB +4.00 KiB 0 0/0
5 19.97 ms 19.47 ms −0.50 ms 26.56 MiB 18.71 MiB −7.85 MiB 0 0/0
10 19.86 ms 19.42 ms −0.45 ms 27.94 MiB 13.66 MiB −14.28 MiB 0 0/0
25 20.81 ms 20.15 ms −0.66 ms 27.98 MiB 13.92 MiB −14.06 MiB 0 0/0
100 19.91 ms 19.50 ms −0.41 ms 27.94 MiB 28.19 MiB +254.00 KiB 0 0/0
Frontend differential — ✅ 1,020/1,020 cases matched; 0 issues
Match DOM mismatch Diagnostic mismatch Moli error Reference error Infrastructure error Mismatched frames Duration
1,020 0 0 0 0 0 0 6m 23.07s
Agent episodes · Moli vs Chromium — ✅ 8/8 Moli episodes passed; 0 failures
Fast contract Episodes Passed Assertions Ready p50 Episode p50
Moli 8 8 47/47 28.23 ms 24.83 ms
Chromium 8 8 47/47 250.91 ms 83.00 ms
Operation p50 Chromium Moli Delta Delta %
navigate 40.40 ms 5.91 ms −34.49 ms −85.37%
observe 0.71 ms 0.97 ms +0.27 ms +37.83%
fill 2.78 ms 3.34 ms +0.56 ms +20.09%
click 4.47 ms 3.95 ms −0.52 ms −11.55%
Idle-resource episode Peak RSS Peak PSS Average CPU Peak CPU Peak processes Sampler
Moli 66.45 MiB 63.10 MiB 0.76% 10.00% 1 ✅
Chromium 1276.61 MiB 405.38 MiB 0.59% 6.01% 13 ⚠️ PSS partial
Runtime and CDP session contracts — ✅ 26 contract cases; 0 failures
Suite Cases Failures Median case p50 Median case p95 Median peak PSS p50
Synthetic fetch 13 0 17.79 ms 18.55 ms 703.00 KiB
Long-lived CDP session 13 0 18.19 ms 18.70 ms —
CDP smoke — ✅ 53/53 groups passed; 628 scenarios

Workers: 4 · cumulative group time: 181.96 s · failed groups: 0

Slowest group Scenarios Duration Status
scrollbar-visibility 22 21.54 s ✅
target-lifecycle 24 15.97 s ✅
dom-input 27 12.27 s ✅
chromium-cdp 56 10.54 s ✅
multi-page 45 10.40 s ✅
WebMainBench · 545 pages — ✅ 545/545 completed; 0 unexpected failures
Completed Successful Expected DNS failure Unexpected failures Panics Crashes Timeouts Empty output
545/545 544 1 0 0 0 0 0

Frozen HTML · Linux · --wait done · 45 seconds per page · no retries. Content quality is evaluated separately.

Diagnostics: webmainbench-results — every page's Markdown, stderr, and exit status. Source run and artifacts

All artifact fields are parsed by the trusted default-branch renderer; missing or invalid inputs remain visible as unavailable.

@lanyue-llk

Copy link
Copy Markdown
Contributor Author

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 content heuristics into #1501, so it is intentionally not merged.

@lanyue-llk

Copy link
Copy Markdown
Contributor Author

Reopened after correcting the consolidation scope: this is an independent pre-existing stack and should not have been closed as part of #1501 cleanup. Its original scope and base relationship are preserved; this does not add it to #1501.

@lanyue-llk lanyue-llk left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR makes moli-html2md keep more of what a page shows: alt text for images that have no usable source, srcset/lazy-load image candidates, links for <iframe>/<video>/<audio> sources, form-control text (with password, hidden and file inputs left out), <select>/<option> boundaries, and an aria-label/title fallback for empty elements. It also filters link/image URLs by scheme. The image work is careful. srcset follows the WHATWG grammar, standard sources come before lazy attributes, and alt text survives a missing source. That part is principled.

Assessment: request changes. Several heuristics are broader than their tests. The generic label fallback can drop this PR's own media output. <time> and <button> are forced onto new lines, which turns into <br> inside GFM table cells. Form "current state" comes from default content attributes. The live-value hook has no implementation in this PR.

Overlap with main / other PRs

  • origin/main has no html2md changes since this PR's merge base f702d9a6, so nothing on main is equivalent or textually conflicting. GitHub reports MERGEABLE. The one file main changed, moli/tests/fetch_cli/http_fail.rs (subprocess helper moved to super::subprocess), merges cleanly.
  • #1591 (open, fix(html2md): preserve visible labels and literal preformatted text) duplicates and conflicts with this PR, in the same machine.rs match arms:
    • It adds its own "video" | "audio" and "source" | "track" resource links. Its labels differ ("Video poster" vs an empty alt here), and it handles <source> as a standalone element, not as a media child.
    • It adds resource_url(), which is nearly the same as media::safe_url() here (same scheme allowlist, same control-char stripping, same relative-URL test).
    • It adds an empty-anchor aria-label fallback in Writer::end_link, where this PR uses the generic content::fallback_text path.
    • Whichever lands second must be reconciled by hand. Pick one owner for media links, URL policy and accessible-name fallback before either merges, or the crate ends up with two parallel implementations.
  • #1501 is closed. Its html2md commits that reached main (06d6a57d7 hidden serialized state, dd7cd1c1e code boundaries) are older than this branch's base, so they do not overlap. But content::has_readable_content does not use visibility::nonrendered_serialized_state. That gives a second, inconsistent definition of what renders (see the inline comment).

Findings without a diff anchor

  • [major] Stack hygiene and PR description: Dom::control_value and form::textarea_text are dead in this PR. No adapter implements the hook (NativeDom in moli-dom/src/native/markdown.rs does not override it), and no test in this PR overrides it. The textarea branches in content.rs and machine.rs can never take their Some path. The first test override appears in #1336 and the renderer implementation in #1337 (page_dump/visibility.rs). The description's claim that the browser adapter supplies live values through control_value describes #1337, not this PR. Move the hook into #1336/#1337 or document the dependency.
  • [minor] Duplicate srcset parsers: moli-renderer-v8/src/native_bridge/element/images/src.rs already has parse_srcset_candidates/parse_srcset_descriptors for real image selection. This PR adds a second, independently written WHATWG srcset parser. It also exports it as #[doc(hidden)] pub only so one integration test can call it. Two parsers of one grammar will drift. Keep one implementation in the lower-level crate, and test through convert instead of widening the public API.
  • [minor] Scope creep: the http_fail.rs change (a FIXTURE_DATE const and an unconditional 1.1 s sleep, while Date was already pinned at base) has nothing to do with html2md. It belongs in its own PR. The sleep adds wall time to every nextest run and does not fail without a fix.
  • [nit] README: link-scheme filtering, the forced line breaks for buttons/dates, and dropping <title> outside SVG are behavior changes the README does not document.
  • CI: the only failing check, "Frontend differential", is 3 Chromium reference CDP timeouts (reference_error) and not a Moli mismatch. The sequential-navigation soak shows HEAD 150/200 direct passes vs base 199/200, with wall time 1167 s vs 469 s. An html2md-only change cannot plausibly cause that; it looks like public-site noise. Re-run it before relying on this run's numbers.
  • Missing tests: no test covers a labelled element whose only content is media or a select, a <time> or <button> inside a table cell or running text, or a non-allowlisted but legitimate link scheme.

Verdict: changes requested (posted as a comment because GitHub does not allow requesting changes on your own PR).

Automated review by Claude Code.

Comment thread moli-html2md/src/machine.rs Resolved
Comment thread moli-html2md/src/content.rs Resolved
Comment thread moli-html2md/src/machine.rs Resolved
Comment thread moli-html2md/src/form.rs Resolved
Comment thread moli-html2md/src/form.rs Resolved
Comment thread moli-html2md/src/machine.rs Resolved
Comment thread moli-html2md/src/media.rs Resolved
Comment thread moli-html2md/src/media.rs Resolved
Comment thread moli-html2md/src/machine.rs Resolved
Comment thread moli/tests/fetch_cli/http_fail.rs Resolved

@lanyue-llk lanyue-llk left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review of the updated version (e9dccde1e)

The PR makes moli-html2md keep more of what a page shows: alt text for images without a usable source, srcset/lazy candidates, links for <iframe>/<video>/<audio>, form-control text, <select>/<option> boundaries, and an aria-label/title fallback for empty name-bearing elements. The new head is rebased onto current origin/main (bd8e0b27). It adds one real commit, e9dccde1e, that addresses most of the last round.

Verdict: request changes (narrow). The big problems are fixed. The fallback now runs after the children have produced output (a per-writer content counter), so it no longer swallows media, choices or rules. The fallback is limited to name-bearing elements. The button/time block boundaries are gone. Link filtering is now a denylist. Placeholder text is no longer used as a value. The remaining issues are smaller: media still forces paragraph breaks in inline contexts, accessible names still look like typed values, there is some dead or duplicated code, and the stack needs cleanup.

Previous findings

# Finding Status Evidence
1 [major] label fallback swallows media/choices/rules; ignores serialized state FIXED The pre-scan has_readable_content is removed. Task::Fallback(label, mark) (machine.rs:78, 355) writes the label only when the writer's content_mark did not change. The test labels_cannot_replace_media_choices_or_rules would fail under the old pre-scan.
2 [minor] fallback applied to every element; no word boundary FIXED (residual nit) content.rs limits it to name-bearing tags and roles and skips aria-hidden/hidden/presentation. The label is padded with spaces (x Save y test). Residual: img/input are in the list but never reach the fallback (new inline).
3 [major] button/time forced block boundaries FIXED The arm is now "select" | "optgroup" | "option" only. phrasing_controls_and_dates_keep_inline_styles_and_table_cells covers strong, link and table cells.
4 [major] checked/value are default state, not current FIXED (documented; live state in #1337) The README now says plain DOM attributes are defaults. #1337's page_dump/visibility.rs overrides checked and value through attribute(). The test was renamed source_form_values_….
5 [minor] placeholder emitted as a value PARTIAL Placeholder is dropped. aria-label/title still render as bare text that looks like a typed value (thread reply).
6 [minor] link scheme allowlist drops legitimate schemes FIXED safe_link_url is a denylist (javascript:, vbscript:, data:text/html, data:application/xhtml+xml), tested with magnet/sms/geo/file/blob/data-pdf/custom schemes. #1591, which had the competing allowlist, is closed.
7 [nit] lazy attribute list inline; dead .or(src) FIXED LAZY_SOURCE_ATTRIBUTES const, .or(src) removed.
8 [nit] constant-false tag == "img"; needless Cow::Owned FIXED direct_source(dom, node, false), Cow::Borrowed(candidate.url).
9 [nit] poster written with empty alt FIXED poster_label → "Video poster" / "<title> poster".
10 [minor] unrelated http_fail.rs sleep FIXED (net) No net diff vs main. Commit 2 still adds it and commit 7 removes it (see hygiene).
S1 [major] control_value dead in this PR NOT FIXED (downgraded to minor) Still no implementation or test override in #1334 to #1336. The first override is in #1337 (visibility.rs:404, regressions.rs:1317). The hook was widened to <input>, and the doc comment still says textarea only (new inline).
S2 [minor] duplicate srcset parser + #[doc(hidden)] pub export NOT FIXED No reply. media::parse_srcset is still re-exported (lib.rs:24) beside moli-renderer-v8/.../images/src.rs:783.
S3 [minor] scope creep (http_fail.rs) FIXED (net) See #10.
S4 [nit] README undocumented behavior changes PARTIAL The link policy and form defaults are now documented. Dropping <title> outside SVG (and emitting it inside) is still undocumented.
S5 Missing tests FIXED Tests now cover media, select and hr in labelled elements, time/button in tables and inline styles, and non-web schemes.
S6 Overlap with #1591 RESOLVED #1591 was closed on 2026-10-22 as superseded by this stack. Nothing else on main touches html2md since f702d9a6. git merge-tree against origin/main is clean.

New findings (inline unless noted)

  • [minor] media() forces paragraph boundaries around inline iframe/video (machine.rs:367). This splits an enclosing link and adds <br><br> in table cells.
  • [minor] The video poster is dropped whenever no source passes safe_url, for example with blob:/MSE players (machine.rs:368).
  • [minor] SVG <title> is emitted as inline text glued to neighbors ([TwitterFollow](/t)). This contradicts the PR's own rule that tooltips are not article text (machine.rs:224).
  • [minor] img/input are listed as name-bearing but return before the fallback, so <img aria-label> is lost. The SVG <title> loop in fallback_text is effectively dead (content.rs:25, 71).
  • [minor] control_value is still dead in this PR, and its doc no longer matches its use (dom.rs:29).
  • [minor] Duplicate srcset parser and test-only public export (lib.rs:24).
  • [nit] Role-token parsing is duplicated in content.rs (lines 8 to 17 and 40 to 45).
  • [nit] The test name empty_accessible_element_retains_its_declared_text now asserts the opposite (regressions.rs:579).

Findings without a diff anchor

  • [minor] Stack and commit hygiene. Commit 8432da1f5 adds placeholder-as-value and the button/time boundaries, and e9dccde1e removes them. Commit 2757784a9 ("freeze response metadata") adds the http_fail.rs change that e9dccde1e reverts, so its subject no longer describes anything in the net diff. The two empty commits 8663d9a89/48001fb55 ("ci: …") are still present. Squash the fixups, drop the empty CI commits and the reverted http_fail.rs hunk, so every commit states a net change.
  • [minor] The PR description is stale. It says "HTTP Date 测试保留:跨秒比较仍验证完整输出", but the PR no longer touches that test. It lists removing quote, icon-class and Bootstrap-tooltip heuristics, which were introduced and removed inside this PR and are not changes vs main. It says the browser adapter supplies control_value, which only #1337 does. It omits the anchor-scheme denylist, the SVG <title> handling and the select/option line boundaries. Rewrite it against the net diff.
  • CI: the new head e9dccde1 passes Format, Clippy, Nextest, both release builds, CDP smoke, WebDriver smoke, PDF, WebMainBench and the harness tests. Frontend differential, Agent episodes, Runtime/CDP contracts, Spider and the sequential-navigation soak are still pending. The bot comments on the PR are for the previous head 2b228c34. Its soak (HEAD 150/200 direct passes vs base 199/200) should be checked on the new run before merge.

Verdict: changes requested (posted as a comment because GitHub does not allow requesting changes on your own PR).

Automated review by Claude Code.

Comment thread moli-html2md/src/machine.rs Resolved
Comment thread moli-html2md/src/machine.rs Resolved
Comment thread moli-html2md/src/machine.rs Resolved
Comment thread moli-html2md/src/content.rs Resolved
Comment thread moli-html2md/src/content.rs Resolved
Comment thread moli-html2md/src/dom.rs Resolved
Comment thread moli-html2md/src/lib.rs Resolved
Comment thread moli-html2md/tests/regressions.rs Resolved

@lanyue-llk lanyue-llk left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Round-3 re-review of the updated version (54c1d1cb7)

Re-review of the third version (54c1d1cb7, a fast-forward of the round-2 head on bd8e0b27). The PR makes moli-html2md keep more of what a page shows: image text alternatives, srcset/lazy candidates, iframe/video/audio links and posters, form-control text, <select>/<option> boundaries, and an accessible-name fallback for empty name-bearing elements. The new commit addresses every round-2 inline finding, and the renderer now uses the shared srcset parser.

Verdict: request changes (small). Each remaining item is minor, and each has a small fix. Two are regressions this commit introduces: a poster-only <video> now drops its fallback content, and the shared srcset parser trims Unicode whitespace that the deleted renderer parser rejected. One is an alt="" handling bug that came from our own round-2 suggestion. One is the round-1 form-label ambiguity, which a test now locks in. Commit and description hygiene is still unaddressed after three rounds. This is the complete list: I re-read the whole diff and found nothing else.

Previous findings

# Finding Status Evidence
R2-1 [minor] media() forced paragraph breaks around inline iframe/video FIXED machine.rs:362-397 uses boundary(2) only when is_block(tag) (audio) and spaces otherwise. inline_media_keeps_links_emphasis_and_table_flow covers link, paragraph, emphasis and table cell (no <br>). The test fails under the old code.
R2-2 [minor] poster dropped when no source passes safe_url FIXED (new regression) The poster is computed before the empty check (machine.rs:355-361), and source-less and blob: cases are tested. Returning true now also skips the video's fallback children (new inline).
R2-3 [minor] SVG <title> emitted as glued body text FIXED "title" => return for every title (machine.rs:220). The svg <title> loop in content.rs:44-60 now supplies the name only for an SVG with no other output. Documented in README:133-134. Both cases are tested.
R2-4 [minor] img/input listed as name-bearing but unreachable FIXED (residual) Removed from the list. content::image_label gives alt → aria-label → title, used for the src and no-src paths (machine.rs:263-273), and is tested. Residual: alt="" is treated as missing (new inline).
R2-5 [nit] duplicated first-role-token parse FIXED primary_role + role_matches + PRESENTATIONAL_ROLES/NAMED_WIDGET_ROLES. The first-token choice is documented in a comment, as we asked.
R2-6 [minor] control_value dead in this PR; stale doc FIXED live_controls_replace_defaults_including_explicit_clears overrides the hook for input and textarea (non-empty and cleared). The doc (dom.rs:29-31) now covers both controls. The production producer is still only in #1337, which we accept.
R2-7 [minor] duplicate srcset parser + #[doc(hidden)] pub export FIXED (residual) The renderer tokenizer/validators are deleted, and parse_srcset_candidates maps moli_html2md::parse_srcset. Residual: the shared parser is less strict than the one it replaced, and the export is still doc(hidden) with a string descriptor that the renderer re-tokenizes (new inline).
R2-8 [nit] misnamed test FIXED Renamed to generic_container_labels_are_not_article_text_but_link_labels_are.
R1-5 [minor] hint/label text emitted as if it were a value NOT FIXED Placeholder is gone, but aria-label/title still render as bare text (form.rs:34-41). The new test asserts a live-cleared input outputs Field (new inline). There was no reply to the round-2 thread.
R1-4 follow-up [nit] <select> lists options without marking selected NOT ADDRESSED (non-blocking) No change or README note. Mark the selected option (e.g. ☑, the same glyph checkboxes use) or document the limitation.
Stack #4 hooks without producers; README contract PARTIAL control_value is now exercised (R2-6). README.md:19 still says "four borrowed queries", but this PR adds the optional control_value query; the README mentions it only in prose at line 127. List it in the DOM-interface section.
Stack #10 role/URL/label rules diverge PARTIAL Role parsing in content.rs is unified. The resource allowlist (media::safe_url: http/https/mailto/tel/ftp + data:image/) is still undocumented in the README, which documents only the link denylist. Label resolution now has four rules, not three (new inline on image_label).
Stack #11 / hygiene empty ci: commits, add-then-revert churn NOT FIXED 8663d9a89 and 48001fb55 are still empty. 2757784a9 still adds the http_fail.rs sleep that e9dccde1e reverts. 8432da1f5 still adds the placeholder-as-value and button/time boundaries that e9dccde1e removes. New: 54c1d1cb7 ("fix(html2md): …") also rewrites renderer image selection in moli-renderer-v8/.../images/src.rs (-220 lines); that belongs in its own refactor(renderer) commit.
Description stale PR body PARTIAL It now mentions the shared srcset parser, the poster and inline media. It still says "HTTP Date 测试保留:跨秒比较仍验证完整输出" (the PR does not touch that test). It still lists deleting quote/icon-class/Bootstrap-tooltip semantics, which never existed on main. It still says the browser adapter supplies control_value (only #1337 does). It still omits the link-scheme denylist and the SVG <title> rule.

New findings (inline)

  • [minor] A poster-only <video> now returns early and drops its fallback children, including the fallback download link (machine.rs:359).
  • [minor] The shared srcset parser trims Unicode whitespace from descriptors, so browser image selection accepts candidates that WHATWG and the deleted parser reject (media.rs:112). The renderer also re-tokenizes a string descriptor (src.rs:784).
  • [minor] image_label treats alt="" as missing and promotes title, so decorative images gain alt text and tooltip text (content.rs:83). Our round-2 suggestion caused this. Image, media, fallback and input labels now follow four different rules.
  • [minor] A cleared or empty text input still renders its accessible name as if it were a value, and the new test asserts that (form.rs:34).

Not anchorable

  • Hygiene and description: see the table. Squash 8432da1f5+e9dccde1e+54c1d1cb7 into net-change commits. Drop 8663d9a89, 48001fb55 and the http_fail.rs hunk of 2757784a9. Split the renderer srcset change into its own commit, then rewrite the description against the net diff.
  • CI at 54c1d1cb: Resolve revisions, Format, Clippy, Windows storage, Python/Node harness and CDP smoke pass. Nextest and both release builds are still queued. The A/B bot comments (soak, spider, regression report) are still for 2b228c34. The earlier soak gap (HEAD 150/200 vs base 199/200 direct passes) needs a fresh run on this head before merge. Because this commit changes renderer currentSrc selection, Nextest (the renderer srcset suite) must pass.
  • Merge: origin/main has moved 7 commits past bd8e0b27, none touching moli-html2md, images/src.rs or page_dump.rs. git merge-tree --write-tree origin/main 54c1d1cb7 is clean (tree 701cd792).

Verdict: changes requested (posted as a comment because GitHub does not allow requesting changes on your own PR).

Automated review by Claude Code.

Comment thread moli-html2md/src/machine.rs Resolved
Comment thread moli-html2md/src/media.rs Resolved
Comment thread moli-html2md/src/content.rs Resolved
Comment thread moli-html2md/src/form.rs Resolved
@lanyue-llk

Copy link
Copy Markdown
Contributor Author

The round-3 stack review is on #1337: #1337 (comment). Finding N1 is in this PR: commit 54c1d1c rewrites the renderer's srcset selection (img.currentSrc) to use the html2md parser, and it no longer follows the HTML spec for parentheses.

@lanyue-llk lanyue-llk left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Round-4 re-review of the updated version (fb466fc6e)

Round-4 re-review of fb466fc6e (a fast-forward of round-3 head 54c1d1cb7 on bd8e0b27; it adds 2ff73d38e and fb466fc6e). The PR makes moli-html2md keep image text alternatives, srcset/lazy candidates, media links and posters, form-control text and <select> boundaries. It also makes the renderer's currentSrc selection use the html2md srcset parser.

Verdict: request changes. All five round-3 inline findings are addressed, and each comes with a regression test that would fail without the fix. One blocking item remains: stack finding N1. parse_srcset still counts nested parentheses, but the HTML spec does not nest them, and this parser now drives img.currentSrc. The image_label fix also has a new minor regression: hidden, aria-hidden and presentational exclusions now discard authored alt as well as the synthesized fallback names. Everything else is nit-level.

Previous findings

# Finding Status Evidence
R3-1 [minor] poster-only <video> dropped its fallback children FIXED media() returns has_source (machine.rs:374,400), so the children are visited when no source is usable. media_fallback_and_decorative_images_keep_author_intent covers src='' and blob: and asserts both the poster and [Download](/clip.mp4). It fails on 54c1d1cb7. fb466fc6e also rejects whitespace-only posters (see the nit at machine.rs:358).
R3-2 [minor] srcset descriptors trimmed with Unicode trim() FIXED trim_ascii() (media.rs:118). Negative cases for U+3000 and NBSP are in both srcset_recovers_only_the_future_compatible_width_height_pair and the renderer's srcset_parser_rejects_unicode_descriptor_spaces (images/src.rs:1079). Both fail with trim().
R3-3 [nit] renderer re-parses a string descriptor; doc(hidden) export FIXED SrcsetCandidate now has typed width/height/density, the score is computed inside largest_srcset_candidate, and the renderer copies fields with a checked u32 conversion. doc(hidden) is gone and both items have rustdoc. descriptor: &str is kept because #1337 (visibility.rs:340-343) reserializes it. Accepted.
R3-4 [minor] alt="" treated as missing PARTIAL alt="" now stays decorative (content.rs:91-104) and is tested with and without a source. New regression: the exclusion block runs before alt, so an authored non-empty alt is discarded for hidden/aria-hidden/role=presentation images (new inline). The reply says "Media labels now also read aria-label", but in this PR media::label still reads only title. That change is in #1336.
R3-5 / R1-5 [minor] empty text input emitted aria-label/title as a value FIXED Name fallback only for submit/button/reset (form.rs:26-47). live_controls_replace_defaults_including_explicit_clears now expects "" for a cleared input. The new test asserts that <input type=search aria-label=Search> gives "" and type=submit gives Search. README:122 still states the old rule (nit).
Stack N1 renderer currentSrc depends on html2md's parser, which handles parentheses differently NOT FIXED media.rs:108-113 still counts parenthesis depth. No reply. See the inline for the counterexample. The renderer change is again inside an html2md-titled commit (2ff73d38e).
R1-4 follow-up [nit] <select> does not mark the selected option NOT ADDRESSED (non-blocking) No change and no README note.
Stack #4 README DOM contract NOT FIXED README.md:19 still says "four borrowed queries". control_value and the now-public parse_srcset/SrcsetCandidate are not in the README API section.
Stack #10 role/URL/label rules diverge PARTIAL image_label and fallback_text now repeat the hidden/presentational predicate, and the two copies differ: aria-hidden is trimmed in content.rs:7 but not in :86. The resource allowlist (safe_url) is still undocumented in the README.
Stack #11 / hygiene empty ci: commits, add-then-revert churn NOT FIXED 8663d9a89 and 48001fb55 are still empty. The 2757784a9/e9dccde1e http_fail.rs pair still nets to zero. 54c1d1cb7 and now 2ff73d38e change moli-renderer-v8/.../images/src.rs under fix(html2md) titles.
Description stale PR body PARTIAL The new bullets match the code. It still says "HTTP Date 测试保留:跨秒比较仍验证完整输出" (the net diff does not touch that test). It still lists deleting quote/icon-class/Bootstrap-tooltip semantics, which never existed on main. It still says the browser adapter supplies control_value (only #1337 does). It does not say that the renderer's currentSrc parsing changed.

New findings (inline)

  • [minor] parse_srcset nests parentheses, while HTML's "in parens" state ends at the first ). srcset="a.png ((x), b.png 2x" now selects the fallback src instead of b.png (media.rs:111; stack N1, still open).
  • [minor] image_label discards authored alt on hidden/aria-hidden/presentational images while it still emits the image, so ![Revenue chart](/c.png) becomes ![](/c.png) (content.rs:83). The Some("") branch also returns an untrimmed aria-label.
  • [nit] The poster check trims, but the output uses the untrimmed value, so poster=" /cover.jpg " gives ![Video poster](%20/cover.jpg%20) (machine.rs:358).
  • [nit] README:122 ("Empty accessible controls retain their labels") contradicts the new rule at :127. Line 127 is also not rewrapped.
  • [nit] In source_form_values_preserve_readable_state_without_secrets, the "Search" assertion is vacuous: it matches inside "Search term", so it does not prove the submit value is emitted (regressions.rs:656).

Not anchorable

  • Hygiene: squash 8432da1f5+e9dccde1e+54c1d1cb7+2ff73d38e+fb466fc6e into net-change commits. Drop the empty 8663d9a89/48001fb55 and the http_fail.rs hunk of 2757784a9. Move the images/src.rs change (and the parser fix below) into one refactor(renderer) commit, then rewrite the description against the net diff.
  • CI at fb466fc6e: Resolve revisions, Format, Clippy, Windows storage, Python/Node harness and CDP smoke pass. Nextest is in progress and both release builds are queued. The renderer srcset suite (Nextest) must pass because currentSrc parsing changed. The A/B bot comments (soak/spider/regression) are still for 2b228c34, and the soak gap needs a fresh run on this head.
  • Merge: origin/main (45be4e35) is 16 commits past bd8e0b27, and none of them touch moli-html2md, images/ or page_dump.rs. git merge-tree --write-tree origin/main refs/review/v4-1334 is clean (tree ea54b556).

This list is complete. I re-read the whole net diff, and nothing else is outstanding.

Verdict: changes requested (posted as a comment because GitHub does not allow requesting changes on your own PR).

Automated review by Claude Code.

Comment thread moli-html2md/src/media.rs Resolved
Comment thread moli-html2md/src/content.rs Resolved
Comment thread moli-html2md/src/machine.rs Resolved
Comment thread moli-html2md/README.md Resolved
Comment thread moli-html2md/tests/regressions.rs Resolved

@lanyue-llk lanyue-llk left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Round-5 re-review of the updated version (97ff3aeae)

Round-5 re-review of 97ff3aeae. This is a fast-forward of round-4 head fb466fc6e on bd8e0b27, and 97ff3aeae is the only new commit. The PR makes moli-html2md keep image text alternatives, srcset/lazy candidates, media links and posters, form-control text and <select> boundaries. It also makes the renderer's currentSrc use the shared srcset parser.

Verdict: approve. Stack N1 and all five round-4 inline findings are fixed. Each fix has a regression test that fails on fb466fc6e. Only nits and hygiene items remain, and none of them blocks the merge.

Previous findings

# Finding Status Evidence
R4-1 / Stack N1 [minor] parse_srcset nested parentheses FIXED media.rs:108-113 now uses a bool: ( sets it, ) clears it, and , breaks only outside parens. This matches the spec's single "in parens" state, where ( inside parens is just appended. Splitting descriptors on whitespace inside parens still rejects the same candidates as the spec, because the token that holds the ( can never parse as Nw/Nh/Nx. Tests: renderer srcset_parentheses_do_not_nest (images/src.rs:1079, via moli_html2md::parse_srcset) and html2md "a.png ((x), b.png 2x" gives ![](b.png). With the depth counter both fail: 0 candidates, and the output falls back to /fallback.png.
R4-2 [minor] image_label dropped authored alt on hidden/aria-hidden/presentational images FIXED Non-empty alt now returns before excluded_from_naming (content.rs:90-95). The exclusion still suppresses synthesized aria-label/title. One shared predicate, with trimmed aria-hidden, now serves fallback_text and image_label. The alt="" branch trims aria-label. authored_image_alternatives_survive_naming_exclusions covers all three exclusions with alt and with aria-label only, plus alt='' aria-label=' '.
R4-3 [nit] poster trimmed only for the check FIXED media::direct_attribute(..., "poster", true) (machine.rs:355-357) trims and also rejects #…/about:blank. Tested: ' /cover.jpg ' gives /cover.jpg, and #cover/about:blank fall back to the children.
R4-4 [nit] README:122 contradicted :127 FIXED The general sentence is gone and the separate empty-text/button rules remain. The wrap at :127-128 is still a little ragged (cosmetic).
R4-5 [nit] vacuous "Search" assertion FIXED The submit value is now the distinct Go (regressions.rs:649,656).
R1-4 follow-up [nit] <select> does not mark the selected option NOT ADDRESSED (non-blocking) No change.
Stack #4 README DOM contract NOT FIXED (nit) README.md:19 still says "four borrowed queries". The optional control_value and public parse_srcset/SrcsetCandidate are not in the API section.
Stack #10 role/URL/label rules diverge FIXED for naming; safe_url allowlist still undocumented (nit) excluded_from_naming now has one copy.
Stack #11 / hygiene empty ci: commits, add-then-revert churn, mistitled commits NOT FIXED (nit) 8663d9a89/48001fb55 are still empty, and the 2757784a9/e9dccde1e http_fail.rs pair still nets to zero. The renderer behaviour change is still in 2ff73d38e (fix(html2md)), while 97ff3aeae (fix(renderer)) is mostly html2md changes. Squash before merge.
Description stale PR body PARTIAL (nit) It now states the shared parser and the non-nesting rule. It still claims "HTTP Date 测试保留:跨秒比较仍验证完整输出", which the net diff does not touch, and it still lists removing quote/icon-class/Bootstrap-tooltip semantics, which never existed on main.

New findings

  • [nit] excluded_from_naming is written as if cond { return true; } false. Return the expression directly, and make it private: it is only used in content.rs (content.rs:77).

Not anchorable

  • CI at 97ff3aeae: Resolve revisions, Format, Clippy, Windows storage, Python/Node harness and CDP smoke pass. Nextest and both release builds are still queued. Nextest must be green before merge because the renderer srcset tests changed.
  • Merge: git merge-tree --write-tree origin/main refs/review/v5-1334 is clean (tree 01286728). v5-1335/1336/1337/1380 all sit on this head.

This list is complete. I re-read the full net diff, and nothing else is outstanding.

Verdict: approve (posted as a comment; self-approval is not allowed).

Automated review by Claude Code.

Comment thread moli-html2md/src/content.rs Resolved

@lanyue-llk lanyue-llk left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final re-review (P0/P1 only) (62251602f)

Verdict: approve. No P0/P1 issues. v6 (62251602f) fast-forwards v5 97ff3aeae on the same base bd8e0b27. It adds one commit, refactor(html2md): simplify private naming exclusion predicate.

Previous P0/P1 findings

Finding Status
None. Every earlier finding on this PR was minor or nit, and all of them were already fixed or non-blocking at v5. n/a

This round: content.rs:77-82 now returns the aria-hidden \|\| hidden \|\| presentational-role expression directly and makes the function private. Behaviour is unchanged. The only callers are in content.rs (lines 5 and 89), so making it private does not break the build, and Clippy passes. This resolves the round-5 nit.

New P0/P1 findings: No P0/P1 issues found.

Merge: git merge-tree --write-tree origin/main refs/review/v6-1334 is clean (tree 4168b277), and GitHub reports MERGEABLE.

CI at 62251602f: Resolve revisions, Format, Clippy, Windows storage, Python/Node harness and CDP smoke pass. Nextest and both release builds are still pending. Nextest must be green before merge.

Verdict: approve (posted as a comment; self-approval is not allowed).

Automated review by Claude Code.

@lanyue-llk
lanyue-llk force-pushed the codex/content-media-forms branch from 6225160 to 0ec6219 Compare October 22, 2026 11:48
@ldm0
ldm0 force-pushed the codex/content-media-forms branch from 0ec6219 to f5b8c70 Compare October 23, 2026 10:56
@ldm0
ldm0 merged commit 3a4078a into main Oct 24, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants