index : gitrs
A lightweight web interface for browsing Git repositories, implemented in Rust
about summary refs log tree commit diff

Diffstat (limited to 'src/main.rs')

-rw-r--r-- src/main.rs 20
 1 file changed, 20 insertions(+)

diff --git a/src/main.rs b/src/main.rs
index 9c53edf..775f8cc 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -129,4 +129,24 @@
            html.contains(r#"src="https://github.com/user-attachments/assets/1234?a=1&b=2""#)
        );
    }

    #[test]
    fn shell_highlight_preserves_urls_and_highlights_commands_and_flags() {
        let block = syntax_highlight::highlight_block(
            "git clone https://github.com/y2w8/gitrs.git\nsudo $(which gitrs) --port 80\nNMRS_LOG=trace nmrs-tui\nexport PATH=\"$HOME/.cargo/bin:$PATH\"\n",
            "sh",
        );
        assert!(block.contains(r#"<span class="hl-function">git</span>"#));
        assert!(!block.contains("hl-comment"));
        assert!(
            block.contains(&v_htmlescape::escape("https://github.com/y2w8/gitrs.git").to_string())
        );
        assert!(block.contains(r#"<span class="hl-function-builtin">sudo</span>"#));
        assert!(block.contains(r#"<span class="hl-function-builtin">which</span>"#));
        assert!(block.contains(r#"<span class="hl-property">--port</span>"#));
        assert!(block.contains(r#"<span class="hl-number">80</span>"#));
        assert!(block.contains(r#"<span class="hl-constant">NMRS_LOG</span>"#));
        assert!(block.contains(r#"<span class="hl-function">nmrs-tui</span>"#));
        assert!(block.contains(r#"<span class="hl-variable">$HOME</span>"#));
    }
}