Skip to content

Commit

Permalink
fix: Prevent extra leading space in paragraphs in line wrap modes (#473)
Browse files Browse the repository at this point in the history
  • Loading branch information
hukkin authored Nov 8, 2024
1 parent 8d1712d commit b8c3561
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/users/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Note that there is currently no guarantee for a stable Markdown formatting style
- Fixed
- Incorrect line wrap on lines right after a hard break.
Thank you, [MDW](https://github.com/mdeweerd), for the issue.
- Adding an extra leading space to paragraphs that start with space in line wrap modes.
- Added
- Plugin interface: `mdformat.plugins.ParserExtensionInterface.add_cli_argument_group`.
With this plugins can now read CLI arguments merged with values from `.mdformat.toml`.
Expand Down
2 changes: 1 addition & 1 deletion src/mdformat/renderer/_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ def _wrap(text: str, *, width: int | Literal["no"]) -> str:
)
wrapped = wrapper.fill(text)
wrapped = _recover_preserve_chars(wrapped, replacements)
return " " + wrapped if text.startswith(" ") else wrapped
return wrapped


def _prepare_wrap(text: str) -> tuple[str, str]:
Expand Down
8 changes: 8 additions & 0 deletions tests/data/wrap_width_50.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,3 +180,11 @@ sssssssssssssssssssssssssssssssssssss backslash
bar"> ipsum dolor sit amet, consectetur adip
elitismisun.
.


Starts with encoded space
.
 * * * 
.
 * * \*
.

0 comments on commit b8c3561

Please sign in to comment.