Switch to two-face for extra syntect syntaxes (#2937)

This commit is contained in:
CosmicHorror 2023-12-18 05:17:47 -07:00 committed by GitHub
parent 754e1788b2
commit 56159997b7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 17 additions and 24 deletions

12
Cargo.lock generated
View file

@ -2645,6 +2645,17 @@ version = "0.19.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49d64318d8311fc2668e48b63969f4343e0a85c4a109aa8460d6672e364b8bd1"
[[package]]
name = "two-face"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37bed2135b2459c7eefba72c906d374697eb15949c205f2f124e3636a46b5eeb"
dependencies = [
"once_cell",
"serde",
"syntect",
]
[[package]]
name = "typed-arena"
version = "2.0.2"
@ -2692,6 +2703,7 @@ dependencies = [
"toml",
"tracing",
"ttf-parser",
"two-face",
"typed-arena",
"typst-macros",
"typst-syntax",

View file

@ -104,6 +104,7 @@ tracing-error = "0.2"
tracing-flame = "0.2.0"
tracing-subscriber = "0.3.17"
ttf-parser = "0.19.2"
two-face = { version = "0.3.0", default-features = false, features = ["syntect-fancy"] }
typed-arena = "2"
unicode_names2 = "1.2"
unicode-bidi = "0.3.13"

2
NOTICE
View file

@ -215,7 +215,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
================================================================================
================================================================================
Syntaxes in `crates/typst-library/assets/syntect.bin` are generated from syntax
Syntaxes embedded within the `two-face` crate are generated from syntax
definitions which can be found here:
https://github.com/sharkdp/bat/tree/master/assets/syntaxes

View file

@ -54,6 +54,7 @@ time = { workspace = true }
toml = { workspace = true }
tracing = { workspace = true }
ttf-parser = { workspace = true }
two-face = { workspace = true }
typed-arena = { workspace = true }
unicode-bidi = { workspace = true }
unicode-math-class = { workspace = true }

Binary file not shown.

View file

@ -734,31 +734,10 @@ fn parse_theme(
/// The syntect syntax definitions.
///
/// Code for syntax set generation is below. The `syntaxes` directory is from
/// Syntax set is generated from the syntaxes from the `bat` project
/// <https://github.com/sharkdp/bat/tree/master/assets/syntaxes>
///
/// ```ignore
/// fn main() {
/// let mut builder = syntect::parsing::SyntaxSet::load_defaults_nonewlines().into_builder();
/// builder.add_from_folder("syntaxes/02_Extra", false).unwrap();
/// syntect::dumps::dump_to_file(&builder.build(), "syntect.bin").unwrap();
/// }
/// ```
///
/// The following syntaxes are disabled due to compatibility issues:
/// ```text
/// syntaxes/02_Extra/Assembly (ARM).sublime-syntax
/// syntaxes/02_Extra/Elixir/Regular Expressions (Elixir).sublime-syntax
/// syntaxes/02_Extra/JavaScript (Babel).sublime-syntax
/// syntaxes/02_Extra/LiveScript.sublime-syntax
/// syntaxes/02_Extra/PowerShell.sublime-syntax
/// syntaxes/02_Extra/SCSS_Sass/Syntaxes/Sass.sublime-syntax
/// syntaxes/02_Extra/SLS/SLS.sublime-syntax
/// syntaxes/02_Extra/VimHelp.sublime-syntax
/// syntaxes/02_Extra/cmd-help/syntaxes/cmd-help.sublime-syntax
/// ```
pub static RAW_SYNTAXES: Lazy<syntect::parsing::SyntaxSet> =
Lazy::new(|| syntect::dumps::from_binary(include_bytes!("../../assets/syntect.bin")));
Lazy::new(two_face::syntax::extra_no_newlines);
/// The default theme used for syntax highlighting.
pub static RAW_THEME: Lazy<synt::Theme> = Lazy::new(|| synt::Theme {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 43 KiB

After

Width:  |  Height:  |  Size: 39 KiB