mirror of
https://github.com/sharkdp/bat.git
synced 2025-02-07 05:31:09 +00:00
Expose syntect theme and syntax sets (#2030)
Fixes #2026 Ref https://github.com/dandavison/delta/issues/895
This commit is contained in:
parent
312c8ef01f
commit
4e36a56014
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
## `bat` as a library
|
## `bat` as a library
|
||||||
|
|
||||||
|
- Exposed `get_syntax_set` and `get_theme` methods on `HighlightingAssets`. See #2030 (@dandavison)
|
||||||
|
|
||||||
# v0.19.0
|
# v0.19.0
|
||||||
|
|
||||||
|
@ -90,7 +90,8 @@ impl HighlightingAssets {
|
|||||||
self.fallback_theme = Some(theme);
|
self.fallback_theme = Some(theme);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_syntax_set(&self) -> Result<&SyntaxSet> {
|
/// Return the collection of syntect syntax definitions.
|
||||||
|
pub fn get_syntax_set(&self) -> Result<&SyntaxSet> {
|
||||||
self.syntax_set_cell
|
self.syntax_set_cell
|
||||||
.get_or_try_init(|| self.serialized_syntax_set.deserialize())
|
.get_or_try_init(|| self.serialized_syntax_set.deserialize())
|
||||||
}
|
}
|
||||||
@ -186,7 +187,8 @@ impl HighlightingAssets {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn get_theme(&self, theme: &str) -> &Theme {
|
/// Look up a syntect theme by name.
|
||||||
|
pub fn get_theme(&self, theme: &str) -> &Theme {
|
||||||
match self.get_theme_set().get(theme) {
|
match self.get_theme_set().get(theme) {
|
||||||
Some(theme) => theme,
|
Some(theme) => theme,
|
||||||
None => {
|
None => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user