flowmark 0.5.2__tar.gz → 0.5.3__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.3}/.copier-answers.yml +1 -1
- {flowmark-0.5.2 → flowmark-0.5.3}/.github/workflows/ci.yml +1 -1
- {flowmark-0.5.2 → flowmark-0.5.3}/.github/workflows/publish.yml +1 -1
- {flowmark-0.5.2 → flowmark-0.5.3}/PKG-INFO +1 -1
- {flowmark-0.5.2 → flowmark-0.5.3}/pyproject.toml +1 -1
- flowmark-0.5.3/src/flowmark/__init__.py +34 -0
- flowmark-0.5.2/src/flowmark/custom_marko.py → flowmark-0.5.3/src/flowmark/formats/flowmark_markdown.py +10 -6
- {flowmark-0.5.2/src/flowmark → flowmark-0.5.3/src/flowmark/linewrapping}/line_wrappers.py +7 -3
- {flowmark-0.5.2/src/flowmark → flowmark-0.5.3/src/flowmark/linewrapping}/markdown_filling.py +14 -10
- {flowmark-0.5.2/src/flowmark → flowmark-0.5.3/src/flowmark/linewrapping}/text_filling.py +1 -1
- {flowmark-0.5.2 → flowmark-0.5.3}/src/flowmark/reformat_api.py +3 -3
- {flowmark-0.5.2/src/flowmark → flowmark-0.5.3/src/flowmark/transforms}/doc_cleanups.py +1 -1
- {flowmark-0.5.2/src/flowmark → flowmark-0.5.3/src/flowmark/transforms}/doc_transforms.py +1 -1
- {flowmark-0.5.2 → flowmark-0.5.3}/tests/test_cleanups.py +4 -4
- {flowmark-0.5.2 → flowmark-0.5.3}/tests/test_ellipses.py +1 -1
- {flowmark-0.5.2 → flowmark-0.5.3}/tests/test_filling.py +4 -1
- {flowmark-0.5.2 → flowmark-0.5.3}/tests/test_frontmatter.py +2 -2
- {flowmark-0.5.2 → flowmark-0.5.3}/tests/test_list_spacing.py +1 -1
- {flowmark-0.5.2 → flowmark-0.5.3}/tests/test_ref_docs.py +1 -1
- {flowmark-0.5.2 → flowmark-0.5.3}/tests/test_smartquotes.py +1 -1
- {flowmark-0.5.2 → flowmark-0.5.3}/tests/test_wrapping.py +2 -2
- flowmark-0.5.3/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.3}/.cursor/rules/flowmark.mdc +0 -0
- {flowmark-0.5.2 → flowmark-0.5.3}/.cursor/rules/general.mdc +0 -0
- {flowmark-0.5.2 → flowmark-0.5.3}/.cursor/rules/python.mdc +0 -0
- {flowmark-0.5.2 → flowmark-0.5.3}/.gitignore +0 -0
- {flowmark-0.5.2 → flowmark-0.5.3}/.vscode/settings.json +0 -0
- {flowmark-0.5.2 → flowmark-0.5.3}/LICENSE +0 -0
- {flowmark-0.5.2 → flowmark-0.5.3}/Makefile +0 -0
- {flowmark-0.5.2 → flowmark-0.5.3}/README.md +0 -0
- {flowmark-0.5.2 → flowmark-0.5.3}/development.md +0 -0
- {flowmark-0.5.2 → flowmark-0.5.3}/devtools/lint.py +0 -0
- {flowmark-0.5.2 → flowmark-0.5.3}/installation.md +0 -0
- {flowmark-0.5.2 → flowmark-0.5.3}/poetry.lock +0 -0
- {flowmark-0.5.2 → flowmark-0.5.3}/publishing.md +0 -0
- {flowmark-0.5.2 → flowmark-0.5.3}/src/flowmark/cli.py +0 -0
- {flowmark-0.5.2/src/flowmark → flowmark-0.5.3/src/flowmark/formats}/frontmatter.py +0 -0
- {flowmark-0.5.2/src/flowmark → flowmark-0.5.3/src/flowmark/linewrapping}/sentence_split_regex.py +0 -0
- {flowmark-0.5.2/src/flowmark → flowmark-0.5.3/src/flowmark/linewrapping}/text_wrapping.py +0 -0
- {flowmark-0.5.2 → flowmark-0.5.3}/src/flowmark/py.typed +0 -0
- {flowmark-0.5.2/src/flowmark → flowmark-0.5.3/src/flowmark/typography}/ellipses.py +0 -0
- {flowmark-0.5.2/src/flowmark → flowmark-0.5.3/src/flowmark/typography}/smartquotes.py +0 -0
- {flowmark-0.5.2 → flowmark-0.5.3}/tests/test_sentences.py +0 -0
- {flowmark-0.5.2 → flowmark-0.5.3}/tests/test_width_options.py +0 -0
- {flowmark-0.5.2 → flowmark-0.5.3}/tests/testdocs/.gitignore +0 -0
- {flowmark-0.5.2 → flowmark-0.5.3}/tests/testdocs/testdoc.expected.auto.md +0 -0
- {flowmark-0.5.2 → flowmark-0.5.3}/tests/testdocs/testdoc.expected.cleaned.md +0 -0
- {flowmark-0.5.2 → flowmark-0.5.3}/tests/testdocs/testdoc.expected.plain.md +0 -0
- {flowmark-0.5.2 → flowmark-0.5.3}/tests/testdocs/testdoc.expected.semantic.md +0 -0
- {flowmark-0.5.2 → flowmark-0.5.3}/tests/testdocs/testdoc.orig.md +0 -0
|
@@ -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
|
|
@@ -14,7 +14,7 @@ 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 LineWrapper
|
|
17
|
+
from flowmark.linewrapping.line_wrappers import LineWrapper
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
def _normalize_title_quotes(title: str) -> str:
|
|
@@ -327,17 +327,21 @@ class MarkdownNormalizer(Renderer):
|
|
|
327
327
|
return element.dest
|
|
328
328
|
|
|
329
329
|
|
|
330
|
-
def
|
|
330
|
+
def flowmark_markdown(line_wrapper: LineWrapper) -> Markdown:
|
|
331
331
|
"""
|
|
332
|
-
Marko Markdown setup for GFM with
|
|
333
|
-
renderer that normalizes Markdown.
|
|
332
|
+
Marko Markdown setup for GFM with a few customizations for Flowmark and a new
|
|
333
|
+
renderer that normalizes Markdown according to Flowmark's conventions.
|
|
334
334
|
"""
|
|
335
335
|
|
|
336
336
|
class CustomRenderer(MarkdownNormalizer):
|
|
337
337
|
def __init__(self) -> None:
|
|
338
338
|
super().__init__(line_wrapper)
|
|
339
339
|
|
|
340
|
-
class
|
|
340
|
+
class FlowmarkMarkdown(Markdown):
|
|
341
|
+
"""
|
|
342
|
+
Marko Markdown API with Flowmark customizations.
|
|
343
|
+
"""
|
|
344
|
+
|
|
341
345
|
def __init__(self) -> None: # pyright: ignore[reportMissingSuperCall]
|
|
342
346
|
pass
|
|
343
347
|
|
|
@@ -364,4 +368,4 @@ def custom_marko(line_wrapper: LineWrapper) -> Markdown:
|
|
|
364
368
|
|
|
365
369
|
self._setup_done: bool = True
|
|
366
370
|
|
|
367
|
-
return
|
|
371
|
+
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.3/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(
|
|
@@ -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)
|