mirror of
https://github.com/sxyazi/yazi.git
synced 2024-12-18 22:31:35 +03:00
feat: fallback to built-in highlighting if jq
is not installed (#151)
This commit is contained in:
parent
4c98a351c9
commit
9c6b3c9d1d
@ -3,6 +3,7 @@ use std::{io::BufRead, path::Path, sync::atomic::{AtomicUsize, Ordering}};
|
|||||||
use adaptor::ADAPTOR;
|
use adaptor::ADAPTOR;
|
||||||
use anyhow::anyhow;
|
use anyhow::anyhow;
|
||||||
use config::{MANAGER, PREVIEW};
|
use config::{MANAGER, PREVIEW};
|
||||||
|
use futures::TryFutureExt;
|
||||||
use shared::{MimeKind, PeekError};
|
use shared::{MimeKind, PeekError};
|
||||||
use syntect::{easy::HighlightFile, util::as_24_bit_terminal_escaped};
|
use syntect::{easy::HighlightFile, util::as_24_bit_terminal_escaped};
|
||||||
use tokio::fs;
|
use tokio::fs;
|
||||||
@ -69,7 +70,9 @@ impl Provider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub(super) async fn json(path: &Path, skip: usize) -> Result<String, PeekError> {
|
pub(super) async fn json(path: &Path, skip: usize) -> Result<String, PeekError> {
|
||||||
external::jq(path, skip, MANAGER.layout.preview_height()).await
|
external::jq(path, skip, MANAGER.layout.preview_height())
|
||||||
|
.or_else(|_| Provider::highlight(path, skip))
|
||||||
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) async fn archive(path: &Path, skip: usize) -> Result<String, PeekError> {
|
pub(super) async fn archive(path: &Path, skip: usize) -> Result<String, PeekError> {
|
||||||
|
Loading…
Reference in New Issue
Block a user