Skip to content

Avoid creating overlong inline-code lines when wrapping #330

Description

@lodyai

Summary

mdtablefix --wrap joins long inline-code API signatures with following prose and creates Markdown lines that still violate an 80-column MD013 line-length policy.

Reproduction

Using mdtablefix 0.4.0:

mdtablefix --wrap --renumber --breaks --ellipsis --fences --in-place docs/execplans/3-1-2-tool-discovery-and-routing.md
markdownlint-cli2 docs/execplans/3-1-2-tool-discovery-and-routing.md

Input excerpt:

`retrieve_log(&self, ctx: &RequestContext, path: &str) -> ToolLogStoreResult<bytes::Bytes>`
— reads a log blob by path.

`delete_log(&self, ctx: &RequestContext, path: &str) -> ToolLogStoreResult<()>`
— deletes a single log blob.

`list_logs_for_server(&self, ctx: &RequestContext, server_id: McpServerId) -> ToolLogStoreResult<Vec<String>>`
— lists all log blob paths for a server by prefix scan on
`tool_logs/{tenant_id}/{server_id}/` (tenant extracted from `ctx`).

Actual output excerpt:

`retrieve_log(&self, ctx: &RequestContext, path: &str) -> ToolLogStoreResult<bytes::Bytes>` —
reads a log blob by path.

`delete_log(&self, ctx: &RequestContext, path: &str) -> ToolLogStoreResult<()>` —
deletes a single log blob.

`list_logs_for_server(&self, ctx: &RequestContext, server_id: McpServerId) -> ToolLogStoreResult<Vec<String>>` —
lists all log blob paths for a server by prefix scan on
`tool_logs/{tenant_id}/{server_id}/` (tenant extracted from `ctx`).

markdownlint-cli2 then reports these lines as too long:

docs/execplans/3-1-2-tool-discovery-and-routing.md:529:81 error MD013/line-length Line length [Expected: 80; Actual: 93]
docs/execplans/3-1-2-tool-discovery-and-routing.md:532:81 error MD013/line-length Line length [Expected: 80; Actual: 81]
docs/execplans/3-1-2-tool-discovery-and-routing.md:535:81 error MD013/line-length Line length [Expected: 80; Actual: 112]

A similar case appears in docs/corbusier-api-design.md, where this wrapped input:

- `Task { id, origin, branch_ref, pull_request_ref, state, created_at,
  updated_at }`

is rewritten to one overlong line:

- `Task { id, origin, branch_ref, pull_request_ref, state, created_at, updated_at }`

Expected behaviour

When --wrap is enabled, mdtablefix should preserve or create Markdown that satisfies the configured wrap width. If an inline code span is too long to fit with surrounding prose, the formatter should keep the code span on its own line, keep the description on the next line, or leave the original wrapping unchanged.

Impact

The formatter target becomes self-defeating: mdtablefix --wrap creates output that immediately fails markdownlint-cli2 with MD013.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions