Skip to content

feat(mdformat): add markdown table formatter tool and tasks#442

Open
ajalon1 wants to merge 11 commits into
datarobot-oss:mainfrom
ajalon1:aj/add-markdown-table-formatter-tool
Open

feat(mdformat): add markdown table formatter tool and tasks#442
ajalon1 wants to merge 11 commits into
datarobot-oss:mainfrom
ajalon1:aj/add-markdown-table-formatter-tool

Conversation

@ajalon1
Copy link
Copy Markdown
Contributor

@ajalon1 ajalon1 commented Apr 17, 2026

Add a new Go-based markdown table formatter tool using the fbiville/markdown-table-formatter library.

The tool formats markdown tables to be readable in raw form by aligning columns with padding.

What's new

  • tools/mdformat/: Standalone Go tool that parses and formats markdown tables with proper column alignment
  • format-md-tables task: Manually format markdown tables
  • lint task: Now checks markdown table formatting (with -check flag) as the first validation step
  • delint task: Now formats markdown tables as the first cleanup step

Implementation details

  • Recursively formats all .md files while skipping .factory and node_modules directories
  • Uses fbiville/markdown-table-formatter library with WithPrettyPrint() for column alignment
  • Separates markdown table detection and reformatting from the main CLI module
  • Tool is built on-demand during lint/delint tasks

Testing

  • All existing tests pass
  • Lint checks pass (including the new markdown table check)

Note

Low Risk
Primarily tooling and documentation formatting changes; main risk is introducing new lint/format enforcement that could fail CI or rewrite markdown unexpectedly.

Overview
Introduces a new Go tool, tools/mdformat, that scans Markdown files and rewrites table blocks with aligned columns (or fails in -check mode).

Wires this into developer workflows by adding a task format-md-tables, running mdformat -check . as the first step of task lint, and formatting tables during task delint. Updates Go module metadata (new dependency + local tool/replace) and adjusts docs tables accordingly; licensing config now ignores go.mod/go.sum files.

Reviewed by Cursor Bugbot for commit 2c5ff0b. Bugbot is set up for automated code reviews on this repo. Configure here.

Add a new Go-based markdown table formatter tool using the fbiville/markdown-table-formatter library.
The tool formats markdown tables to be readable in raw form by aligning columns with padding.

New additions:
- tools/mdformat/: Standalone Go tool that parses and formats markdown tables
- format-md-tables task: Manually format markdown tables
- lint task: Now checks markdown tables (with -check flag)
- delint task: Now formats markdown tables as first step

The tool recursively formats all .md files while skipping .factory and node_modules directories.

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
Copy link
Copy Markdown

@github-advanced-security github-advanced-security AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trivy found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

@ajalon1 ajalon1 force-pushed the aj/add-markdown-table-formatter-tool branch from ef3d160 to 00c3fb8 Compare April 17, 2026 19:55
Comment thread tools/mdformat/main.go
Comment thread tools/mdformat/main.go
func isTableLine(line string) bool {
trimmed := strings.TrimSpace(line)
return strings.Contains(trimmed, "|")
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Table detection matches any line containing pipe character

High Severity

isTableLine returns true for any line containing a | character, and formatMarkdown has no awareness of fenced code blocks. Lines inside code blocks with shell pipes (e.g., cmd | tee file), bitwise OR expressions, or other non-table uses of | get collected and potentially reformatted as table content. When two or more consecutive pipe-containing lines appear inside a code block, they'll be passed to formatTable and corrupted.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 00c3fb8. Configure here.

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

There are 3 total unresolved issues (including 1 from previous review).

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 2c5ff0b. Configure here.

Comment thread Taskfile.yaml
silent: true
desc: "Format markdown tables"
cmds:
- sh -c 'cd tools/mdformat && go run . ../../..'
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong path traverses above repository root directory

High Severity

The format-md-tables task uses ../../.. as the target path, but from tools/mdformat/ that navigates three levels up — to the parent of the repository root. It needs ../.. (two levels) to reach the repo root. The lint task correctly targets . from the repo root, but format-md-tables (also called by delint) will recursively walk and rewrite .md files outside the repository.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 2c5ff0b. Configure here.

Comment thread tools/mdformat/main.go
return processFile(filePath, checkMode)
}
return nil
})
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check mode stops after first unformatted file found

Medium Severity

In check mode, processFile returns an error for each file needing formatting. Since filepath.Walk stops on the first non-nil error from its callback, the directory walk aborts after discovering just one unformatted file. The lint task (mdformat -check .) will therefore only report a single file per run, requiring repeated runs to find all issues. The callback needs to accumulate failures without stopping the walk.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 2c5ff0b. Configure here.

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.

2 participants