Expand description
Per-language code block linting and formatting using external tools.
This module provides infrastructure for running external formatters and linters on fenced code blocks in markdown files, based on their language tags.
§Overview
When enabled, rumdl can process code blocks using external tools:
- Lint mode (
rumdl check): Run linters and report diagnostics - Format mode (
rumdl check --fix/rumdl fmt): Run formatters and update content
§Configuration
Code block tools are disabled by default. Enable and configure in .rumdl.toml:
[code-block-tools]
enabled = true
normalize-language = "linguist" # Resolve aliases like "py" -> "python"
on-error = "fail" # or "skip" / "warn"
timeout = 30000 # ms per tool
[code-block-tools.languages.python]
lint = ["ruff:check"]
format = ["ruff:format"]
[code-block-tools.languages.shell]
lint = ["shellcheck"]
format = ["shfmt"]
[code-block-tools.language-aliases]
py = "python"
bash = "shell"§Built-in Tools
Common tools are pre-configured:
ruff:check,ruff:format- Pythonprettier,prettier:json, etc. - JavaScript, JSON, YAML, etc.shellcheck,shfmt- Shell scriptsrustfmt- Rustgofmt,goimports- Go- And many more (see
registrymodule)
§Custom Tools
Define custom tools in configuration:
[code-block-tools.tools.my-formatter]
command = ["my-tool", "--format"]
stdin = true
stdout = true§Language Resolution
With normalize-language = "linguist" (default), common aliases are resolved:
py,python3→pythonbash,sh,zsh→shelljs,node→javascript
See linguist module for the full list.
Re-exports§
pub use config::CodeBlockToolsConfig;pub use config::LanguageToolConfig;pub use config::NormalizeLanguage;pub use config::OnError;pub use config::ToolDefinition;pub use executor::ExecutorError;pub use executor::ToolExecutor;pub use executor::ToolOutput;pub use linguist::LinguistResolver;pub use processor::CodeBlockDiagnostic;pub use processor::CodeBlockResult;pub use processor::CodeBlockToolProcessor;pub use processor::DiagnosticSeverity;pub use processor::FencedCodeBlockInfo;pub use processor::ProcessorError;pub use registry::ToolRegistry;
Modules§
- config
- Configuration types for code block tools.
- executor
- Tool execution engine for running external formatters and linters.
- linguist
- Language alias resolution using GitHub Linguist data.
- processor
- Main processor for code block linting and formatting.
- registry
- Built-in tool registry with definitions for common formatters and linters.