/
FerrisMind
/
StriMD
Обзор
Документация
Войти
/
FerrisMind
/
StriMD
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
examples/static_export.rs
43 строки
1 KB
FerrisMind
fix: reorder imports and enhance image handling in examples
01 июн 2026, 12:35
01 июн 2026, 12:35
f5ae30f
Код
Авторство
О чём код?
//! Headless static preview: parse TEST.md and export HTML (Task 7.1). //! //! ```bash //! cargo run --example static_export --no-default-features --features no_iced,static //! cargo run --example static_export --no-default-features --features no_iced,static -- examples/assets/MPF.md //! ``` use std::path::{Path, PathBuf}; use strimd::{Document, ParseBackend, ParseProfile}; fn main() { let input = std::env::args() .nth(1) .map(PathBuf::from) .unwrap_or_else(|| PathBuf::from("examples/assets/TEST.md")); let source = std::fs::read_to_string(&input) .unwrap_or_else(|err| panic!("read {}: {err}", input.display())); let doc = Document::parse(&source, ParseProfile::GitHubPreview) .unwrap_or_else(|err| panic!("parse {}: {err}", input.display())); eprintln!( "input: {}, blocks: {}, backend: {:?}", display_path(&input), doc.blocks().len(), doc.parse_backend() ); assert_eq!(doc.parse_backend(), ParseBackend::Pulldown); let html = doc.to_html().expect("export html"); assert!(!html.is_empty(), "expected non-empty HTML export"); assert!( html.contains("<h1") || html.contains("Heading"), "missing heading markup" ); // Downstream consumers typically write or snapshot this output. print!("{html}"); } fn display_path(path: &Path) -> String { path.to_string_lossy().into_owned() }