Skip to content

Commit

Permalink
feat: support markuplint (#297)
Browse files Browse the repository at this point in the history
  • Loading branch information
hougesen authored Jun 15, 2024
1 parent ced7826 commit 2a4ca6b
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 7 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ mdsf init
<!-- START_SECTION:supported-languages -->

`mdsf` currently supports 123 tools.
`mdsf` currently supports 124 tools.

| Formatter | Description |
| ------------------ | ---------------------------------------------------------------------------------------------------------------------- |
Expand Down Expand Up @@ -175,6 +175,7 @@ mdsf init
| leptosfmt | [https://github.com/bram209/leptosfmt](https://github.com/bram209/leptosfmt) |
| luaformatter | [https://github.com/Koihik/LuaFormatter](https://github.com/Koihik/LuaFormatter) |
| markdownlint | [https://github.com/davidanson/markdownlint](https://github.com/davidanson/markdownlint) |
| markuplint | [https://markuplint.dev](https://markuplint.dev) |
| mdformat | [https://github.com/executablebooks/mdformat](https://github.com/executablebooks/mdformat) |
| misspell | [https://github.com/client9/misspell/](https://github.com/client9/misspell/) |
| mix_format | [https://hexdocs.pm/mix/main/Mix.Tasks.Format.html](https://hexdocs.pm/mix/main/Mix.Tasks.Format.html) |
Expand Down
5 changes: 5 additions & 0 deletions schemas/v0.1.1/mdsf.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,11 @@
"type": "string",
"enum": ["markdownlint"]
},
{
"description": "https://markuplint.dev",
"type": "string",
"enum": ["markuplint"]
},
{
"description": "https://github.com/executablebooks/mdformat",
"type": "string",
Expand Down
32 changes: 32 additions & 0 deletions src/formatters/markuplint.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
use super::execute_command;
use crate::{error::MdsfError, runners::setup_npm_script};

#[inline]
fn set_markuplint_args(cmd: &mut std::process::Command, snippet_path: &std::path::Path) {
cmd.arg("--fix").arg(snippet_path);
}

#[inline]
fn invoke_markuplint(
mut cmd: std::process::Command,
snippet_path: &std::path::Path,
) -> Result<(bool, Option<String>), MdsfError> {
set_markuplint_args(&mut cmd, snippet_path);

execute_command(&mut cmd, snippet_path)
}

#[inline]
pub fn format_using_markuplint(
snippet_path: &std::path::Path,
) -> Result<(bool, Option<String>), MdsfError> {
if let Ok(path_result) =
invoke_markuplint(std::process::Command::new("markuplint"), snippet_path)
{
if !path_result.0 {
return Ok(path_result);
}
}

invoke_markuplint(setup_npm_script("markuplint"), snippet_path)
}
19 changes: 13 additions & 6 deletions src/formatters/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ use crate::{
kcl_fmt::format_using_kcl_fmt, kdlfmt::format_using_kdlfmt, ktfmt::format_using_ktfmt,
ktlint::format_using_ktlint, leptosfmt::format_using_leptosfmt,
luaformatter::format_using_luaformatter, markdownlint::format_using_markdownlint,
mdformat::format_using_mdformat, misspell::format_using_misspell,
mix_format::format_using_mix_format, nimpretty::format_using_nimpretty,
nixfmt::format_using_nixfmt, nixpkgs_fmt::format_using_nixpkgs_fmt,
npm_groovy_lint::format_using_npm_groovy_lint, ocamlformat::format_using_ocamlformat,
ocp_indent::format_using_ocp_indent, ormolu::format_using_ormolu,
oxlint::format_using_oxlint, perltidy::format_using_perltidy,
markuplint::format_using_markuplint, mdformat::format_using_mdformat,
misspell::format_using_misspell, mix_format::format_using_mix_format,
nimpretty::format_using_nimpretty, nixfmt::format_using_nixfmt,
nixpkgs_fmt::format_using_nixpkgs_fmt, npm_groovy_lint::format_using_npm_groovy_lint,
ocamlformat::format_using_ocamlformat, ocp_indent::format_using_ocp_indent,
ormolu::format_using_ormolu, oxlint::format_using_oxlint, perltidy::format_using_perltidy,
pg_format::format_using_pg_format, prettier::format_using_prettier,
puppet_lint::format_using_puppet_lint, purs_tidy::format_using_purs_tidy,
pyink::format_using_pyink, rescript_format::format_using_rescript_format,
Expand Down Expand Up @@ -139,6 +139,7 @@ mod ktlint;
mod leptosfmt;
mod luaformatter;
mod markdownlint;
mod markuplint;
mod mdformat;
mod misspell;
mod mix_format;
Expand Down Expand Up @@ -582,6 +583,10 @@ pub enum Tooling {
#[serde(rename = "markdownlint")]
Markdownlint,

#[doc = "https://markuplint.dev"]
#[serde(rename = "markuplint")]
Markuplint,

#[doc = "https://github.com/executablebooks/mdformat"]
#[serde(rename = "mdformat")]
MdFormat,
Expand Down Expand Up @@ -883,6 +888,7 @@ impl Tooling {
Self::LeptosFmt => format_using_leptosfmt(snippet_path),
Self::LuaFormatter => format_using_luaformatter(snippet_path),
Self::Markdownlint => format_using_markdownlint(snippet_path),
Self::Markuplint => format_using_markuplint(snippet_path),
Self::MdFormat => format_using_mdformat(snippet_path),
Self::Misspell => format_using_misspell(snippet_path),
Self::MixFormat => format_using_mix_format(snippet_path),
Expand Down Expand Up @@ -1015,6 +1021,7 @@ impl core::fmt::Display for Tooling {
Self::LeptosFmt => write!(f, "leptosfmt"),
Self::LuaFormatter => write!(f, "luaformatter"),
Self::Markdownlint => write!(f, "markdownlint"),
Self::Markuplint => write!(f, "markuplint"),
Self::MdFormat => write!(f, "mdformat"),
Self::Misspell => write!(f, "misspell"),
Self::MixFormat => write!(f, "mix_format"),
Expand Down

0 comments on commit 2a4ca6b

Please sign in to comment.