Riapplica la fase 5 di aKode (86e7c72e) sulla base ripulita:
- crate codex-* -> akode-*, codex-rs -> akode-rs, codex-cli -> akode-cli, binario e ausiliari akode;
- ~/.codex -> ~/.akode, CODEX_HOME -> AKODE_HOME, variabili CODEX_* -> AKODE_*, .codex/ -> .akode/ di progetto;
nessun fallback a ~/.codex o a CODEX_*;
- testi per l'utente "Codex" -> "aKode"; testi verso il modello e istruzioni di sistema invariati;
- snapshot insta rinominati (non ancora rigenerati).
I conflitti con la base ripulita sono stati risolti riapplicando la rinomina ai file senza le
funzioni di imeAI (script di mappa dei token per file).
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
84 lines
2.8 KiB
Rust
84 lines
2.8 KiB
Rust
use super::render_markdown;
|
|
use pretty_assertions::assert_eq;
|
|
|
|
#[test]
|
|
fn markdown_clipboard_preserves_rich_formatting() {
|
|
let markdown = "# Findings\n\nRead [the source](https://example.com/source?q=1&v=2).\n\n\
|
|
- **Bold**, *italic*, ~~removed~~, and `inline <code>`\n\n\
|
|
> A quoted finding.\n\n\
|
|
```rust\nfn main() { println!(\"<hello>\"); }\n```\n\n\
|
|
| Item | Result |\n| --- | --- |\n| Copy | Formatted |\n";
|
|
insta::assert_snapshot!(render_markdown(markdown));
|
|
}
|
|
|
|
#[test]
|
|
fn markdown_clipboard_preserves_local_link_destinations() {
|
|
let markdown = r#"[parser](/repo/src/parser.rs:42)
|
|
|
|
[**Windows parser**](C:\repo\src\parser.rs:42:7)
|
|
|
|
[`relative parser`](../src/parser.rs#L42-L48)
|
|
|
|
[file URL](file:///repo/src/parser.rs#L42)
|
|
|
|
[escaped path](/repo/a&b/<parser>.rs:42)
|
|
|
|
[Unicode path](</repo/my project/解析.rs:42>)
|
|
|
|
[](/repo/diagram.rs:7)
|
|
|
|
[web link](https://example.com/source) and [another file](src/lib.rs:9)
|
|
"#;
|
|
insta::assert_snapshot!(render_markdown(markdown));
|
|
}
|
|
|
|
#[test]
|
|
fn markdown_clipboard_images_are_inert() {
|
|
assert_eq!(
|
|
render_markdown(
|
|
"\n\n\
|
|
[](https://example.com/page)"
|
|
),
|
|
"<p>tracking pixel</p>\n\
|
|
<p><a href=\"https://example.com/page\"><strong>Preview</strong> & details</a></p>\n"
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn markdown_clipboard_escapes_raw_html_and_rejects_unsafe_destinations() {
|
|
assert_eq!(
|
|
render_markdown("<script>alert(1)</script>\n\nHello <img src=x onerror=alert(1)>!"),
|
|
"<script>alert(1)</script>\n<p>Hello <img src=x onerror=alert(1)>!</p>\n"
|
|
);
|
|
for (destination, visible_destination) in [
|
|
("javascript:alert(1)", "javascript:alert(1)"),
|
|
("JaVaScRiPt:alert(1)", "JaVaScRiPt:alert(1)"),
|
|
("javascript:alert(1)", "javascript:alert(1)"),
|
|
("data:text/html,unsafe", "data:text/html,unsafe"),
|
|
(
|
|
"javascript:alert("<>&")",
|
|
"javascript:alert(\"<>&\")",
|
|
),
|
|
] {
|
|
assert_eq!(
|
|
render_markdown(&format!("[link]({destination}) ")),
|
|
format!("<p>link ({visible_destination}) image</p>\n")
|
|
);
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn markdown_clipboard_unwraps_table_fences_independent_of_tui_preferences() {
|
|
let table = "| Item | Result |\n| --- | --- |\n| Copy | Formatted |\n";
|
|
for tables in [true, false] {
|
|
crate::markdown_render::preferences::init(akode_config::types::TuiRendering {
|
|
tables,
|
|
..Default::default()
|
|
});
|
|
assert_eq!(
|
|
render_markdown(&format!("```markdown\n{table}```")),
|
|
render_markdown(table)
|
|
);
|
|
}
|
|
}
|