summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCosmicHorror <CosmicHorrorDev@pm.me>2023-12-18 05:17:47 -0700
committerGitHub <noreply@github.com>2023-12-18 13:17:47 +0100
commit56159997b7a5866e0005f21ff3b6a5f4b9d3d6b3 (patch)
treec3f7a12ae0b49c14c134d3cce73b2e7e7f582ae9
parent754e1788b2c690a5520d34b967cae31fb44726b9 (diff)
Switch to `two-face` for extra syntect syntaxes (#2937)
-rw-r--r--Cargo.lock12
-rw-r--r--Cargo.toml1
-rw-r--r--NOTICE2
-rw-r--r--crates/typst/Cargo.toml1
-rw-r--r--crates/typst/assets/syntect.binbin687378 -> 0 bytes
-rw-r--r--crates/typst/src/text/raw.rs25
-rw-r--r--tests/ref/text/raw-code.pngbin43940 -> 40290 bytes
7 files changed, 17 insertions, 24 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 64610cc2..98eaa81e 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2646,6 +2646,17 @@ 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"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2692,6 +2703,7 @@ dependencies = [
"toml",
"tracing",
"ttf-parser",
+ "two-face",
"typed-arena",
"typst-macros",
"typst-syntax",
diff --git a/Cargo.toml b/Cargo.toml
index 9e6e5ac0..bd82c319 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -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"
diff --git a/NOTICE b/NOTICE
index 92e1a54a..65062585 100644
--- a/NOTICE
+++ b/NOTICE
@@ -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
diff --git a/crates/typst/Cargo.toml b/crates/typst/Cargo.toml
index af90a1d8..a22bb792 100644
--- a/crates/typst/Cargo.toml
+++ b/crates/typst/Cargo.toml
@@ -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 }
diff --git a/crates/typst/assets/syntect.bin b/crates/typst/assets/syntect.bin
deleted file mode 100644
index 043602a4..00000000
--- a/crates/typst/assets/syntect.bin
+++ /dev/null
Binary files differ
diff --git a/crates/typst/src/text/raw.rs b/crates/typst/src/text/raw.rs
index aa2f93f8..1f9f9ccb 100644
--- a/crates/typst/src/text/raw.rs
+++ b/crates/typst/src/text/raw.rs
@@ -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 {
diff --git a/tests/ref/text/raw-code.png b/tests/ref/text/raw-code.png
index f772ba41..d3373f5f 100644
--- a/tests/ref/text/raw-code.png
+++ b/tests/ref/text/raw-code.png
Binary files differ