Skip to content

fix: support table alignment cells with fewer than 3 dashes (Prettier compatibility) - #1

Open
mabyoungg wants to merge 1 commit into
brandonhimpfen:mainfrom
mabyoungg:fix/prettier-table-compatibility
Open

fix: support table alignment cells with fewer than 3 dashes (Prettier compatibility)#1
mabyoungg wants to merge 1 commit into
brandonhimpfen:mainfrom
mabyoungg:fix/prettier-table-compatibility

Conversation

@mabyoungg

Copy link
Copy Markdown

Problem

Currently, is_alignment_cell expects the remaining dashes to be at least 3 characters long (len(cell) >= 3).

However, code formatters like Prettier automatically shrink table alignment cells to 1 or 2 dashes (e.g., | :-: | or | :--: |) if the column header and content are extremely short (1 or 2 characters). When this happens, the function incorrectly returns False, causing the sorting bot to treat the alignment row as a regular data row and breaking the entire table layout.

According to the GitHub Flavored Markdown (GFM) spec, an alignment cell is valid with 1 or more dashes.

Solution

  • Modified the length check condition from >= 3 to >= 1 to ensure full compatibility with auto-formatters like Prettier under any header length.
  • This ensures the alignment row is safely skipped during the sorting process regardless of formatting.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant