Conversation
Co-authored-by: KyleKing <3784339+KyleKing@users.noreply.github.com>
Remove the aggressive trailing space stripping from _render_code_inline that was causing HTML changes. The function now preserves trailing spaces to maintain HTML output consistency. Updated test expectations accordingly. Co-authored-by: KyleKing <3784339+KyleKing@users.noreply.github.com>
|
@copilot Improve the test suite for different variations like this and not just the specific one I provided (different types of whitespace, different HTML, etc.) There is an option in mdformat to allow breaking HTML checks locally when known to cause issues We cannot break support for issue 34, so ensure that the best effort formatting is preserved |
- Reverted to original _render_code_inline behavior that strips trailing spaces as best-effort for issue #34 - Added comprehensive test suite in inline_code_whitespace.md covering 19 edge cases - Enhanced docstring with guidance on --no-validate flag for edge cases - All 270 tests pass including snippet formatting and new whitespace tests Co-authored-by: KyleKing <3784339+KyleKing@users.noreply.github.com>
I've restored the original best-effort trailing space stripping behavior to maintain issue #34 support and added comprehensive test coverage. Changes in commit 9549fd3:
All 270 tests pass, including the original snippet formatting case from issue #34. |
|
@copilot with CI passing, does that mean that the reported issue with |
The reported issue with CI passes because:
Pre-commit fails because: Current behavior (best-effort for issue #34):
Workarounds for users:
This is the intended trade-off: best-effort formatting for common case (issue #34) with documented workarounds for edge cases. |
The
_render_code_inlinefunction uses a best-effort heuristic to strip trailing spaces from inline code, primarily to clean up unintended spaces from newlines before closing backticks (issue #34). This approach may change HTML in rare edge cases where trailing spaces are intentional.Changes
mdformat_mkdocs/plugin.py: Maintains the original best-effort implementation that strips trailing spaces when there's no leading space. Enhanced docstring to document the heuristic, potential HTML changes in edge cases, and workarounds (--no-validateflag or add leading space to preserve trailing).Test fixtures: Added comprehensive test suite
inline_code_whitespace.mdwith 19 test cases covering:Technical Context
Markdown-it normalizes both
`code\n`and`code `to the same parsed representation (code). The best-effort heuristic strips trailing spaces when there's no leading space to handle the common case (newlines before closing backticks) while accepting that rare edge cases with intentional trailing spaces may have HTML changes.Trade-offs
`test `before---)--no-validateflag or add leading space (` test `)All 270 tests pass, including original issue #34 support.
Original prompt
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.