flowmark 0.3.0__tar.gz → 0.3.1__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.3.1/.copier-answers.yml +9 -0
- flowmark-0.3.1/.github/workflows/ci.yml +63 -0
- flowmark-0.3.1/.github/workflows/publish.yml +38 -0
- flowmark-0.3.1/.gitignore +176 -0
- flowmark-0.3.1/Makefile +32 -0
- {flowmark-0.3.0 → flowmark-0.3.1}/PKG-INFO +72 -61
- {flowmark-0.3.0 → flowmark-0.3.1}/README.md +62 -45
- flowmark-0.3.1/development.md +64 -0
- flowmark-0.3.1/devtools/lint.py +45 -0
- flowmark-0.3.1/poetry.lock +778 -0
- flowmark-0.3.1/pyproject.toml +88 -0
- {flowmark-0.3.0 → flowmark-0.3.1}/src/flowmark/cli.py +17 -0
- flowmark-0.3.1/tests/__init__.py +0 -0
- flowmark-0.3.1/tests/test_filling.py +286 -0
- flowmark-0.3.1/tests/test_frontmatter.py +72 -0
- flowmark-0.3.1/tests/test_ref_docs.py +41 -0
- flowmark-0.3.1/tests/test_wrapping.py +130 -0
- flowmark-0.3.1/tests/testdocs/testdoc.orig.md +593 -0
- flowmark-0.3.1/tests/testdocs/testdoc.out.plain.md +877 -0
- flowmark-0.3.1/tests/testdocs/testdoc.out.semantic.md +918 -0
- flowmark-0.3.1/uv.lock +579 -0
- flowmark-0.3.0/pyproject.toml +0 -102
- {flowmark-0.3.0 → flowmark-0.3.1}/LICENSE +0 -0
- {flowmark-0.3.0 → flowmark-0.3.1}/src/flowmark/__init__.py +0 -0
- {flowmark-0.3.0 → flowmark-0.3.1}/src/flowmark/frontmatter.py +0 -0
- {flowmark-0.3.0 → flowmark-0.3.1}/src/flowmark/line_wrappers.py +0 -0
- {flowmark-0.3.0 → flowmark-0.3.1}/src/flowmark/markdown_filling.py +0 -0
- {flowmark-0.3.0 → flowmark-0.3.1}/src/flowmark/sentence_split_regex.py +0 -0
- {flowmark-0.3.0 → flowmark-0.3.1}/src/flowmark/text_filling.py +0 -0
- {flowmark-0.3.0 → flowmark-0.3.1}/src/flowmark/text_wrapping.py +0 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Changes here will be overwritten by Copier. Do not edit manually.
|
|
2
|
+
_commit: 1742e95
|
|
3
|
+
_src_path: gh:jlevy/simple-modern-uv
|
|
4
|
+
package_author_email: joshua@cal.berkeley.edu
|
|
5
|
+
package_author_name: Joshua Levy
|
|
6
|
+
package_description: Better line wrapping and formatting for plaintext and Markdown
|
|
7
|
+
package_github_org: jlevy
|
|
8
|
+
package_name: flowmark
|
|
9
|
+
package_slug: flowmark
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# This workflow will install Python dependencies, run tests and lint with a single version of Python
|
|
2
|
+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
|
|
3
|
+
|
|
4
|
+
name: CI
|
|
5
|
+
|
|
6
|
+
on:
|
|
7
|
+
push:
|
|
8
|
+
# Use ["main", "master"] for CI only on the default branch.
|
|
9
|
+
# Use ["**"] for CI on all branches.
|
|
10
|
+
branches: ["main", "master"]
|
|
11
|
+
pull_request:
|
|
12
|
+
branches: ["main", "master"]
|
|
13
|
+
|
|
14
|
+
permissions:
|
|
15
|
+
contents: read
|
|
16
|
+
|
|
17
|
+
jobs:
|
|
18
|
+
build:
|
|
19
|
+
strategy:
|
|
20
|
+
matrix:
|
|
21
|
+
# Update this as needed:
|
|
22
|
+
|
|
23
|
+
# Common platforms: ["ubuntu-latest", "macos-latest", "windows-latest"]
|
|
24
|
+
os: ["ubuntu-latest"]
|
|
25
|
+
python-version: ["3.10","3.11", "3.12", "3.13"]
|
|
26
|
+
|
|
27
|
+
# Linux only by default. Use ${{ matrix.os }} for other OSes.
|
|
28
|
+
runs-on: ${{ matrix.os }}
|
|
29
|
+
|
|
30
|
+
steps:
|
|
31
|
+
# Generally following uv docs:
|
|
32
|
+
# https://docs.astral.sh/uv/guides/integration/github/
|
|
33
|
+
|
|
34
|
+
- name: Checkout (official GitHub action)
|
|
35
|
+
uses: actions/checkout@v4
|
|
36
|
+
with:
|
|
37
|
+
# Important for versioning plugins:
|
|
38
|
+
fetch-depth: 0
|
|
39
|
+
|
|
40
|
+
- name: Install uv (official Astral action)
|
|
41
|
+
uses: astral-sh/setup-uv@v5
|
|
42
|
+
with:
|
|
43
|
+
version: "0.6.5"
|
|
44
|
+
enable-cache: true
|
|
45
|
+
python-version: ${{ matrix.python-version }}
|
|
46
|
+
|
|
47
|
+
- name: Set up Python (using uv)
|
|
48
|
+
run: uv python install
|
|
49
|
+
|
|
50
|
+
# Alternately can use the official Python action:
|
|
51
|
+
# - name: Set up Python (using actions/setup-python)
|
|
52
|
+
# uses: actions/setup-python@v5
|
|
53
|
+
# with:
|
|
54
|
+
# python-version: ${{ matrix.python-version }}
|
|
55
|
+
|
|
56
|
+
- name: Install all dependencies
|
|
57
|
+
run: uv sync --all-extras --dev
|
|
58
|
+
|
|
59
|
+
- name: Run linting
|
|
60
|
+
run: uv run python devtools/lint.py
|
|
61
|
+
|
|
62
|
+
- name: Run tests
|
|
63
|
+
run: uv run pytest
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
workflow_dispatch: # Enable manual trigger.
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
build-and-publish:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
permissions:
|
|
12
|
+
id-token: write # Mandatory for OIDC.
|
|
13
|
+
contents: read
|
|
14
|
+
steps:
|
|
15
|
+
- name: Checkout (official GitHub action)
|
|
16
|
+
uses: actions/checkout@v4
|
|
17
|
+
with:
|
|
18
|
+
# Important for versioning plugins:
|
|
19
|
+
fetch-depth: 0
|
|
20
|
+
|
|
21
|
+
- name: Install uv (official Astral action)
|
|
22
|
+
uses: astral-sh/setup-uv@v5
|
|
23
|
+
with:
|
|
24
|
+
version: "0.6.5"
|
|
25
|
+
enable-cache: true
|
|
26
|
+
python-version: "3.12"
|
|
27
|
+
|
|
28
|
+
- name: Set up Python (using uv)
|
|
29
|
+
run: uv python install
|
|
30
|
+
|
|
31
|
+
- name: Install all dependencies
|
|
32
|
+
run: uv sync --all-extras --dev
|
|
33
|
+
|
|
34
|
+
- name: Build package
|
|
35
|
+
run: uv build
|
|
36
|
+
|
|
37
|
+
- name: Publish to PyPI (using uv)
|
|
38
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
# Additions to standard GitHub .gitignore:
|
|
2
|
+
tmp/
|
|
3
|
+
trash/
|
|
4
|
+
.kmd/
|
|
5
|
+
|
|
6
|
+
# Byte-compiled / optimized / DLL files
|
|
7
|
+
__pycache__/
|
|
8
|
+
*.py[cod]
|
|
9
|
+
*$py.class
|
|
10
|
+
|
|
11
|
+
# C extensions
|
|
12
|
+
*.so
|
|
13
|
+
|
|
14
|
+
# Distribution / packaging
|
|
15
|
+
.Python
|
|
16
|
+
build/
|
|
17
|
+
develop-eggs/
|
|
18
|
+
dist/
|
|
19
|
+
downloads/
|
|
20
|
+
eggs/
|
|
21
|
+
.eggs/
|
|
22
|
+
lib/
|
|
23
|
+
lib64/
|
|
24
|
+
parts/
|
|
25
|
+
sdist/
|
|
26
|
+
var/
|
|
27
|
+
wheels/
|
|
28
|
+
share/python-wheels/
|
|
29
|
+
*.egg-info/
|
|
30
|
+
.installed.cfg
|
|
31
|
+
*.egg
|
|
32
|
+
MANIFEST
|
|
33
|
+
|
|
34
|
+
# PyInstaller
|
|
35
|
+
# Usually these files are written by a python script from a template
|
|
36
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
37
|
+
*.manifest
|
|
38
|
+
*.spec
|
|
39
|
+
|
|
40
|
+
# Installer logs
|
|
41
|
+
pip-log.txt
|
|
42
|
+
pip-delete-this-directory.txt
|
|
43
|
+
|
|
44
|
+
# Unit test / coverage reports
|
|
45
|
+
htmlcov/
|
|
46
|
+
.tox/
|
|
47
|
+
.nox/
|
|
48
|
+
.coverage
|
|
49
|
+
.coverage.*
|
|
50
|
+
.cache
|
|
51
|
+
nosetests.xml
|
|
52
|
+
coverage.xml
|
|
53
|
+
*.cover
|
|
54
|
+
*.py,cover
|
|
55
|
+
.hypothesis/
|
|
56
|
+
.pytest_cache/
|
|
57
|
+
cover/
|
|
58
|
+
|
|
59
|
+
# Translations
|
|
60
|
+
*.mo
|
|
61
|
+
*.pot
|
|
62
|
+
|
|
63
|
+
# Django stuff:
|
|
64
|
+
*.log
|
|
65
|
+
local_settings.py
|
|
66
|
+
db.sqlite3
|
|
67
|
+
db.sqlite3-journal
|
|
68
|
+
|
|
69
|
+
# Flask stuff:
|
|
70
|
+
instance/
|
|
71
|
+
.webassets-cache
|
|
72
|
+
|
|
73
|
+
# Scrapy stuff:
|
|
74
|
+
.scrapy
|
|
75
|
+
|
|
76
|
+
# Sphinx documentation
|
|
77
|
+
docs/_build/
|
|
78
|
+
|
|
79
|
+
# PyBuilder
|
|
80
|
+
.pybuilder/
|
|
81
|
+
target/
|
|
82
|
+
|
|
83
|
+
# Jupyter Notebook
|
|
84
|
+
.ipynb_checkpoints
|
|
85
|
+
|
|
86
|
+
# IPython
|
|
87
|
+
profile_default/
|
|
88
|
+
ipython_config.py
|
|
89
|
+
|
|
90
|
+
# pyenv
|
|
91
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
92
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
93
|
+
# .python-version
|
|
94
|
+
|
|
95
|
+
# pipenv
|
|
96
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
97
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
98
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
99
|
+
# install all needed dependencies.
|
|
100
|
+
#Pipfile.lock
|
|
101
|
+
|
|
102
|
+
# UV
|
|
103
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
104
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
105
|
+
# commonly ignored for libraries.
|
|
106
|
+
#uv.lock
|
|
107
|
+
|
|
108
|
+
# poetry
|
|
109
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
110
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
111
|
+
# commonly ignored for libraries.
|
|
112
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
113
|
+
#poetry.lock
|
|
114
|
+
|
|
115
|
+
# pdm
|
|
116
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
117
|
+
#pdm.lock
|
|
118
|
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
|
119
|
+
# in version control.
|
|
120
|
+
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
|
|
121
|
+
.pdm.toml
|
|
122
|
+
.pdm-python
|
|
123
|
+
.pdm-build/
|
|
124
|
+
|
|
125
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
126
|
+
__pypackages__/
|
|
127
|
+
|
|
128
|
+
# Celery stuff
|
|
129
|
+
celerybeat-schedule
|
|
130
|
+
celerybeat.pid
|
|
131
|
+
|
|
132
|
+
# SageMath parsed files
|
|
133
|
+
*.sage.py
|
|
134
|
+
|
|
135
|
+
# Environments
|
|
136
|
+
.env
|
|
137
|
+
.venv
|
|
138
|
+
env/
|
|
139
|
+
venv/
|
|
140
|
+
ENV/
|
|
141
|
+
env.bak/
|
|
142
|
+
venv.bak/
|
|
143
|
+
|
|
144
|
+
# Spyder project settings
|
|
145
|
+
.spyderproject
|
|
146
|
+
.spyproject
|
|
147
|
+
|
|
148
|
+
# Rope project settings
|
|
149
|
+
.ropeproject
|
|
150
|
+
|
|
151
|
+
# mkdocs documentation
|
|
152
|
+
/site
|
|
153
|
+
|
|
154
|
+
# mypy
|
|
155
|
+
.mypy_cache/
|
|
156
|
+
.dmypy.json
|
|
157
|
+
dmypy.json
|
|
158
|
+
|
|
159
|
+
# Pyre type checker
|
|
160
|
+
.pyre/
|
|
161
|
+
|
|
162
|
+
# pytype static type analyzer
|
|
163
|
+
.pytype/
|
|
164
|
+
|
|
165
|
+
# Cython debug symbols
|
|
166
|
+
cython_debug/
|
|
167
|
+
|
|
168
|
+
# PyCharm
|
|
169
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
170
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
171
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
172
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
173
|
+
#.idea/
|
|
174
|
+
|
|
175
|
+
# PyPI configuration file
|
|
176
|
+
.pypirc
|
flowmark-0.3.1/Makefile
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Makefile for easy development workflows.
|
|
2
|
+
# GitHub Actions call uv directly.
|
|
3
|
+
|
|
4
|
+
.DEFAULT_GOAL := default
|
|
5
|
+
|
|
6
|
+
.PHONY: default install_deps lint test build clean gen_test_docs
|
|
7
|
+
|
|
8
|
+
default: install_deps lint test
|
|
9
|
+
|
|
10
|
+
install_deps:
|
|
11
|
+
uv sync --all-extras --dev
|
|
12
|
+
|
|
13
|
+
lint:
|
|
14
|
+
uv run python devtools/lint.py
|
|
15
|
+
|
|
16
|
+
test:
|
|
17
|
+
uv run pytest
|
|
18
|
+
|
|
19
|
+
build:
|
|
20
|
+
uv build
|
|
21
|
+
|
|
22
|
+
clean:
|
|
23
|
+
-rm -rf dist/
|
|
24
|
+
-rm -rf *.egg-info/
|
|
25
|
+
-rm -rf .pytest_cache/
|
|
26
|
+
-rm -rf .mypy_cache/
|
|
27
|
+
-rm -rf .venv/
|
|
28
|
+
-find . -type d -name "__pycache__" -exec rm -rf {} +
|
|
29
|
+
|
|
30
|
+
gen_test_docs:
|
|
31
|
+
poetry run flowmark tests/testdocs/testdoc.orig.md -o tests/testdocs/testdoc.out.plain.md
|
|
32
|
+
poetry run flowmark --semantic tests/testdocs/testdoc.orig.md -o tests/testdocs/testdoc.out.semantic.md
|
|
@@ -1,34 +1,72 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: flowmark
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.1
|
|
4
4
|
Summary: Better line wrapping and formatting for plaintext and Markdown
|
|
5
|
-
|
|
6
|
-
Author: Joshua Levy
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
15
|
-
Requires-Dist: marko (>=2.1.2,<3.0.0)
|
|
16
|
-
Requires-Dist: regex (>=2024.11.6,<2025.0.0)
|
|
17
|
-
Requires-Dist: strif (>=2.0.0,<3.0.0)
|
|
5
|
+
Project-URL: Repository, https://github.com//flowmark
|
|
6
|
+
Author-email: Joshua Levy <joshua@cal.berkeley.edu>
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Requires-Python: <4.0,>=3.10
|
|
10
|
+
Requires-Dist: marko>=2.1.2
|
|
11
|
+
Requires-Dist: regex>=2024.11.6
|
|
12
|
+
Requires-Dist: strif>=2.0.0
|
|
18
13
|
Description-Content-Type: text/markdown
|
|
19
14
|
|
|
20
15
|
# flowmark
|
|
21
16
|
|
|
22
17
|
Flowmark is a new Python implementation of **text and Markdown line wrapping and
|
|
23
|
-
filling
|
|
18
|
+
filling**, with an emphasis on making **git diffs** and **LLM edits** to text documents
|
|
19
|
+
easier to diff and review.
|
|
24
20
|
|
|
25
|
-
In addition, it adds
|
|
26
|
-
|
|
27
|
-
[markdownfmt](https://github.com/shurcooL/markdownfmt) or
|
|
21
|
+
In addition, it adds **support for Markdown** and offers **Markdown auto-formatting and
|
|
22
|
+
normalization** as a library or from the command line.
|
|
23
|
+
This is much like [markdownfmt](https://github.com/shurcooL/markdownfmt) or
|
|
28
24
|
[prettier's Markdown support](https://prettier.io/blog/2017/11/07/1.8.0) but is pure
|
|
29
25
|
Python and has (in my humble opinion) better options and defaults.
|
|
30
26
|
|
|
31
|
-
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
The simplest way to use the tool is to use [uv](https://github.com/astral-sh/uv):
|
|
30
|
+
|
|
31
|
+
```shell
|
|
32
|
+
uv tool install flowmark
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Or [pipx](https://github.com/pypa/pipx):
|
|
36
|
+
|
|
37
|
+
```shell
|
|
38
|
+
pipx install flowmark
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Then
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
flowmark --help
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
To use as a library, use pip/poetry/uv to install
|
|
48
|
+
[`flowmark`](https://pypi.org/project/flowmark/).
|
|
49
|
+
|
|
50
|
+
## Use in VSCode/Cursor
|
|
51
|
+
|
|
52
|
+
You can use Flowmark to auto-format Markdown on save in VSCode or Cursor.
|
|
53
|
+
Install the "Run on Save" (`emeraldwalk.runonsave`) extension.
|
|
54
|
+
Then add to your `settings.json`:
|
|
55
|
+
|
|
56
|
+
```json
|
|
57
|
+
"emeraldwalk.runonsave": {
|
|
58
|
+
"commands": [
|
|
59
|
+
{
|
|
60
|
+
"match": "\\.md$",
|
|
61
|
+
"cmd": "flowmark --auto ${file}"
|
|
62
|
+
}
|
|
63
|
+
]
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
The `--auto` option is just the same as `--inplace --nobackup --semantic`.
|
|
68
|
+
|
|
69
|
+
## Use Cases
|
|
32
70
|
|
|
33
71
|
- As a **command line formatter** to format text or Markdown files using the `flowmark`
|
|
34
72
|
command.
|
|
@@ -72,49 +110,23 @@ It aims to be small and simple and have only a few dependencies, currently only
|
|
|
72
110
|
Because **YAML frontmatter** is common on Markdown files, the Markdown autoformat
|
|
73
111
|
preserves all frontmatter (content between `---` delimiters at the front of a file).
|
|
74
112
|
|
|
75
|
-
|
|
76
|
-
Previously I'd implemented something very similar with
|
|
77
|
-
[for Atom](https://github.com/jlevy/atom-flowmark) but Atom is no more and there seems
|
|
78
|
-
to be greater need for this in Python now.
|
|
79
|
-
From many years experience, I found the Markdown formatting conventions enforced by the
|
|
80
|
-
Atom Flowmark plugin worked well for editing and publishing large or collaboratively
|
|
81
|
-
edited documents.
|
|
82
|
-
|
|
83
|
-
## Installation
|
|
84
|
-
|
|
85
|
-
The simplest way to use the tool is to use [pipx](https://github.com/pypa/pipx):
|
|
86
|
-
|
|
87
|
-
```shell
|
|
88
|
-
pipx install flowmark
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
Then
|
|
92
|
-
|
|
93
|
-
```
|
|
94
|
-
flowmark --help
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
To use as a library, use pip/poetry/uv to install
|
|
98
|
-
[`flowmark`](https://pypi.org/project/flowmark/).
|
|
113
|
+
## Why a New Markdown Formatter?
|
|
99
114
|
|
|
100
|
-
|
|
115
|
+
Previously I'd implemented something very similar with
|
|
116
|
+
[for Atom](https://github.com/jlevy/atom-flowmark).
|
|
117
|
+
I found the Markdown formatting conventions enforced by the that plugin worked really
|
|
118
|
+
well for editing and publishing large or collaboratively edited documents.
|
|
101
119
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
Then add to your `settings.json`:
|
|
120
|
+
This is new, pure Python implementation.
|
|
121
|
+
There are numerous needs for a tool like this on the command line and in Python.
|
|
105
122
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
{
|
|
110
|
-
"match": "\\.md$",
|
|
111
|
-
"cmd": "flowmark --auto ${file}"
|
|
112
|
-
}
|
|
113
|
-
]
|
|
114
|
-
}
|
|
115
|
-
```
|
|
123
|
+
With LLM tools now using Markdown everywhere, there are enormous advantages to having
|
|
124
|
+
very clean and well-formatted Markdown documents, since you can then cleanly see diffs
|
|
125
|
+
or edits made by LLMs.
|
|
116
126
|
|
|
117
|
-
|
|
127
|
+
If you are in a workspace where you are editing lots of text, having them all be
|
|
128
|
+
Markdown with frontmatter, auto-formatted for every git commit makes for a *much* better
|
|
129
|
+
experience.
|
|
118
130
|
|
|
119
131
|
## Usage
|
|
120
132
|
|
|
@@ -174,5 +186,4 @@ For more details, see: https://github.com/jlevy/flowmark
|
|
|
174
186
|
* * *
|
|
175
187
|
|
|
176
188
|
*This project was built from
|
|
177
|
-
[simple-modern-
|
|
178
|
-
|
|
189
|
+
[simple-modern-uv](https://github.com/jlevy/simple-modern-uv).*
|
|
@@ -1,15 +1,58 @@
|
|
|
1
1
|
# flowmark
|
|
2
2
|
|
|
3
3
|
Flowmark is a new Python implementation of **text and Markdown line wrapping and
|
|
4
|
-
filling
|
|
4
|
+
filling**, with an emphasis on making **git diffs** and **LLM edits** to text documents
|
|
5
|
+
easier to diff and review.
|
|
5
6
|
|
|
6
|
-
In addition, it adds
|
|
7
|
-
|
|
8
|
-
[markdownfmt](https://github.com/shurcooL/markdownfmt) or
|
|
7
|
+
In addition, it adds **support for Markdown** and offers **Markdown auto-formatting and
|
|
8
|
+
normalization** as a library or from the command line.
|
|
9
|
+
This is much like [markdownfmt](https://github.com/shurcooL/markdownfmt) or
|
|
9
10
|
[prettier's Markdown support](https://prettier.io/blog/2017/11/07/1.8.0) but is pure
|
|
10
11
|
Python and has (in my humble opinion) better options and defaults.
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
The simplest way to use the tool is to use [uv](https://github.com/astral-sh/uv):
|
|
16
|
+
|
|
17
|
+
```shell
|
|
18
|
+
uv tool install flowmark
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Or [pipx](https://github.com/pypa/pipx):
|
|
22
|
+
|
|
23
|
+
```shell
|
|
24
|
+
pipx install flowmark
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Then
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
flowmark --help
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
To use as a library, use pip/poetry/uv to install
|
|
34
|
+
[`flowmark`](https://pypi.org/project/flowmark/).
|
|
35
|
+
|
|
36
|
+
## Use in VSCode/Cursor
|
|
37
|
+
|
|
38
|
+
You can use Flowmark to auto-format Markdown on save in VSCode or Cursor.
|
|
39
|
+
Install the "Run on Save" (`emeraldwalk.runonsave`) extension.
|
|
40
|
+
Then add to your `settings.json`:
|
|
41
|
+
|
|
42
|
+
```json
|
|
43
|
+
"emeraldwalk.runonsave": {
|
|
44
|
+
"commands": [
|
|
45
|
+
{
|
|
46
|
+
"match": "\\.md$",
|
|
47
|
+
"cmd": "flowmark --auto ${file}"
|
|
48
|
+
}
|
|
49
|
+
]
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
The `--auto` option is just the same as `--inplace --nobackup --semantic`.
|
|
54
|
+
|
|
55
|
+
## Use Cases
|
|
13
56
|
|
|
14
57
|
- As a **command line formatter** to format text or Markdown files using the `flowmark`
|
|
15
58
|
command.
|
|
@@ -53,49 +96,23 @@ It aims to be small and simple and have only a few dependencies, currently only
|
|
|
53
96
|
Because **YAML frontmatter** is common on Markdown files, the Markdown autoformat
|
|
54
97
|
preserves all frontmatter (content between `---` delimiters at the front of a file).
|
|
55
98
|
|
|
56
|
-
|
|
57
|
-
Previously I'd implemented something very similar with
|
|
58
|
-
[for Atom](https://github.com/jlevy/atom-flowmark) but Atom is no more and there seems
|
|
59
|
-
to be greater need for this in Python now.
|
|
60
|
-
From many years experience, I found the Markdown formatting conventions enforced by the
|
|
61
|
-
Atom Flowmark plugin worked well for editing and publishing large or collaboratively
|
|
62
|
-
edited documents.
|
|
63
|
-
|
|
64
|
-
## Installation
|
|
65
|
-
|
|
66
|
-
The simplest way to use the tool is to use [pipx](https://github.com/pypa/pipx):
|
|
67
|
-
|
|
68
|
-
```shell
|
|
69
|
-
pipx install flowmark
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
Then
|
|
73
|
-
|
|
74
|
-
```
|
|
75
|
-
flowmark --help
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
To use as a library, use pip/poetry/uv to install
|
|
79
|
-
[`flowmark`](https://pypi.org/project/flowmark/).
|
|
99
|
+
## Why a New Markdown Formatter?
|
|
80
100
|
|
|
81
|
-
|
|
101
|
+
Previously I'd implemented something very similar with
|
|
102
|
+
[for Atom](https://github.com/jlevy/atom-flowmark).
|
|
103
|
+
I found the Markdown formatting conventions enforced by the that plugin worked really
|
|
104
|
+
well for editing and publishing large or collaboratively edited documents.
|
|
82
105
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
Then add to your `settings.json`:
|
|
106
|
+
This is new, pure Python implementation.
|
|
107
|
+
There are numerous needs for a tool like this on the command line and in Python.
|
|
86
108
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
{
|
|
91
|
-
"match": "\\.md$",
|
|
92
|
-
"cmd": "flowmark --auto ${file}"
|
|
93
|
-
}
|
|
94
|
-
]
|
|
95
|
-
}
|
|
96
|
-
```
|
|
109
|
+
With LLM tools now using Markdown everywhere, there are enormous advantages to having
|
|
110
|
+
very clean and well-formatted Markdown documents, since you can then cleanly see diffs
|
|
111
|
+
or edits made by LLMs.
|
|
97
112
|
|
|
98
|
-
|
|
113
|
+
If you are in a workspace where you are editing lots of text, having them all be
|
|
114
|
+
Markdown with frontmatter, auto-formatted for every git commit makes for a *much* better
|
|
115
|
+
experience.
|
|
99
116
|
|
|
100
117
|
## Usage
|
|
101
118
|
|
|
@@ -155,4 +172,4 @@ For more details, see: https://github.com/jlevy/flowmark
|
|
|
155
172
|
* * *
|
|
156
173
|
|
|
157
174
|
*This project was built from
|
|
158
|
-
[simple-modern-
|
|
175
|
+
[simple-modern-uv](https://github.com/jlevy/simple-modern-uv).*
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
## Development
|
|
2
|
+
|
|
3
|
+
[Fork](https://github.com/jlevy/flowmark/fork) this repo (having your own fork will make
|
|
4
|
+
it easier to contribute),
|
|
5
|
+
[check out](https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository),
|
|
6
|
+
and then install the package dependencies:
|
|
7
|
+
|
|
8
|
+
```shell
|
|
9
|
+
uv sync --all-extras --dev
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Developer workflows:
|
|
13
|
+
|
|
14
|
+
```shell
|
|
15
|
+
# Run uv sync, lint, and test:
|
|
16
|
+
make
|
|
17
|
+
|
|
18
|
+
# Build wheel:
|
|
19
|
+
make build
|
|
20
|
+
|
|
21
|
+
# Linting and testing individually:
|
|
22
|
+
make lint
|
|
23
|
+
make test
|
|
24
|
+
|
|
25
|
+
# Delete all the build artifacts:
|
|
26
|
+
make clean
|
|
27
|
+
|
|
28
|
+
# To run a shell within the Python environment:
|
|
29
|
+
# You can use uv to create and activate a virtual environment
|
|
30
|
+
uv venv
|
|
31
|
+
source .venv/bin/activate
|
|
32
|
+
|
|
33
|
+
# Thereafter you can run tests.
|
|
34
|
+
|
|
35
|
+
# To run tests:
|
|
36
|
+
uv run pytest # all tests
|
|
37
|
+
uv run pytest -s src/module/some_file.py # one test, showing outputs
|
|
38
|
+
|
|
39
|
+
# uv dependency management commands:
|
|
40
|
+
# Add a new dependency:
|
|
41
|
+
uv add package_name
|
|
42
|
+
# Add a development dependency:
|
|
43
|
+
uv add --dev package_name
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Release Process
|
|
47
|
+
|
|
48
|
+
This project is set up to publish to [PyPI](https://pypi.org/) from GitHub Actions.
|
|
49
|
+
|
|
50
|
+
Thanks to [the dynamic versioning
|
|
51
|
+
plugin](https://github.com/ninoseki/uv-dynamic-versioning/) and the
|
|
52
|
+
[`publish.yml` workflow](.github/workflows/publish.yml), you can simply create tagged
|
|
53
|
+
releases (using standard format for the tag name, e.g. `v0.1.0`) on GitHub and the tag
|
|
54
|
+
will trigger a release build, which then uploads it to PyPI.
|
|
55
|
+
|
|
56
|
+
For this to work you will need to have a PyPI account and authorize your repository to
|
|
57
|
+
publish to PyPI. The simplest way to do that is on [the publishing settings
|
|
58
|
+
page](https://pypi.org/manage/account/publishing/). Configure "Trusted Publisher
|
|
59
|
+
Management" and register your GitHub repo as a new "pending" trusted publisher, entering
|
|
60
|
+
the project name, repo owner, repo name, and `publish.yml` as the workflow name.
|
|
61
|
+
|
|
62
|
+
* * *
|
|
63
|
+
|
|
64
|
+
*This file generated by [simple-modern-uv](https://github.com/jlevy/simple-modern-uv).*
|