1
0
mirror of https://github.com/sharkdp/bat.git synced 2025-09-08 14:22:25 +01:00

Credit syntax definition and theme authors with new --acknowledgements option (#1971)

The text that is printed is generated when building assets, by analyzing LICENSE
and NOTICE files that comes with syntaxes and themes.

We take this opportunity to also add a NOTICE file as defined by Apache License 2.0.
This commit is contained in:
Martin Nordholts
2021-12-11 14:00:45 +01:00
committed by GitHub
parent 63ad53817d
commit a3ea798246
12 changed files with 325 additions and 7 deletions

View File

@@ -55,6 +55,9 @@ pub(crate) const COMPRESS_THEMES: bool = false;
/// performance due to lazy-loading
pub(crate) const COMPRESS_LAZY_THEMES: bool = true;
/// Compress for size of ~10 kB instead of ~120 kB
pub(crate) const COMPRESS_ACKNOWLEDGEMENTS: bool = true;
impl HighlightingAssets {
fn new(serialized_syntax_set: SerializedSyntaxSet, theme_set: LazyThemeSet) -> Self {
HighlightingAssets {
@@ -305,6 +308,13 @@ pub(crate) fn get_integrated_themeset() -> LazyThemeSet {
from_binary(include_bytes!("../assets/themes.bin"), COMPRESS_THEMES)
}
pub fn get_acknowledgements() -> String {
from_binary(
include_bytes!("../assets/acknowledgements.bin"),
COMPRESS_ACKNOWLEDGEMENTS,
)
}
pub(crate) fn from_binary<T: serde::de::DeserializeOwned>(v: &[u8], compressed: bool) -> T {
asset_from_contents(v, "n/a", compressed)
.expect("data integrated in binary is never faulty, but make sure `compressed` is in sync!")