Skip to content

Commit

Permalink
feat(Automattic#230): delegate typst files to parser in harper-cli an…
Browse files Browse the repository at this point in the history
…d harper-ls
  • Loading branch information
grantlemons committed Dec 4, 2024
1 parent 55bfcbf commit 376e427
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
4 changes: 3 additions & 1 deletion harper-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ 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;
use harper_core::parsers::{Markdown, Typst};
use harper_core::{remove_overlaps, Dictionary, Document, FstDictionary};

#[derive(Debug, Parser)]
Expand Down Expand Up @@ -107,6 +107,8 @@ fn load_file(file: &Path) -> anyhow::Result<(Document, String)> {
let mut parser: Box<dyn harper_core::parsers::Parser> =
if let Some("md") = file.extension().map(|v| v.to_str().unwrap()) {
Box::new(Markdown)
} else if let Some("typ") = file.extension().map(|v| v.to_str().unwrap()) {
Box::new(Typst)
} else {
Box::new(
CommentParser::new_from_filename(file)
Expand Down
1 change: 1 addition & 0 deletions harper-core/src/parsers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ 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};

Expand Down
6 changes: 5 additions & 1 deletion harper-ls/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ use std::sync::Arc;
use anyhow::anyhow;
use harper_comments::CommentParser;
use harper_core::linting::{LintGroup, Linter};
use harper_core::parsers::{CollapseIdentifiers, IsolateEnglish, Markdown, Parser, PlainEnglish};
use harper_core::parsers::{
CollapseIdentifiers, IsolateEnglish, Markdown, Parser, PlainEnglish, Typst,
};
use harper_core::{
Dictionary, Document, FstDictionary, FullDictionary, MergedDictionary, Token, TokenKind,
WordMetadata,
Expand Down Expand Up @@ -206,6 +208,8 @@ impl Backend {
}
} else if language_id == "markdown" {
Some(Box::new(Markdown))
} else if language_id == "typst" {
Some(Box::new(Typst))
} else if language_id == "git-commit" {
Some(Box::new(GitCommitParser))
} else if language_id == "html" {
Expand Down

0 comments on commit 376e427

Please sign in to comment.