flowmark 0.5.2__tar.gz → 0.5.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {flowmark-0.5.2 → flowmark-0.5.4}/.copier-answers.yml +1 -1
- {flowmark-0.5.2 → flowmark-0.5.4}/.github/workflows/ci.yml +2 -2
- {flowmark-0.5.2 → flowmark-0.5.4}/.github/workflows/publish.yml +1 -1
- {flowmark-0.5.2 → flowmark-0.5.4}/PKG-INFO +3 -1
- flowmark-0.5.4/docs/bug1-example.md +2 -0
- flowmark-0.5.4/docs/bug2-example.md +4 -0
- {flowmark-0.5.2 → flowmark-0.5.4}/pyproject.toml +4 -2
- flowmark-0.5.4/src/flowmark/__init__.py +34 -0
- {flowmark-0.5.2 → flowmark-0.5.4}/src/flowmark/cli.py +14 -9
- flowmark-0.5.2/src/flowmark/custom_marko.py → flowmark-0.5.4/src/flowmark/formats/flowmark_markdown.py +26 -6
- {flowmark-0.5.2/src/flowmark → flowmark-0.5.4/src/flowmark/linewrapping}/line_wrappers.py +7 -3
- {flowmark-0.5.2/src/flowmark → flowmark-0.5.4/src/flowmark/linewrapping}/markdown_filling.py +14 -10
- {flowmark-0.5.2/src/flowmark → flowmark-0.5.4/src/flowmark/linewrapping}/text_filling.py +1 -1
- {flowmark-0.5.2 → flowmark-0.5.4}/src/flowmark/reformat_api.py +77 -3
- {flowmark-0.5.2/src/flowmark → flowmark-0.5.4/src/flowmark/transforms}/doc_cleanups.py +1 -1
- {flowmark-0.5.2/src/flowmark → flowmark-0.5.4/src/flowmark/transforms}/doc_transforms.py +1 -1
- {flowmark-0.5.2 → flowmark-0.5.4}/tests/test_cleanups.py +4 -4
- {flowmark-0.5.2 → flowmark-0.5.4}/tests/test_ellipses.py +1 -1
- {flowmark-0.5.2 → flowmark-0.5.4}/tests/test_filling.py +4 -1
- {flowmark-0.5.2 → flowmark-0.5.4}/tests/test_frontmatter.py +2 -2
- {flowmark-0.5.2 → flowmark-0.5.4}/tests/test_list_spacing.py +1 -1
- {flowmark-0.5.2 → flowmark-0.5.4}/tests/test_ref_docs.py +1 -1
- {flowmark-0.5.2 → flowmark-0.5.4}/tests/test_smartquotes.py +1 -1
- {flowmark-0.5.2 → flowmark-0.5.4}/tests/test_wrapping.py +2 -2
- flowmark-0.5.4/uv.lock +389 -0
- flowmark-0.5.2/src/flowmark/__init__.py +0 -28
- flowmark-0.5.2/uv.lock +0 -382
- {flowmark-0.5.2 → flowmark-0.5.4}/.cursor/rules/flowmark.mdc +0 -0
- {flowmark-0.5.2 → flowmark-0.5.4}/.cursor/rules/general.mdc +0 -0
- {flowmark-0.5.2 → flowmark-0.5.4}/.cursor/rules/python.mdc +0 -0
- {flowmark-0.5.2 → flowmark-0.5.4}/.gitignore +0 -0
- {flowmark-0.5.2 → flowmark-0.5.4}/.vscode/settings.json +0 -0
- {flowmark-0.5.2 → flowmark-0.5.4}/LICENSE +0 -0
- {flowmark-0.5.2 → flowmark-0.5.4}/Makefile +0 -0
- {flowmark-0.5.2 → flowmark-0.5.4}/README.md +0 -0
- {flowmark-0.5.2 → flowmark-0.5.4}/development.md +0 -0
- {flowmark-0.5.2 → flowmark-0.5.4}/devtools/lint.py +0 -0
- {flowmark-0.5.2 → flowmark-0.5.4}/installation.md +0 -0
- {flowmark-0.5.2 → flowmark-0.5.4}/poetry.lock +0 -0
- {flowmark-0.5.2 → flowmark-0.5.4}/publishing.md +0 -0
- {flowmark-0.5.2/src/flowmark → flowmark-0.5.4/src/flowmark/formats}/frontmatter.py +0 -0
- {flowmark-0.5.2/src/flowmark → flowmark-0.5.4/src/flowmark/linewrapping}/sentence_split_regex.py +0 -0
- {flowmark-0.5.2/src/flowmark → flowmark-0.5.4/src/flowmark/linewrapping}/text_wrapping.py +0 -0
- {flowmark-0.5.2 → flowmark-0.5.4}/src/flowmark/py.typed +0 -0
- {flowmark-0.5.2/src/flowmark → flowmark-0.5.4/src/flowmark/typography}/ellipses.py +0 -0
- {flowmark-0.5.2/src/flowmark → flowmark-0.5.4/src/flowmark/typography}/smartquotes.py +0 -0
- {flowmark-0.5.2 → flowmark-0.5.4}/tests/test_sentences.py +0 -0
- {flowmark-0.5.2 → flowmark-0.5.4}/tests/test_width_options.py +0 -0
- {flowmark-0.5.2 → flowmark-0.5.4}/tests/testdocs/.gitignore +0 -0
- {flowmark-0.5.2 → flowmark-0.5.4}/tests/testdocs/testdoc.expected.auto.md +0 -0
- {flowmark-0.5.2 → flowmark-0.5.4}/tests/testdocs/testdoc.expected.cleaned.md +0 -0
- {flowmark-0.5.2 → flowmark-0.5.4}/tests/testdocs/testdoc.expected.plain.md +0 -0
- {flowmark-0.5.2 → flowmark-0.5.4}/tests/testdocs/testdoc.expected.semantic.md +0 -0
- {flowmark-0.5.2 → flowmark-0.5.4}/tests/testdocs/testdoc.orig.md +0 -0
|
@@ -22,7 +22,7 @@ jobs:
|
|
|
22
22
|
|
|
23
23
|
# Common platforms: ["ubuntu-latest", "macos-latest", "windows-latest"]
|
|
24
24
|
os: ["ubuntu-latest"]
|
|
25
|
-
python-version: ["3.10","3.11", "3.12", "3.13"]
|
|
25
|
+
python-version: ["3.10","3.11", "3.12", "3.13", "3.14"]
|
|
26
26
|
|
|
27
27
|
# Linux only by default. Use ${{ matrix.os }} for other OSes.
|
|
28
28
|
runs-on: ${{ matrix.os }}
|
|
@@ -41,7 +41,7 @@ jobs:
|
|
|
41
41
|
uses: astral-sh/setup-uv@v5
|
|
42
42
|
with:
|
|
43
43
|
# Update this as needed:
|
|
44
|
-
version: "0.
|
|
44
|
+
version: "0.9.5"
|
|
45
45
|
enable-cache: true
|
|
46
46
|
python-version: ${{ matrix.python-version }}
|
|
47
47
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: flowmark
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.4
|
|
4
4
|
Summary: Better auto-formatting for Markdown and plaintext
|
|
5
5
|
Project-URL: Repository, https://github.com/jlevy/flowmark
|
|
6
6
|
Author-email: Joshua Levy <joshua@cal.berkeley.edu>
|
|
@@ -11,9 +11,11 @@ Classifier: Intended Audience :: Developers
|
|
|
11
11
|
Classifier: Operating System :: OS Independent
|
|
12
12
|
Classifier: Programming Language :: Python
|
|
13
13
|
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
14
15
|
Classifier: Programming Language :: Python :: 3.11
|
|
15
16
|
Classifier: Programming Language :: Python :: 3.12
|
|
16
17
|
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
17
19
|
Classifier: Typing :: Typed
|
|
18
20
|
Requires-Python: <4.0,>=3.10
|
|
19
21
|
Requires-Dist: marko>=2.1.3
|
|
@@ -26,9 +26,11 @@ classifiers = [
|
|
|
26
26
|
"Operating System :: OS Independent",
|
|
27
27
|
"Programming Language :: Python",
|
|
28
28
|
"Programming Language :: Python :: 3",
|
|
29
|
+
"Programming Language :: Python :: 3.10",
|
|
29
30
|
"Programming Language :: Python :: 3.11",
|
|
30
31
|
"Programming Language :: Python :: 3.12",
|
|
31
32
|
"Programming Language :: Python :: 3.13",
|
|
33
|
+
"Programming Language :: Python :: 3.14",
|
|
32
34
|
"Typing :: Typed",
|
|
33
35
|
# Include this to avoid accidentally publishing to PyPI:
|
|
34
36
|
# "Private :: Do Not Upload",
|
|
@@ -49,7 +51,7 @@ dev = [
|
|
|
49
51
|
"ruff>=0.11.9",
|
|
50
52
|
"codespell>=2.4.1",
|
|
51
53
|
"rich>=14.0.0",
|
|
52
|
-
"basedpyright
|
|
54
|
+
"basedpyright==1.29.5", # TODO: Upgrade when Cursor supports it.
|
|
53
55
|
"funlog>=0.2.1",
|
|
54
56
|
]
|
|
55
57
|
|
|
@@ -78,7 +80,7 @@ source = "uv-dynamic-versioning"
|
|
|
78
80
|
[tool.uv-dynamic-versioning]
|
|
79
81
|
vcs = "git"
|
|
80
82
|
style = "pep440"
|
|
81
|
-
bump =
|
|
83
|
+
bump = true
|
|
82
84
|
|
|
83
85
|
[tool.hatch.build.targets.wheel]
|
|
84
86
|
# The source location for the package.
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
__all__ = (
|
|
2
|
+
"fill_text",
|
|
3
|
+
"fill_markdown",
|
|
4
|
+
"first_sentence",
|
|
5
|
+
"first_sentences",
|
|
6
|
+
"flowmark_markdown",
|
|
7
|
+
"html_md_word_splitter",
|
|
8
|
+
"simple_word_splitter",
|
|
9
|
+
"line_wrap_by_sentence",
|
|
10
|
+
"line_wrap_to_width",
|
|
11
|
+
"reformat_file",
|
|
12
|
+
"reformat_text",
|
|
13
|
+
"split_sentences_regex",
|
|
14
|
+
"wrap_paragraph",
|
|
15
|
+
"wrap_paragraph_lines",
|
|
16
|
+
"Wrap",
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
from flowmark.formats.flowmark_markdown import flowmark_markdown
|
|
20
|
+
from flowmark.linewrapping.line_wrappers import line_wrap_by_sentence, line_wrap_to_width
|
|
21
|
+
from flowmark.linewrapping.markdown_filling import fill_markdown
|
|
22
|
+
from flowmark.linewrapping.sentence_split_regex import (
|
|
23
|
+
first_sentence,
|
|
24
|
+
first_sentences,
|
|
25
|
+
split_sentences_regex,
|
|
26
|
+
)
|
|
27
|
+
from flowmark.linewrapping.text_filling import Wrap, fill_text
|
|
28
|
+
from flowmark.linewrapping.text_wrapping import (
|
|
29
|
+
html_md_word_splitter,
|
|
30
|
+
simple_word_splitter,
|
|
31
|
+
wrap_paragraph,
|
|
32
|
+
wrap_paragraph_lines,
|
|
33
|
+
)
|
|
34
|
+
from flowmark.reformat_api import reformat_file, reformat_text
|
|
@@ -19,6 +19,9 @@ Command-line usage examples:
|
|
|
19
19
|
# Format a Markdown file to stdout
|
|
20
20
|
flowmark README.md
|
|
21
21
|
|
|
22
|
+
# Format multiple Markdown files in-place
|
|
23
|
+
flowmark --inplace README.md CHANGELOG.md docs/*.md
|
|
24
|
+
|
|
22
25
|
# Format a Markdown file in-place without backups and all auto-formatting
|
|
23
26
|
# options enabled
|
|
24
27
|
flowmark --auto README.md
|
|
@@ -40,19 +43,21 @@ Command-line usage examples:
|
|
|
40
43
|
For more details, see: https://github.com/jlevy/flowmark
|
|
41
44
|
"""
|
|
42
45
|
|
|
46
|
+
from __future__ import annotations
|
|
47
|
+
|
|
43
48
|
import argparse
|
|
44
49
|
import importlib.metadata
|
|
45
50
|
import sys
|
|
46
51
|
from dataclasses import dataclass
|
|
47
52
|
|
|
48
|
-
from flowmark.reformat_api import
|
|
53
|
+
from flowmark.reformat_api import reformat_files
|
|
49
54
|
|
|
50
55
|
|
|
51
56
|
@dataclass
|
|
52
57
|
class Options:
|
|
53
58
|
"""Command-line options for the flowmark tool."""
|
|
54
59
|
|
|
55
|
-
|
|
60
|
+
files: list[str]
|
|
56
61
|
output: str
|
|
57
62
|
width: int
|
|
58
63
|
plaintext: bool
|
|
@@ -79,11 +84,11 @@ def _parse_args(args: list[str] | None = None) -> Options:
|
|
|
79
84
|
formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
80
85
|
)
|
|
81
86
|
parser.add_argument(
|
|
82
|
-
"
|
|
83
|
-
nargs="
|
|
87
|
+
"files",
|
|
88
|
+
nargs="*",
|
|
84
89
|
type=str,
|
|
85
|
-
default="-",
|
|
86
|
-
help="Input
|
|
90
|
+
default=["-"],
|
|
91
|
+
help="Input files (use '-' for stdin, multiple files supported)",
|
|
87
92
|
)
|
|
88
93
|
parser.add_argument(
|
|
89
94
|
"-o",
|
|
@@ -161,7 +166,7 @@ def _parse_args(args: list[str] | None = None) -> Options:
|
|
|
161
166
|
opts.ellipses = True
|
|
162
167
|
|
|
163
168
|
return Options(
|
|
164
|
-
|
|
169
|
+
files=opts.files,
|
|
165
170
|
output=opts.output,
|
|
166
171
|
width=opts.width,
|
|
167
172
|
plaintext=opts.plaintext,
|
|
@@ -197,8 +202,8 @@ def main(args: list[str] | None = None) -> int:
|
|
|
197
202
|
return 0
|
|
198
203
|
|
|
199
204
|
try:
|
|
200
|
-
|
|
201
|
-
|
|
205
|
+
reformat_files(
|
|
206
|
+
files=options.files,
|
|
202
207
|
output=options.output,
|
|
203
208
|
width=options.width,
|
|
204
209
|
inplace=options.inplace,
|
|
@@ -14,7 +14,12 @@ from marko.parser import Parser
|
|
|
14
14
|
from marko.source import Source
|
|
15
15
|
from typing_extensions import override
|
|
16
16
|
|
|
17
|
-
from flowmark.line_wrappers import
|
|
17
|
+
from flowmark.linewrapping.line_wrappers import (
|
|
18
|
+
LineWrapper,
|
|
19
|
+
line_wrap_by_sentence,
|
|
20
|
+
line_wrap_to_width,
|
|
21
|
+
)
|
|
22
|
+
from flowmark.linewrapping.text_filling import DEFAULT_WRAP_WIDTH
|
|
18
23
|
|
|
19
24
|
|
|
20
25
|
def _normalize_title_quotes(title: str) -> str:
|
|
@@ -327,17 +332,32 @@ class MarkdownNormalizer(Renderer):
|
|
|
327
332
|
return element.dest
|
|
328
333
|
|
|
329
334
|
|
|
330
|
-
|
|
335
|
+
DEFAULT_SEMANTIC_LINE_WRAPPER = line_wrap_by_sentence(width=DEFAULT_WRAP_WIDTH, is_markdown=True)
|
|
336
|
+
"""
|
|
337
|
+
Default line wrapper for semantic line wrapping.
|
|
338
|
+
"""
|
|
339
|
+
|
|
340
|
+
DEFAULT_FIXED_LINE_WRAPPER = line_wrap_to_width(width=DEFAULT_WRAP_WIDTH, is_markdown=True)
|
|
341
|
+
"""
|
|
342
|
+
Default line wrapper for fixed-width line wrapping.
|
|
343
|
+
"""
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
def flowmark_markdown(line_wrapper: LineWrapper = DEFAULT_SEMANTIC_LINE_WRAPPER) -> Markdown:
|
|
331
347
|
"""
|
|
332
|
-
Marko Markdown setup for GFM with
|
|
333
|
-
renderer that normalizes Markdown.
|
|
348
|
+
Marko Markdown setup for GFM with a few customizations for Flowmark and a new
|
|
349
|
+
renderer that normalizes Markdown according to Flowmark's conventions.
|
|
334
350
|
"""
|
|
335
351
|
|
|
336
352
|
class CustomRenderer(MarkdownNormalizer):
|
|
337
353
|
def __init__(self) -> None:
|
|
338
354
|
super().__init__(line_wrapper)
|
|
339
355
|
|
|
340
|
-
class
|
|
356
|
+
class FlowmarkMarkdown(Markdown):
|
|
357
|
+
"""
|
|
358
|
+
Marko Markdown API with Flowmark customizations.
|
|
359
|
+
"""
|
|
360
|
+
|
|
341
361
|
def __init__(self) -> None: # pyright: ignore[reportMissingSuperCall]
|
|
342
362
|
pass
|
|
343
363
|
|
|
@@ -364,4 +384,4 @@ def custom_marko(line_wrapper: LineWrapper) -> Markdown:
|
|
|
364
384
|
|
|
365
385
|
self._setup_done: bool = True
|
|
366
386
|
|
|
367
|
-
return
|
|
387
|
+
return FlowmarkMarkdown()
|
|
@@ -2,9 +2,13 @@ import re
|
|
|
2
2
|
from collections.abc import Callable
|
|
3
3
|
from typing import Protocol
|
|
4
4
|
|
|
5
|
-
from flowmark.sentence_split_regex import split_sentences_regex
|
|
6
|
-
from flowmark.text_filling import DEFAULT_WRAP_WIDTH
|
|
7
|
-
from flowmark.text_wrapping import
|
|
5
|
+
from flowmark.linewrapping.sentence_split_regex import split_sentences_regex
|
|
6
|
+
from flowmark.linewrapping.text_filling import DEFAULT_WRAP_WIDTH
|
|
7
|
+
from flowmark.linewrapping.text_wrapping import (
|
|
8
|
+
DEFAULT_LEN_FUNCTION,
|
|
9
|
+
wrap_paragraph,
|
|
10
|
+
wrap_paragraph_lines,
|
|
11
|
+
)
|
|
8
12
|
|
|
9
13
|
DEFAULT_MIN_LINE_LEN = 20
|
|
10
14
|
"""Default minimum line length for sentence breaking."""
|
{flowmark-0.5.2/src/flowmark → flowmark-0.5.4/src/flowmark/linewrapping}/markdown_filling.py
RENAMED
|
@@ -15,15 +15,19 @@ import re
|
|
|
15
15
|
from collections.abc import Callable
|
|
16
16
|
from textwrap import dedent
|
|
17
17
|
|
|
18
|
-
from flowmark.
|
|
19
|
-
from flowmark.
|
|
20
|
-
from flowmark.
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
from flowmark.
|
|
26
|
-
from flowmark.text_filling import DEFAULT_WRAP_WIDTH
|
|
18
|
+
from flowmark.formats.flowmark_markdown import flowmark_markdown
|
|
19
|
+
from flowmark.formats.frontmatter import split_frontmatter
|
|
20
|
+
from flowmark.linewrapping.line_wrappers import (
|
|
21
|
+
LineWrapper,
|
|
22
|
+
line_wrap_by_sentence,
|
|
23
|
+
line_wrap_to_width,
|
|
24
|
+
)
|
|
25
|
+
from flowmark.linewrapping.sentence_split_regex import split_sentences_regex
|
|
26
|
+
from flowmark.linewrapping.text_filling import DEFAULT_WRAP_WIDTH
|
|
27
|
+
from flowmark.transforms.doc_cleanups import doc_cleanups
|
|
28
|
+
from flowmark.transforms.doc_transforms import rewrite_text_content
|
|
29
|
+
from flowmark.typography.ellipses import ellipses as apply_ellipses
|
|
30
|
+
from flowmark.typography.smartquotes import smart_quotes
|
|
27
31
|
|
|
28
32
|
|
|
29
33
|
def _normalize_html_comments(text: str, break_str: str = "\n\n") -> str:
|
|
@@ -126,7 +130,7 @@ def fill_markdown(
|
|
|
126
130
|
markdown_text = _normalize_html_comments(markdown_text)
|
|
127
131
|
|
|
128
132
|
# Parse and render.
|
|
129
|
-
marko =
|
|
133
|
+
marko = flowmark_markdown(line_wrapper)
|
|
130
134
|
document = marko.parse(markdown_text)
|
|
131
135
|
if cleanups:
|
|
132
136
|
doc_cleanups(document)
|
|
@@ -3,9 +3,9 @@ from pathlib import Path
|
|
|
3
3
|
|
|
4
4
|
from strif import atomic_output_file
|
|
5
5
|
|
|
6
|
-
from flowmark.markdown_filling import fill_markdown
|
|
7
|
-
from flowmark.text_filling import Wrap, fill_text
|
|
8
|
-
from flowmark.text_wrapping import html_md_word_splitter
|
|
6
|
+
from flowmark.linewrapping.markdown_filling import fill_markdown
|
|
7
|
+
from flowmark.linewrapping.text_filling import Wrap, fill_text
|
|
8
|
+
from flowmark.linewrapping.text_wrapping import html_md_word_splitter
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
def reformat_text(
|
|
@@ -102,3 +102,77 @@ def reformat_file(
|
|
|
102
102
|
else:
|
|
103
103
|
with atomic_output_file(output, make_parents=make_parents) as tmp_path:
|
|
104
104
|
tmp_path.write_text(result)
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def reformat_files(
|
|
108
|
+
files: list[str],
|
|
109
|
+
output: str | None = None,
|
|
110
|
+
width: int = 88,
|
|
111
|
+
inplace: bool = False,
|
|
112
|
+
nobackup: bool = False,
|
|
113
|
+
plaintext: bool = False,
|
|
114
|
+
semantic: bool = False,
|
|
115
|
+
cleanups: bool = True,
|
|
116
|
+
smartquotes: bool = False,
|
|
117
|
+
ellipses: bool = False,
|
|
118
|
+
make_parents: bool = True,
|
|
119
|
+
) -> None:
|
|
120
|
+
"""
|
|
121
|
+
Reformat multiple files with the same options.
|
|
122
|
+
|
|
123
|
+
Args:
|
|
124
|
+
files: List of file paths to process, or ["-"] for stdin.
|
|
125
|
+
output: Output file path (ignored when inplace=True, use "-" for stdout).
|
|
126
|
+
width: The width to wrap lines to.
|
|
127
|
+
inplace: Whether to write files back to their original paths.
|
|
128
|
+
nobackup: Whether to not make backups of original files.
|
|
129
|
+
plaintext: Use plaintext instead of Markdown mode wrapping.
|
|
130
|
+
semantic: Use semantic line breaks (based on sentences) heuristic.
|
|
131
|
+
cleanups: Enable (safe) cleanups for common issues.
|
|
132
|
+
smartquotes: Convert straight quotes to typographic quotes.
|
|
133
|
+
ellipses: Convert three dots to ellipsis character.
|
|
134
|
+
make_parents: Whether to make parent directories if they don't exist.
|
|
135
|
+
"""
|
|
136
|
+
if len(files) == 1 and files[0] == "-":
|
|
137
|
+
# Single stdin case - use original function
|
|
138
|
+
reformat_file(
|
|
139
|
+
path=files[0],
|
|
140
|
+
output=output,
|
|
141
|
+
width=width,
|
|
142
|
+
inplace=inplace,
|
|
143
|
+
nobackup=nobackup,
|
|
144
|
+
plaintext=plaintext,
|
|
145
|
+
semantic=semantic,
|
|
146
|
+
cleanups=cleanups,
|
|
147
|
+
smartquotes=smartquotes,
|
|
148
|
+
ellipses=ellipses,
|
|
149
|
+
make_parents=make_parents,
|
|
150
|
+
)
|
|
151
|
+
return
|
|
152
|
+
|
|
153
|
+
# Multiple files case
|
|
154
|
+
if not inplace and output and output != "-":
|
|
155
|
+
raise ValueError(
|
|
156
|
+
"Cannot specify output file when processing multiple files (use --inplace instead)"
|
|
157
|
+
)
|
|
158
|
+
|
|
159
|
+
for file_path in files:
|
|
160
|
+
if inplace:
|
|
161
|
+
# Process each file in-place
|
|
162
|
+
output = None
|
|
163
|
+
else:
|
|
164
|
+
# Process each file to stdout
|
|
165
|
+
output = "-"
|
|
166
|
+
reformat_file(
|
|
167
|
+
path=file_path,
|
|
168
|
+
output=output,
|
|
169
|
+
width=width,
|
|
170
|
+
inplace=inplace,
|
|
171
|
+
nobackup=nobackup,
|
|
172
|
+
plaintext=plaintext,
|
|
173
|
+
semantic=semantic,
|
|
174
|
+
cleanups=cleanups,
|
|
175
|
+
smartquotes=smartquotes,
|
|
176
|
+
ellipses=ellipses,
|
|
177
|
+
make_parents=make_parents,
|
|
178
|
+
)
|
|
@@ -4,7 +4,7 @@ from marko import block, inline
|
|
|
4
4
|
from marko.block import Document
|
|
5
5
|
from marko.element import Element
|
|
6
6
|
|
|
7
|
-
from flowmark.doc_transforms import transform_tree
|
|
7
|
+
from flowmark.transforms.doc_transforms import transform_tree
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
def _unbold_heading_transformer(element: Element) -> None:
|
|
@@ -45,7 +45,7 @@ def coalesce_raw_text_nodes(doc: Document) -> None:
|
|
|
45
45
|
This is useful for smart quotes processing which needs to see text that spans
|
|
46
46
|
across line breaks as a single unit.
|
|
47
47
|
"""
|
|
48
|
-
from flowmark.doc_transforms import transform_tree
|
|
48
|
+
from flowmark.transforms.doc_transforms import transform_tree
|
|
49
49
|
|
|
50
50
|
def transformer(element: Element) -> None:
|
|
51
51
|
if hasattr(element, "children") and isinstance(element.children, list): # pyright: ignore
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
from flowmark.
|
|
2
|
-
from flowmark.
|
|
3
|
-
from flowmark.
|
|
1
|
+
from flowmark.formats.flowmark_markdown import flowmark_markdown
|
|
2
|
+
from flowmark.linewrapping.line_wrappers import line_wrap_by_sentence
|
|
3
|
+
from flowmark.transforms.doc_cleanups import unbold_headings
|
|
4
4
|
|
|
5
5
|
input_md = """
|
|
6
6
|
# **Bold Heading 1**
|
|
@@ -53,7 +53,7 @@ Final text.
|
|
|
53
53
|
|
|
54
54
|
|
|
55
55
|
def test_unbold_headings() -> None:
|
|
56
|
-
marko =
|
|
56
|
+
marko = flowmark_markdown(line_wrap_by_sentence())
|
|
57
57
|
|
|
58
58
|
doc = marko.parse(input_md)
|
|
59
59
|
unbold_headings(doc)
|
|
@@ -2,7 +2,10 @@ from textwrap import dedent
|
|
|
2
2
|
|
|
3
3
|
import marko
|
|
4
4
|
|
|
5
|
-
from flowmark.markdown_filling import
|
|
5
|
+
from flowmark.linewrapping.markdown_filling import (
|
|
6
|
+
_normalize_html_comments, # pyright: ignore[reportPrivateUsage]
|
|
7
|
+
fill_markdown,
|
|
8
|
+
)
|
|
6
9
|
|
|
7
10
|
|
|
8
11
|
def test_normalize_html_comments():
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
from flowmark.frontmatter import has_frontmatter, split_frontmatter
|
|
2
|
-
from flowmark.markdown_filling import fill_markdown
|
|
1
|
+
from flowmark.formats.frontmatter import has_frontmatter, split_frontmatter
|
|
2
|
+
from flowmark.linewrapping.markdown_filling import fill_markdown
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
def test_split_frontmatter():
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from textwrap import dedent
|
|
2
2
|
|
|
3
|
-
from flowmark.text_wrapping import (
|
|
3
|
+
from flowmark.linewrapping.text_wrapping import (
|
|
4
4
|
_HtmlMdWordSplitter, # pyright: ignore
|
|
5
5
|
html_md_word_splitter,
|
|
6
6
|
markdown_escape_word,
|
|
@@ -224,7 +224,7 @@ def test_wrap_width():
|
|
|
224
224
|
|
|
225
225
|
|
|
226
226
|
def test_line_wrap_to_width_with_markdown_breaks():
|
|
227
|
-
from flowmark.line_wrappers import line_wrap_to_width
|
|
227
|
+
from flowmark.linewrapping.line_wrappers import line_wrap_to_width
|
|
228
228
|
|
|
229
229
|
# Get a markdown-aware line wrapper
|
|
230
230
|
wrapper = line_wrap_to_width(width=80, is_markdown=True)
|