|
|
@ -280,13 +280,14 @@ fn blend_fg_color(fg: SyntectColor, bg: SyntectColor) -> SyntectColor {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn detect_code_block(line: &str) -> Option<String> {
|
|
|
|
fn detect_code_block(line: &str) -> Option<String> {
|
|
|
|
|
|
|
|
let line = line.trim_start();
|
|
|
|
if !line.starts_with("```") {
|
|
|
|
if !line.starts_with("```") {
|
|
|
|
return None;
|
|
|
|
return None;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
let lang = line
|
|
|
|
let lang = line
|
|
|
|
.chars()
|
|
|
|
.chars()
|
|
|
|
.skip(3)
|
|
|
|
.skip(3)
|
|
|
|
.take_while(|v| v.is_alphanumeric())
|
|
|
|
.take_while(|v| !v.is_whitespace())
|
|
|
|
.collect();
|
|
|
|
.collect();
|
|
|
|
Some(lang)
|
|
|
|
Some(lang)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -380,4 +381,13 @@ std::error::Error>> {
|
|
|
|
let output = render.render(TEXT);
|
|
|
|
let output = render.render(TEXT);
|
|
|
|
assert_eq!(TEXT_WRAP_ALL, output);
|
|
|
|
assert_eq!(TEXT_WRAP_ALL, output);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
|
|
|
fn test_detect_code_block() {
|
|
|
|
|
|
|
|
assert_eq!(detect_code_block("```rust"), Some("rust".into()));
|
|
|
|
|
|
|
|
assert_eq!(detect_code_block("```c++"), Some("c++".into()));
|
|
|
|
|
|
|
|
assert_eq!(detect_code_block(" ```rust"), Some("rust".into()));
|
|
|
|
|
|
|
|
assert_eq!(detect_code_block("```"), Some("".into()));
|
|
|
|
|
|
|
|
assert_eq!(detect_code_block("``rust"), None);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|