You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An [mdformat](https://github.com/executablebooks/mdformat) plugin for `<placeholder>`
5
+
An [mdformat](https://github.com/executablebooks/mdformat) plugin for [mdslw](https://github.com/razziel89/mdslw)-style sentence wrapping.
6
+
7
+
This plugin wraps markdown text by inserting line breaks after sentence-ending punctuation, making diffs cleaner and easier to review.
8
+
9
+
## Features
10
+
11
+
- Wrap sentences at configurable punctuation marks (default: `.!?:`)
Add this package wherever you use `mdformat` and the plugin will be auto-recognized. No additional configuration necessary. See [additional information on `mdformat` plugins here](https://mdformat.readthedocs.io/en/stable/users/plugins.html)
10
19
20
+
### CLI
21
+
22
+
```sh
23
+
mdformat --wrap-sentences document.md
24
+
```
25
+
26
+
#### Options
27
+
28
+
-`--wrap-sentences`: Enable sentence wrapping (required to activate the plugin)
29
+
-`--sentence-markers TEXT`: Characters that mark sentence endings (default: `.!?:`)
30
+
-`--max-line-width INTEGER`: Maximum line width for wrapping (default: 80, 0 to disable)
31
+
32
+
### Configuration File
33
+
34
+
Create a `.mdformat.toml` file in your project root:
To generate HTML output, `mdformat_mdsf_plugin` can be imported from `mdit_plugins`. For more guidance on `MarkdownIt`, see the docs: <https://markdown-it-py.readthedocs.io/en/latest/using.html#the-parser>
72
+
```python
73
+
import mdformat
39
74
40
-
```py
41
-
from markdown_it import MarkdownIt
75
+
text ="""
76
+
This is a test. It has multiple sentences! Does it work?
77
+
"""
42
78
43
-
from mdformat_mdformat_mdsf.mdit_plugins import mdformat_mdsf_plugin
79
+
# Enable sentence wrapping
80
+
result = mdformat.text(text, extensions={"mdslw"}, options={"wrap_sentences": True})
81
+
82
+
print(result)
83
+
# Output:
84
+
# This is a test.
85
+
# It has multiple sentences!
86
+
# Does it work?
87
+
```
88
+
89
+
## Example
90
+
91
+
**Input:**
92
+
93
+
```markdown
94
+
This is a long sentence. It contains multiple clauses! Does it work? Yes it does.
95
+
```
44
96
45
-
md = MarkdownIt()
46
-
md.use(mdformat_mdsf_plugin)
97
+
**Output (with `--wrap-sentences`):**
47
98
48
-
text ="... markdown example ..."
49
-
md.render(text)
50
-
# <div>
51
-
#
52
-
# </div>
99
+
```markdown
100
+
This is a long sentence.
101
+
It contains multiple clauses!
102
+
Does it work?
103
+
Yes it does.
53
104
```
54
105
55
106
## Contributing
56
107
57
-
See [CONTRIBUTING.md](https://github.com/kyleking/mdformat-mdformat-mdsf/blob/main/CONTRIBUTING.md)
108
+
See [CONTRIBUTING.md](https://github.com/kyleking/mdformat-mdslw/blob/main/CONTRIBUTING.md)
0 commit comments