Skip to content

Fix whitespace around inline elements like links#109

Merged
xijo merged 2 commits intomasterfrom
fix-whitespace-around-links
Jan 20, 2026
Merged

Fix whitespace around inline elements like links#109
xijo merged 2 commits intomasterfrom
fix-whitespace-around-links

Conversation

@xijo
Copy link
Owner

@xijo xijo commented Jan 20, 2026

Summary

  • Add handling for leading newlines when there's preceding inline content
  • Complements the existing trailing newline handling from Fix whitespace collapsing between inline elements #108
  • Refactored directional checks into single has_adjacent_inline_content?(node, direction) method

Before: a\n<a href='1'>link</a>\nis gooda[link](1)is good
After: a\n<a href='1'>link</a>\nis gooda [link](1) is good

Performance

Benchmarked the traversal overhead: ~1.7% impact on full conversion - negligible.

Test plan

  • Added spec for whitespace surrounding links
  • All 206 tests pass

Fixes #91

🤖 Generated with Claude Code

xijo and others added 2 commits January 20, 2026 11:16
Add handling for leading newlines when there's preceding inline content,
complementing the existing trailing newline handling. This fixes cases
like `a\n<a href='1'>link</a>\nis good` which now correctly renders as
`a [link](1) is good` instead of `a[link](1)is good`.

Also refactored the two directional checks into a single
`has_adjacent_inline_content?(node, direction)` method.

Fixes #91

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@xijo xijo merged commit bca16e0 into master Jan 20, 2026
7 checks passed
@xijo xijo deleted the fix-whitespace-around-links branch January 20, 2026 11:11
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.

Too much blankspace gets stripped

1 participant