Offline, privacy-first grammar checker. Fast, open-source, Rust-powered
feat(#230): make typst into a feature
Grant Lemonsee1080da64ee
diff --git a/harper-cli/Cargo.toml b/harper-cli/Cargo.tomlindex 9281ea379..b23feef22 100644--- a/harper-cli/Cargo.toml+++ b/harper-cli/Cargo.toml@@ -13,3 +13,7 @@ clap = { version = "4.5.23", features = ["derive"] }harper-core = { path = "../harper-core", version = "0.14.0" }harper-comments = { path = "../harper-comments", version = "0.14.0" }serde_json = "1.0.133"++[features]+default = ["typst"]+typst = ["harper-core/typst"]diff --git a/harper-cli/src/main.rs b/harper-cli/src/main.rsindex f2b527978..b8f4ab9c3 100644--- a/harper-cli/src/main.rs+++ b/harper-cli/src/main.rs@@ -7,9 +7,12 @@ use ariadne::{Color, Label, Report, ReportKind, Source};use clap::Parser;use harper_comments::CommentParser;use harper_core::linting::{LintGroup, LintGroupConfig, Linter};-use harper_core::parsers::{Markdown, Typst};+use harper_core::parsers::Markdown;use harper_core::{remove_overlaps, Dictionary, Document, FstDictionary};+#[cfg(feature = "typst")]+use harper_core::parsers::Typst;+#[derive(Debug, Parser)]enum Args {/// Lint a provided document.diff --git a/harper-core/Cargo.toml b/harper-core/Cargo.tomlindex f50ef9d6a..d0db54669 100644--- a/harper-core/Cargo.toml+++ b/harper-core/Cargo.toml@@ -24,7 +24,7 @@ thiserror = "2.0.9"unicode-blocks = "0.1.9"unicode-width = "0.2.0"levenshtein_automata = { version = "0.2.1", features = ["fst_automaton"] }-typst-syntax = "0.12.0"+typst-syntax = { version = "0.12.0", optional = true }[dev-dependencies]criterion = { version = "0.5.1", default-features = false }@@ -35,5 +35,6 @@ name = "parse_demo"harness = false[features]-default = []+default = ["typst"]concurrent = []+typst = ["typst-syntax"]diff --git a/harper-core/src/parsers/mod.rs b/harper-core/src/parsers/mod.rsindex afed02ca1..f937d0000 100644--- a/harper-core/src/parsers/mod.rs+++ b/harper-core/src/parsers/mod.rs@@ -3,7 +3,11 @@ mod isolate_english;mod markdown;mod mask;mod plain_english;++#[cfg(feature = "typst")]mod typst;+#[cfg(feature = "typst")]+pub use typst::Typst;use blanket::blanket;pub use collapse_identifiers::CollapseIdentifiers;@@ -11,7 +15,6 @@ pub use isolate_english::IsolateEnglish;pub use markdown::Markdown;pub use mask::Mask;pub use plain_english::PlainEnglish;-pub use typst::Typst;pub use crate::token::{Token, TokenKind, TokenStringExt};diff --git a/harper-core/tests/run_tests.rs b/harper-core/tests/run_tests.rsindex d9ee73ef3..6a258a27f 100644--- a/harper-core/tests/run_tests.rs+++ b/harper-core/tests/run_tests.rs@@ -47,5 +47,8 @@ create_test!(chinese_lorem_ipsum.md, &Markdown, 2);create_test!(obsidian_links.md, &Markdown, 2);create_test!(issue_267.md, &Markdown, 0);create_test!(proper_noun_capitalization.md, &Markdown, 2);++#[cfg(feature = "typst")]create_test!(complex_typst.typ, &Typst, 0);+#[cfg(feature = "typst")]create_test!(typst_spelling_mistakes.typ, &Typst, 4);diff --git a/harper-wasm/Cargo.toml b/harper-wasm/Cargo.tomlindex 3b918038d..2ea1d21f6 100644--- a/harper-wasm/Cargo.toml+++ b/harper-wasm/Cargo.toml@@ -14,7 +14,7 @@ console_error_panic_hook = "0.1.7"tracing = "0.1.41"tracing-wasm = "0.2.1"wasm-bindgen = "0.2.97"-harper-core = { path = "../harper-core", version = "0.14.0", features = ["concurrent"] }+harper-core = { path = "../harper-core", version = "0.14.0", features = ["concurrent"], default-features = false }once_cell = "1.20.2"serde-wasm-bindgen = "0.6.5"serde_json = "1.0.133"