chore: baseline md-preview 1.4.2 + agent workspace

This commit is contained in:
2026-10-21 16:06:27 +08:00
commit f63aff47a8
30 changed files with 15085 additions and 0 deletions

86
agent/tests/fixtures/code-samples.md vendored Normal file
View File

@@ -0,0 +1,86 @@
# 代码配色样例
用于对比 highlight.js 主题:关键字、字符串、注释、类型、数字、内置函数、diff。
## C#
```csharp
using System;
public sealed class Profile
{
private readonly string _name;
public Profile(string name) => _name = name;
// 比较运算符必须保持字面量
public bool IsEmpty() => _name == null || _name.Length == 0;
public override string ToString() => $"Profile({_name})";
}
```
## Rust
```rust
#[derive(Debug, Clone)]
struct Config {
port: u16,
retries: usize,
}
fn main() {
let cfg = Config { port: 8080, retries: 3 };
println!("{cfg:?}"); // 调试输出
}
```
## JavaScript
```javascript
const items = [1, 2, 3].map((n) => n * 2);
function sum(a, b) {
return a + b; // 行注释
}
console.log(sum(1, 2), items);
```
## JSON
```json
{
"name": "md-preview",
"version": "1.4.2",
"offline": true,
"count": 39
}
```
## YAML
```yaml
version: 1
active: 0
tabs:
- D:\Scripts\md-preview\HANDOFF.md
- note.md
```
## PowerShell
```powershell
$env:CARGO_TARGET_DIR = Join-Path $env:TEMP 'mdp-scan-target'
Get-ChildItem -File | Where-Object { $_.Length -gt 1MB }
```
## Diff
```diff
- old line
+ new line
unchanged
```
## 行内代码
使用 `cargo test` 与 `build.ps1`;正文里的 ==高亮== 仍应生效,而 `==literal==` 不应高亮。

51
agent/tests/fixtures/long-headings.md vendored Normal file
View File

@@ -0,0 +1,51 @@
---
title: 折叠与长文测试
tags: [fixture, fold, headings]
---
# 一级标题 A
这是 A 的引导段落。用来验证一级标题折叠时,它下面的二级、三级内容是否一起收起。
## 二级 A-1
A-1 段落。包含 **粗体**、*斜体*、`inline code` 与 ==高亮==。
### 三级 A-1-1
- 列表项 1
- 列表项 2
- 嵌套项
#### 四级 A-1-1-1
> 引用块,用于检查折叠后的间距。
## 二级 A-2
| 列 1 | 列 2 | 列 3 | 列 4 |
|---|---|---|---|
| a | b | c | d |
### 三级 A-2-1
任务列表:
- [x] 已完成
- [ ] 未完成
# 一级标题 B
B 的正文。
## 二级 B-1
```rust
fn main() {
println!("hello");
}
```
## 二级 B-2
结尾段落。

16
agent/tests/fixtures/math-mermaid.md vendored Normal file
View File

@@ -0,0 +1,16 @@
# 数学与图表
行内公式 $E = mc^2$,块级公式:
$$
\int_0^1 x^2 \, dx = \frac{1}{3}
$$
```mermaid
flowchart LR
A[开始] --> B{判断}
B -->|是| C[执行]
B -->|否| D[结束]
```
前后各留一段文字,方便检查折叠与滚动。

64
agent/tests/smoke.ps1 Normal file
View File

@@ -0,0 +1,64 @@
#requires -Version 5.1
<#
MD Preview 冒烟测试
cargo test + 关联检查 + 可选隔离启动(不污染真实 %LOCALAPPDATA%)
#>
[CmdletBinding()]
param(
[string]$Exe = 'D:\Scripts\md-preview\MD-Preview-windows-x64.exe',
[switch]$Launch
)
$ErrorActionPreference = 'Stop'
$repoRoot = (Resolve-Path (Join-Path $PSScriptRoot '..\..')).Path
Set-Location $repoRoot
$cargo = Join-Path $env:USERPROFILE '.cargo\bin\cargo.exe'
if (-not (Test-Path $cargo)) { $cargo = (Get-Command cargo -ErrorAction Stop).Source }
if (-not (Test-Path $Exe)) { throw ('missing exe: ' + $Exe + ' (先运行 agent/scripts/build.ps1)') }
Write-Host '==> cargo test' -ForegroundColor Cyan
& $cargo test
if ($LASTEXITCODE -ne 0) { throw 'cargo test failed' }
Write-Host '==> --help' -ForegroundColor Cyan
$help = (& $Exe --help 2>&1 | Out-String)
if ($help -match 'MD Preview') {
Write-Host ' OK'
} else {
Write-Warning '--help 无输出(GUI 子系统在部分终端下不回显,可忽略)'
}
Write-Host '==> registry association' -ForegroundColor Cyan
$reg = Get-ItemProperty 'HKCU:\Software\Classes\MDPreview.md\shell\open\command' -ErrorAction SilentlyContinue
$expected = '"' + $Exe + '" "%1"'
if ($null -eq $reg) {
Write-Warning 'ProgID 未注册(先运行一次 exe)'
} elseif ($reg.'(default)' -ne $expected) {
Write-Warning ('ProgID 指向不一致: ' + $reg.'(default)')
} else {
Write-Host ' OK'
}
if ($Launch) {
Write-Host '==> launch with isolated config' -ForegroundColor Cyan
$config = Join-Path $env:TEMP ('mdp-smoke-' + [guid]::NewGuid().ToString('N'))
New-Item -ItemType Directory -Path $config | Out-Null
$fixture = Join-Path $PSScriptRoot 'fixtures\long-headings.md'
$env:MD_PREVIEW_CONFIG_DIR = $config
try {
$proc = Start-Process -FilePath $Exe -ArgumentList @($fixture) -PassThru
Start-Sleep -Seconds 3
if ($proc.HasExited) { throw ('process exited early: ' + $proc.ExitCode) }
Write-Host ' running - OK'
$proc.CloseMainWindow() | Out-Null
if (-not $proc.WaitForExit(5000)) { $proc.Kill() }
Write-Host ' exit - OK'
} finally {
Remove-Item Env:\MD_PREVIEW_CONFIG_DIR -ErrorAction SilentlyContinue
Remove-Item -Recurse -Force $config -ErrorAction SilentlyContinue
}
}
Write-Host 'SMOKE OK' -ForegroundColor Green