pub struct MD060TableFormat { /* private fields */ }Expand description
Rule MD060: Table Column Alignment
See docs/md060.md for full documentation, configuration, and examples.
This rule enforces consistent column alignment in Markdown tables for improved readability in source form. When enabled, it ensures table columns are properly aligned with appropriate padding.
§Purpose
- Readability: Aligned tables are significantly easier to read in source form
- Maintainability: Properly formatted tables are easier to edit and review
- Consistency: Ensures uniform table formatting throughout documents
- Developer Experience: Makes working with tables in plain text more pleasant
§Configuration Options
The rule supports the following configuration options:
MD060:
enabled: false # Default: opt-in for conservative adoption
style: "aligned" # Can be "aligned", "compact", or "none"
max_width: 120 # Optional: auto-compact for wide tables§Style Options
- aligned: Columns are padded with spaces for visual alignment (default)
- compact: No padding, minimal spacing
- none: Disable formatting checks
§Max Width
When max_width is set (default: 120), tables wider than this limit will automatically
use compact formatting to prevent excessive line lengths.
§Examples
§Aligned Style (Good)
| Name | Age | City |
|-------|-----|-----------|
| Alice | 30 | Seattle |
| Bob | 25 | Portland |§Unaligned (Bad)
| Name | Age | City |
|---|---|---|
| Alice | 30 | Seattle |
| Bob | 25 | Portland |§Unicode Support
This rule properly handles:
- CJK Characters: Chinese, Japanese, Korean characters are correctly measured as double-width
- Basic Emoji: Most emoji are handled correctly
- Inline Code: Pipes in inline code blocks are properly masked
§Known Limitations
Complex Emoji Sequences: Tables containing Zero-Width Joiner (ZWJ) emoji sequences (e.g., 👨👩👧👦, 👩💻) are automatically skipped. These complex emoji have inconsistent display widths across different terminals and fonts, making accurate alignment impossible. The rule will preserve these tables as-is rather than risk corrupting them.
This is an honest limitation of terminal display technology, similar to what other tools like markdownlint experience.
§Fix Behavior
When applying automatic fixes, this rule:
- Calculates proper display width for each column using Unicode width measurements
- Pads cells with trailing spaces to align columns
- Preserves cell content exactly (only spacing is modified)
- Respects alignment indicators in delimiter rows (
:---,:---:,---:) - Automatically switches to compact mode for tables exceeding max_width
- Skips tables with ZWJ emoji to prevent corruption
Implementations§
Trait Implementations§
Source§impl Clone for MD060TableFormat
impl Clone for MD060TableFormat
Source§fn clone(&self) -> MD060TableFormat
fn clone(&self) -> MD060TableFormat
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MD060TableFormat
impl Debug for MD060TableFormat
Source§impl Default for MD060TableFormat
impl Default for MD060TableFormat
Source§fn default() -> MD060TableFormat
fn default() -> MD060TableFormat
Source§impl Rule for MD060TableFormat
impl Rule for MD060TableFormat
fn name(&self) -> &'static str
fn description(&self) -> &'static str
Source§fn should_skip(&self, ctx: &LintContext<'_>) -> bool
fn should_skip(&self, ctx: &LintContext<'_>) -> bool
fn check(&self, ctx: &LintContext<'_>) -> LintResult
fn fix(&self, ctx: &LintContext<'_>) -> Result<String, LintError>
fn as_any(&self) -> &dyn Any
Source§fn default_config_section(&self) -> Option<(String, Value)>
fn default_config_section(&self) -> Option<(String, Value)>
impl Rule for ... block,
not just the inherent impl.Source§fn from_config(config: &Config) -> Box<dyn Rule>where
Self: Sized,
fn from_config(config: &Config) -> Box<dyn Rule>where
Self: Sized,
Source§fn check_with_ast(
&self,
ctx: &LintContext<'_>,
_ast: &MarkdownAst,
) -> LintResult
fn check_with_ast( &self, ctx: &LintContext<'_>, _ast: &MarkdownAst, ) -> LintResult
Source§fn category(&self) -> RuleCategory
fn category(&self) -> RuleCategory
fn as_maybe_ast(&self) -> Option<&dyn MaybeAst>
Source§fn config_aliases(&self) -> Option<HashMap<String, String>>
fn config_aliases(&self) -> Option<HashMap<String, String>>
Source§fn fix_capability(&self) -> FixCapability
fn fix_capability(&self) -> FixCapability
Auto Trait Implementations§
impl Freeze for MD060TableFormat
impl RefUnwindSafe for MD060TableFormat
impl Send for MD060TableFormat
impl Sync for MD060TableFormat
impl Unpin for MD060TableFormat
impl UnwindSafe for MD060TableFormat
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more