//! The Askama entry point for [`quasi_router::Node::Code`]. //! //! [`super::carousel`]'s shape and its reasoning: glue between a template's own //! type and the vocabulary's, so a page that is still Askama draws the same //! markup a described screen would. Called from `routes/git/browsing.rs` while //! `templates/pages/git/file.html` is still a template. //! //! # Why this exists rather than the page just being converted //! //! The file view is one of three git pages that need the heavy form, and all //! three sit behind `partials/git_nav.html` and `partials/git_notes_panel.html`, //! which eight other git templates share. Converting the page means converting //! the nav, which means converting the eight, which is the whole source-browser //! pass rather than this one. //! //! What could not wait is the seam: `SyntaxHighlighter` stopped emitting HTML on //! 2026-09-02 (quasi `19d7602d`), so something has to turn runs into markup, and //! it should be the renderer rather than a second emitter here. When the page is //! described this file goes and the screen carries `Node::Code` directly. use quasi_router::Node; use quasi_router::screen::Lexeme; /// One line of classified source, as markup for a template to drop in. /// /// Inline, because a line of a file sits in a table cell beside its number: /// the block form owns its own lines and the table is what holds these. #[must_use] pub fn line_html(runs: &[Lexeme], language: Option<&str>) -> String { use quasi_axum::Serves as _; // No shell: this lands inside a document Askama already built, which is // what `fragment` is for. quasi_webview::Webview::new().fragment(&Node::Code { runs: runs.to_vec(), language: language.map(str::to_owned), inline: true, }) } #[cfg(test)] mod tests { use super::*; use makeover_layout::Syntax; /// The classification reaches the markup, and a plain run stays bare text /// rather than becoming a span that says "ordinary". #[test] fn a_classified_line_arrives_whole() { let html = line_html( &[ Lexeme::new("fn", Syntax::Keyword), Lexeme::plain(" main() {}"), ], Some("rust"), ); assert!(html.contains("lex-keyword"), "{html}"); assert!(html.contains(" main() {}"), "{html}"); assert_eq!(html.matches("alert(1)")], None); assert!(!html.contains("