on master help sign in
Expose syntect theme and syntax sets (#2030)

Fixes #2026 Ref https://github.com/dandavison/delta/issues/895

commit4e36a56014cd8615c6142999191d4a097f9b9310 authorDan Davison <dandavison7@gmail.com> dateTue 8 Feb 2022, 02:00 (5 years ago) parent312c8ef
2 files changed+5−2
CHANGELOG.md+1 src/assets.rs+4−2
CHANGELOG.md+1
@@ -18,6 +18,7 @@
1818
1919## `bat` as a library
2020
21+- Exposed `get_syntax_set` and `get_theme` methods on `HighlightingAssets`. See #2030 (@dandavison)
2122
2223# v0.19.0
2324
src/assets.rs+4−2
@@ -90,7 +90,8 @@ impl HighlightingAssets {
9090 self.fallback_theme = Some(theme);
9191 }
9292
93− fn get_syntax_set(&self) -> Result<&SyntaxSet> {
93+ /// Return the collection of syntect syntax definitions.
94+ pub fn get_syntax_set(&self) -> Result<&SyntaxSet> {
9495 self.syntax_set_cell
9596 .get_or_try_init(|| self.serialized_syntax_set.deserialize())
9697 }
@@ -186,7 +187,8 @@ impl HighlightingAssets {
186187 }
187188 }
188189
189− pub(crate) fn get_theme(&self, theme: &str) -> &Theme {
190+ /// Look up a syntect theme by name.
191+ pub fn get_theme(&self, theme: &str) -> &Theme {
190192 match self.get_theme_set().get(theme) {
191193 Some(theme) => theme,
192194 None => {