Download
This commit is contained in:
parent
dc13ef503c
commit
5bcc40d573
5 changed files with 105 additions and 12 deletions
|
|
@ -12,13 +12,23 @@ impl Renderer {
|
|||
hl_registry.link_grammars();
|
||||
Self { hl_registry }
|
||||
}
|
||||
pub fn render(&self, config: &Config, filetype: &str, content: &[u8], pretty: bool, repo_hash_str: &str, file_path: &str) -> String {
|
||||
pub fn render(
|
||||
&self,
|
||||
config: &Config,
|
||||
filetype: &str,
|
||||
content: &[u8],
|
||||
pretty: bool,
|
||||
repo_hash_str: &str,
|
||||
file_path: &str,
|
||||
) -> String {
|
||||
if config.image_extensions.contains_key(filetype) {
|
||||
return format!(r#"<img alt="No description" src="/inline/{repo_hash_str}/{file_path}"/>"#)
|
||||
return format!(
|
||||
r#"<img alt="No description" src="/inline/{repo_hash_str}/{file_path}"/>"#
|
||||
);
|
||||
} else if config.video_extensions.contains_key(filetype) {
|
||||
return format!(r#"<video src="/inline/{repo_hash_str}/{file_path}"></video>"#)
|
||||
return format!(r#"<video src="/inline/{repo_hash_str}/{file_path}"></video>"#);
|
||||
} else if config.audio_extensions.contains_key(filetype) {
|
||||
return format!(r#"<audio src="/inline/{repo_hash_str}/{file_path}"></audio>"#)
|
||||
return format!(r#"<audio src="/inline/{repo_hash_str}/{file_path}"></audio>"#);
|
||||
}
|
||||
let Ok(content) = str::from_utf8(content) else {
|
||||
return String::from("Cannot render file as it is not valid UTF-8.");
|
||||
|
|
|
|||
Loading…
Reference in a new issue