feat(view): M8 遮蔽呈现 — 描述为正文、实现为代码片、桩有徽章;并修复 view 解析模式回归
一、先修回归(用户看到"没渲染"的真因)
view 多处直接用 crate::parse::parse_source 重新解析文件,而 per-file markup:
是在 load 层生效的(M7)。于是任何带 markup: occlusion 的文档在结构区报
"parse/load error: expected ')' after link-index collection",退化成源码视图。
→ 新增 load::parse_source_auto(source):先读 frontmatter 的 markup:,用
with_markup 包住解析;view 的 4 处解析点全部改用。
二、遮蔽呈现
浏览视图(document.rs / /file):
<div class="doc-line doc-occl">
<span class="occl-pre">留存 =</span> ← 变量名 灰 等宽
<span class="occl-label">客户留存率,模拟数据</span> ← 描述 正文
<code class="occl-code">0.42</code> ← 实现 代码片
</div>
空载荷换成 <span class="occl-stub">桩</span> 琥珀徽章(title 说明未接通/待补返回值);
前缀的反引号与 ** 都剥掉,与其它行的 mq-anchor 一致。
卡片视图(render.rs / /debug):按 AST 匹配 Expr::Occluded(Assign/Expr/Return),
渲染 card occl-card:徽章「遮蔽」+ 变量名 + 描述 + 代码片/桩。
样式刻意不加虚线下划线(易读成链接):描述即正文,靠代码片边框区分。
验证:
- /file 页面 0 处 parse/load error;7 个遮蔽行全部渲染
(6 代码片 + 1 桩),文本抽取为「留存 = 客户留存率,模拟数据 [0.42]」
- 4 个单测(裸赋值/粗体赋值/空载荷+嵌套/非遮蔽不误判)
- 全量 cargo test --release 613 passed / 0 failed
未能截图:本机无任何浏览器,puppeteer 的 Chromium 下载被网络阻断;
改为 DOM 断言 + /.preview/occlusion.html 方案对照页由作者目视确认。
文档:doc/design/change-m8-view-occlusion.md
This commit is contained in:
1 parent
8c24d96626
commit
9015de26e5
7 files changed
+387
-4
No files matched your search
@@ -292,6 +292,14 @@ fn label_error(label: &str, e: anyhow::Error) -> anyhow::Error {
|
||||
/// Looks for `markup: occlusion` (or `标记: 遮蔽`) inside the leading frontmatter
|
||||
/// block. Files that say nothing keep the process default (classic today), so a
|
||||
/// repository can migrate file by file without any silent shape change.
|
||||
/// Parse a standalone source the way the file itself declares (`markup:` in
|
||||
/// frontmatter). The viewer must use this — otherwise an occluded document is
|
||||
/// re-parsed in classic mode and fails. `<TAB>` M7/M8
|
||||
pub fn parse_source_auto(source: &str) -> anyhow::Result<Module> {
|
||||
let markup = frontmatter_markup(source);
|
||||
crate::parse::expr::with_markup(markup, || crate::parse::parse_source(source))
|
||||
}
|
||||
|
||||
fn frontmatter_markup(source: &str) -> crate::parse::expr::Markup {
|
||||
use crate::parse::expr::Markup;
|
||||
let mut lines = source.lines();
|
||||
|
||||
Reference in new issue
Block a user