Skip to content

Commit

Permalink
fix: formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Rolv-Apneseth committed Dec 22, 2024
1 parent 5dbbcbd commit f49fde0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
16 changes: 9 additions & 7 deletions src/cli/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,16 @@ impl ExecuteSubcommand for Command {
// If file type is "Auto", guess file type from extension
if matches!(self.r#type, FileType::Auto) {
file_type = match PathBuf::from(filename).extension().and_then(|e| e.to_str()) {
Some(ext) => match ext {
"typ" => FileType::Typst,
"md" | "mkd" | "mdwn" | "mdown" | "mdtxt" | "mdtext" | "markdown" => {
FileType::Markdown
},
Some(ext) => {
match ext {
"typ" => FileType::Typst,
"md" | "mkd" | "mdwn" | "mdown" | "mdtxt" | "mdtext" | "markdown" => {
FileType::Markdown
},

"html" | "htm" => FileType::Html,
_ => FileType::Raw,
"html" | "htm" => FileType::Html,
_ => FileType::Raw,
}
},
None => FileType::Raw,
};
Expand Down
13 changes: 8 additions & 5 deletions src/parsers.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
//! Utilities for parsing the contents of different file types into a text representation that can
//! be sent to the LanguageTool API.
//! Utilities for parsing the contents of different file types into a text
//! representation that can be sent to the LanguageTool API.
/// Parse the contents of an HTML file into a text format to be sent to the LanguageTool API.
/// Parse the contents of an HTML file into a text format to be sent to the
/// LanguageTool API.
#[cfg(feature = "html")]
pub fn parse_html(file_content: impl AsRef<str>) -> String {
use html_parser::Node;
Expand Down Expand Up @@ -85,7 +86,8 @@ pub fn parse_html(file_content: impl AsRef<str>) -> String {
txt
}

/// Parse the contents of a Markdown file into a text format to be sent to the LanguageTool API.
/// Parse the contents of a Markdown file into a text format to be sent to the
/// LanguageTool API.
#[cfg(feature = "markdown")]
pub fn parse_markdown(file_content: impl AsRef<str>) -> String {
use pulldown_cmark::{html, Options, Parser};
Expand All @@ -101,7 +103,8 @@ pub fn parse_markdown(file_content: impl AsRef<str>) -> String {
parse_html(html)
}

/// Parse the contents of a Typst file into a text format to be sent to the LanguageTool API.
/// Parse the contents of a Typst file into a text format to be sent to the
/// LanguageTool API.
#[cfg(feature = "typst")]
pub fn parse_typst(file_content: impl AsRef<str>) -> String {
use typst_syntax::{parse, SyntaxKind, SyntaxNode};
Expand Down

0 comments on commit f49fde0

Please sign in to comment.