pyDiffTools 0.1.41__tar.gz → 0.1.42__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.
- {pydifftools-0.1.41/pyDiffTools.egg-info → pydifftools-0.1.42}/PKG-INFO +1 -1
- {pydifftools-0.1.41 → pydifftools-0.1.42/pyDiffTools.egg-info}/PKG-INFO +1 -1
- {pydifftools-0.1.41 → pydifftools-0.1.42}/pydifftools/continuous.py +9 -2
- {pydifftools-0.1.41 → pydifftools-0.1.42}/pydifftools/wrap_sentences.py +49 -67
- {pydifftools-0.1.41 → pydifftools-0.1.42}/pyproject.toml +1 -1
- {pydifftools-0.1.41 → pydifftools-0.1.42}/tests/test_wrap_check.py +45 -28
- {pydifftools-0.1.41 → pydifftools-0.1.42}/tests/test_wrapping.py +2 -1
- {pydifftools-0.1.41 → pydifftools-0.1.42}/LICENSE.md +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/MANIFEST.in +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/README.rst +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/example_notebook/_quarto.yml +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/example_notebook/project1/.jupyter_cache/__version__.txt +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/example_notebook/project1/.jupyter_cache/executed/1a724af72b16f5a9e607e12b1c721645/base.ipynb +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/example_notebook/project1/.jupyter_cache/executed/1b28fc9daac9081847e5161b2c546f8a/base.ipynb +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/example_notebook/project1/.jupyter_cache/executed/231f64eee282fa225d1104935cf80a24/base.ipynb +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/example_notebook/project1/.jupyter_cache/executed/26e56f6b0ff54851a45145157f2f0dc4/base.ipynb +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/example_notebook/project1/.jupyter_cache/executed/311fabd7029ffd050d056e2f316eb50f/base.ipynb +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/example_notebook/project1/.jupyter_cache/executed/57da2021e5b156ac3adf01398201c723/base.ipynb +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/example_notebook/project1/.jupyter_cache/executed/62b24ea7da75011d92b0f8924faa208d/base.ipynb +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/example_notebook/project1/.jupyter_cache/executed/7f1b20d69d889514ab5d1cc92e3cb14f/base.ipynb +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/example_notebook/project1/.jupyter_cache/executed/86f74c8c54a87ff892d9b15dd714e8f0/base.ipynb +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/example_notebook/project1/.jupyter_cache/executed/88893b4234eac2945d9d6cb2e277f186/base.ipynb +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/example_notebook/project1/.jupyter_cache/executed/9a40046ada6f582ee34af00fbdbfb417/base.ipynb +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/example_notebook/project1/.jupyter_cache/executed/a1bf4d270d0641ff41faf1d7cce3439a/base.ipynb +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/example_notebook/project1/.jupyter_cache/executed/a3789f7d9585a781f2a1c60ce95ff10d/base.ipynb +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/example_notebook/project1/.jupyter_cache/executed/be46ecba858d39ad5f0c46902ddf1c02/base.ipynb +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/example_notebook/project1/.jupyter_cache/executed/d0cbc57a12f2ccce710a5afd04cc05e7/base.ipynb +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/example_notebook/project1/.jupyter_cache/executed/d3e12d320b14228f701231ae32ddd7dd/base.ipynb +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/example_notebook/project1/.jupyter_cache/executed/eb434f61555438d020a6970a5dbf9ee8/base.ipynb +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/example_notebook/project1/.jupyter_cache/executed/f6b0e73aa7fa029134665d4dde57e096/base.ipynb +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/example_notebook/project1/.jupyter_cache/executed/f719a6e4ff09873cb0ffb06ec9d232f9/base.ipynb +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/example_notebook/project1/.jupyter_cache/executed/feeee244a7ce3d60e1a227eb604df823/base.ipynb +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/example_notebook/project1/.jupyter_cache/global.db +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/example_notebook/project1/example.qmd +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/example_notebook/project1/example.tex +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/example_notebook/project1/index.qmd +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/example_notebook/project1/subproject1/.jupyter_cache/__version__.txt +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/example_notebook/project1/subproject1/.jupyter_cache/executed/ca90e4df5f4f0583df6554156a68dc7f/base.ipynb +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/example_notebook/project1/subproject1/.jupyter_cache/global.db +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/example_notebook/project1/subproject1/end_vs_he_sketch.jpg +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/example_notebook/project1/subproject1/independent.qmd +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/example_notebook/project1/subproject1/index.qmd +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/example_notebook/project1/subproject1/tasks.qmd +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/example_notebook/project1/subproject1/test_include.qmd +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/example_notebook/project1/subproject1/tryforerror.qmd +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/example_notebook/project1/test_include.qmd +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/pyDiffTools.egg-info/SOURCES.txt +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/pyDiffTools.egg-info/dependency_links.txt +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/pyDiffTools.egg-info/entry_points.txt +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/pyDiffTools.egg-info/requires.txt +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/pyDiffTools.egg-info/top_level.txt +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/pydifftools/__init__.py +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/pydifftools/bibliography.py +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/pydifftools/browser_lifecycle.py +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/pydifftools/check_numbers.py +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/pydifftools/citation_dialog.py +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/pydifftools/command_line.py +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/pydifftools/command_registry.py +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/pydifftools/comment_functions.py +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/pydifftools/comment_migration.py +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/pydifftools/comment_tags.lua +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/pydifftools/comment_tags_margin.lua +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/pydifftools/comment_tags_no_comments.lua +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/pydifftools/comment_toggle.js +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/pydifftools/comments.css +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/pydifftools/copy_files.py +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/pydifftools/diff-doc.js +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/pydifftools/doc_contents.py +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/pydifftools/flowchart/__init__.py +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/pydifftools/flowchart/comparison.py +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/pydifftools/flowchart/dot_to_yaml.py +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/pydifftools/flowchart/graph.py +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/pydifftools/flowchart/svg-pan-zoom.min.js +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/pydifftools/flowchart/watch_graph.py +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/pydifftools/flowchart/wgrph_view.js +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/pydifftools/forward_search.py +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/pydifftools/git_gd.py +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/pydifftools/git_gd_history.py +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/pydifftools/git_gd_image.py +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/pydifftools/git_gd_qt.py +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/pydifftools/html_comments.py +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/pydifftools/html_uncomments.py +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/pydifftools/log_example.py +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/pydifftools/match_spaces.py +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/pydifftools/notebook/__init__.py +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/pydifftools/notebook/display.py +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/pydifftools/notebook/fast_build.py +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/pydifftools/notebook/tex_to_qmd.py +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/pydifftools/onewordify.py +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/pydifftools/onewordify_undo.py +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/pydifftools/outline.py +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/pydifftools/rearrange_tex.py +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/pydifftools/searchacro.py +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/pydifftools/separate_comments.py +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/pydifftools/split_conflict.py +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/pydifftools/unseparate_comments.py +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/pydifftools/update_check.py +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/pydifftools/xml2xlsx.vbs +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/pydifftools/zotero.py +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/setup.cfg +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/tests/test_bibliography.py +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/tests/test_browser_lifecycle.py +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/tests/test_check_single_use.py +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/tests/test_command_line_help.py +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/tests/test_comment_migration.py +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/tests/test_continuous_shutdown.py +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/tests/test_forward_search.py +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/tests/test_git_gd_history.py +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/tests/test_git_gd_image.py +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/tests/test_git_gd_qt.py +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/tests/test_rrng.py +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/tests/test_tex_to_qmd.py +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/tests/test_update_check.py +0 -0
- {pydifftools-0.1.41 → pydifftools-0.1.42}/tests/test_zotero.py +0 -0
|
@@ -303,6 +303,7 @@ def run_pandoc(
|
|
|
303
303
|
comments_to_margin=False,
|
|
304
304
|
no_comments=False,
|
|
305
305
|
comment_filter_session=None,
|
|
306
|
+
wrapnumber=79,
|
|
306
307
|
):
|
|
307
308
|
# {{{ automatically fix Markdown source and request edits for
|
|
308
309
|
# unfinished spans
|
|
@@ -310,7 +311,7 @@ def run_pandoc(
|
|
|
310
311
|
|
|
311
312
|
automatic_fixes_were_made = False
|
|
312
313
|
while True:
|
|
313
|
-
report = autofix_markdown_file(filename,
|
|
314
|
+
report = autofix_markdown_file(filename, wrapnumber=wrapnumber)
|
|
314
315
|
automatic_fixes_were_made |= bool(report["fixes"])
|
|
315
316
|
if report["fixes"] or report["warnings"]:
|
|
316
317
|
user_says_fixed = show_markdown_fix_dialog(report)
|
|
@@ -789,10 +790,14 @@ class Handler(FileSystemEventHandler):
|
|
|
789
790
|
"no_comments": (
|
|
790
791
|
"Render the HTML without comment tags or comment div blocks."
|
|
791
792
|
),
|
|
793
|
+
"wrapnumber": (
|
|
794
|
+
"Maximum source line width; the automatic Markdown fixes break "
|
|
795
|
+
"only lines longer than this."
|
|
796
|
+
),
|
|
792
797
|
},
|
|
793
798
|
filename_extensions={"filename": ".md"},
|
|
794
799
|
)
|
|
795
|
-
def cpb(filename, comments_to_margin=False, no_comments=False):
|
|
800
|
+
def cpb(filename, comments_to_margin=False, no_comments=False, wrapnumber=79):
|
|
796
801
|
source_path = os.path.normpath(os.path.abspath(filename))
|
|
797
802
|
source_dir = os.path.dirname(source_path)
|
|
798
803
|
html_file = filename.rsplit(".", 1)[0] + ".html"
|
|
@@ -836,6 +841,7 @@ def cpb(filename, comments_to_margin=False, no_comments=False):
|
|
|
836
841
|
comments_to_margin=comments_to_margin,
|
|
837
842
|
no_comments=no_comments,
|
|
838
843
|
comment_filter_session=comment_filter_session,
|
|
844
|
+
wrapnumber=wrapnumber,
|
|
839
845
|
)
|
|
840
846
|
append_autorefresh(html_file)
|
|
841
847
|
notice = zotero_notice()
|
|
@@ -971,6 +977,7 @@ def cpb(filename, comments_to_margin=False, no_comments=False):
|
|
|
971
977
|
comments_to_margin=comments_to_margin,
|
|
972
978
|
no_comments=no_comments,
|
|
973
979
|
comment_filter_session=comment_filter_session,
|
|
980
|
+
wrapnumber=wrapnumber,
|
|
974
981
|
)
|
|
975
982
|
append_autorefresh(html_file)
|
|
976
983
|
except Exception as exc:
|
|
@@ -658,18 +658,29 @@ def _next_break(words, wrapnumber, punctuation_slop, boundaries, offset):
|
|
|
658
658
|
Shared by wrap_prose (which then emits that line) and check_prose
|
|
659
659
|
(which replays the same choice to see if a source line agrees).
|
|
660
660
|
"""
|
|
661
|
+
# counts[j] - 1 is the length of the line holding words[: j + 1]
|
|
661
662
|
counts = list(itertools.accumulate(len(word) + 1 for word in words))
|
|
662
|
-
|
|
663
|
+
if counts[-1] - 1 <= wrapnumber:
|
|
664
|
+
# the rest fits, so there is nothing to break
|
|
665
|
+
return len(words) - 1
|
|
666
|
+
# the last word that fits within the width (or the first word, if even
|
|
667
|
+
# that is too long)
|
|
668
|
+
upto = max(
|
|
669
|
+
[j for j, count in enumerate(counts) if count - 1 <= wrapnumber]
|
|
670
|
+
or [0]
|
|
671
|
+
)
|
|
672
|
+
# prefer to end the line on a clause (comma, paren, dash, ...) or at an
|
|
673
|
+
# inline-math boundary within punctuation_slop characters of that break
|
|
663
674
|
candidates = [
|
|
664
675
|
j
|
|
665
|
-
for j, word in enumerate(words)
|
|
666
|
-
if (
|
|
676
|
+
for j, word in enumerate(words[: upto + 1])
|
|
677
|
+
if (
|
|
678
|
+
(len(word) > 1 and word[-1] in ",;:)-")
|
|
679
|
+
or offset + j in boundaries
|
|
680
|
+
)
|
|
681
|
+
and counts[upto] - counts[j] < punctuation_slop
|
|
667
682
|
]
|
|
668
|
-
if candidates
|
|
669
|
-
punct = min(candidates, key=lambda j: abs(counts[j] - wrapnumber))
|
|
670
|
-
if punct < upto and upto - punct < punctuation_slop:
|
|
671
|
-
upto = punct
|
|
672
|
-
return upto
|
|
683
|
+
return max(candidates) if candidates else upto
|
|
673
684
|
|
|
674
685
|
|
|
675
686
|
def wrap_prose(
|
|
@@ -805,6 +816,11 @@ def _prepare(filename, cleanoo=False, i=-1):
|
|
|
805
816
|
"filename": "Input file to wrap. Use '-' to read from stdin.",
|
|
806
817
|
"cleanoo": "Strip LibreOffice markup before wrapping.",
|
|
807
818
|
"i": "Indentation level for wrapped lines.",
|
|
819
|
+
"wrapnumber": "Maximum line width in characters.",
|
|
820
|
+
"punctuation_slop": (
|
|
821
|
+
"End a line early on a clause (comma, paren, dash, ...) when "
|
|
822
|
+
"that is within this many characters of the widest break."
|
|
823
|
+
),
|
|
808
824
|
},
|
|
809
825
|
filename_extensions={"filename": [".md", ".tex"]},
|
|
810
826
|
)
|
|
@@ -920,7 +936,16 @@ def check_prose(content, wrapnumber, punctuation_slop, line_start=1):
|
|
|
920
936
|
and not breaks_after[actual_end]
|
|
921
937
|
):
|
|
922
938
|
actual_end += 1
|
|
923
|
-
|
|
939
|
+
line_length = (
|
|
940
|
+
positions[actual_end]
|
|
941
|
+
+ len(words[actual_end])
|
|
942
|
+
- positions[fragment_offset]
|
|
943
|
+
)
|
|
944
|
+
# only a line that exceeds the width is too long
|
|
945
|
+
if (
|
|
946
|
+
actual_end > wr_end
|
|
947
|
+
and line_length > wrapnumber
|
|
948
|
+
):
|
|
924
949
|
overflow = words[wr_end + 1]
|
|
925
950
|
issue_line = para_line + stripped.count(
|
|
926
951
|
"\n", 0, positions[actual_end]
|
|
@@ -1004,13 +1029,9 @@ def _iter_block_spans(blocks, wrapnumber, line_start=1):
|
|
|
1004
1029
|
|
|
1005
1030
|
|
|
1006
1031
|
def markdown_lint_issues_from_text(
|
|
1007
|
-
content, wrapnumber=45, punctuation_slop=20
|
|
1032
|
+
content, wrapnumber=45, punctuation_slop=20
|
|
1008
1033
|
):
|
|
1009
|
-
"""Return Markdown writing issues, including unfinished source spans.
|
|
1010
|
-
|
|
1011
|
-
With `max_line_length`, a prose line is only too long when it holds
|
|
1012
|
-
more than that many characters, instead of wr's greedy line choice.
|
|
1013
|
-
"""
|
|
1034
|
+
"""Return Markdown writing issues, including unfinished source spans."""
|
|
1014
1035
|
def mask_comment(match):
|
|
1015
1036
|
return "".join("\n" if char == "\n" else " " for char in match[0])
|
|
1016
1037
|
|
|
@@ -1020,30 +1041,13 @@ def markdown_lint_issues_from_text(
|
|
|
1020
1041
|
# trailing spaces are reported separately below, and a double space
|
|
1021
1042
|
# (a hard line break) must not look like a sentence ending mid-line
|
|
1022
1043
|
prose_content = re.sub(r"[ \t]+$", "", prose_content, flags=re.M)
|
|
1023
|
-
issues = [
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
for issue in check_prose(span, width, punctuation_slop, line)
|
|
1029
|
-
|
|
1030
|
-
"line too long:"
|
|
1031
|
-
):
|
|
1032
|
-
issues.append(issue)
|
|
1033
|
-
if max_line_length is not None:
|
|
1034
|
-
# {{{ flag prose lines longer than the character limit
|
|
1035
|
-
for number in range(line, line + len(span.splitlines())):
|
|
1036
|
-
text = prose_lines[number - 1]
|
|
1037
|
-
# a single unbreakable word cannot be shortened
|
|
1038
|
-
if len(text) > max_line_length and len(
|
|
1039
|
-
WORD.findall(text)
|
|
1040
|
-
) > 1:
|
|
1041
|
-
issues.append((
|
|
1042
|
-
number,
|
|
1043
|
-
f"line over {max_line_length} characters: break "
|
|
1044
|
-
"it at a word boundary",
|
|
1045
|
-
))
|
|
1046
|
-
# }}}
|
|
1044
|
+
issues = [
|
|
1045
|
+
issue
|
|
1046
|
+
for line, width, span in _iter_block_spans(
|
|
1047
|
+
markdown_blocks(prose_content), wrapnumber
|
|
1048
|
+
)
|
|
1049
|
+
for issue in check_prose(span, width, punctuation_slop, line)
|
|
1050
|
+
]
|
|
1047
1051
|
issues.extend(
|
|
1048
1052
|
(issue["line"], issue["message"])
|
|
1049
1053
|
for issue in unclosed_markdown_spans(content)
|
|
@@ -1229,25 +1233,7 @@ def apply_markdown_issue_fix(content, line_number, message):
|
|
|
1229
1233
|
old_line[:-1],
|
|
1230
1234
|
"A line ended with a single stray space. I removed it.",
|
|
1231
1235
|
)
|
|
1232
|
-
if message.startswith("line
|
|
1233
|
-
# {{{ break at the last word boundary that fits the limit
|
|
1234
|
-
limit = int(re.match(r"line over (\d+)", message)[1])
|
|
1235
|
-
gaps = [
|
|
1236
|
-
found.end()
|
|
1237
|
-
for found in WORD.finditer(old_line)
|
|
1238
|
-
if container.end() < found.end() < len(old_line.rstrip())
|
|
1239
|
-
]
|
|
1240
|
-
fitting = [gap for gap in gaps if gap <= limit]
|
|
1241
|
-
# when even the first word is too long, break right after it
|
|
1242
|
-
split_at = fitting[-1] if fitting else gaps[0]
|
|
1243
|
-
first = old_line[:split_at].rstrip()
|
|
1244
|
-
second = old_line[split_at:].lstrip(" \t")
|
|
1245
|
-
reason = (
|
|
1246
|
-
f"This line was longer than {limit} characters. "
|
|
1247
|
-
"I moved the last words onto a new line."
|
|
1248
|
-
)
|
|
1249
|
-
# }}}
|
|
1250
|
-
elif message.startswith("line too long:"):
|
|
1236
|
+
if message.startswith("line too long:"):
|
|
1251
1237
|
match = re.search(r"after '(.+?)' \(before '(.+?)'\); move", message)
|
|
1252
1238
|
if match is None:
|
|
1253
1239
|
raise ValueError(
|
|
@@ -1298,9 +1284,7 @@ def apply_markdown_issue_fix(content, line_number, message):
|
|
|
1298
1284
|
return "".join(lines), old_line, after, reason
|
|
1299
1285
|
|
|
1300
1286
|
|
|
1301
|
-
def autofix_markdown_file(
|
|
1302
|
-
filename, wrapnumber=55, punctuation_slop=20, max_line_length=None
|
|
1303
|
-
):
|
|
1287
|
+
def autofix_markdown_file(filename, wrapnumber=55, punctuation_slop=20):
|
|
1304
1288
|
"""Apply safe source line breaks and report unfinished source spans."""
|
|
1305
1289
|
with open(filename, encoding="utf-8", newline="") as fp:
|
|
1306
1290
|
content = fp.read()
|
|
@@ -1309,10 +1293,7 @@ def autofix_markdown_file(
|
|
|
1309
1293
|
# issue at a time re-lints the whole file for every single fix.
|
|
1310
1294
|
for _ in range(100):
|
|
1311
1295
|
issues = markdown_lint_issues_from_text(
|
|
1312
|
-
content,
|
|
1313
|
-
wrapnumber=wrapnumber,
|
|
1314
|
-
punctuation_slop=punctuation_slop,
|
|
1315
|
-
max_line_length=max_line_length,
|
|
1296
|
+
content, wrapnumber=wrapnumber, punctuation_slop=punctuation_slop
|
|
1316
1297
|
)
|
|
1317
1298
|
fixable = {}
|
|
1318
1299
|
for line_number, message in issues:
|
|
@@ -1358,8 +1339,9 @@ def autofix_markdown_file(
|
|
|
1358
1339
|
@register_command(
|
|
1359
1340
|
"check wrapping and sentence-break rules (for markdown or latex).",
|
|
1360
1341
|
"check that a file already obeys wr's wrapping rules -- without\n"
|
|
1361
|
-
"rewriting anything. Reports a source line as too long if it
|
|
1362
|
-
"
|
|
1342
|
+
"rewriting anything. Reports a source line as too long if it is\n"
|
|
1343
|
+
"longer than --wrapnumber characters (and suggests the break wr would\n"
|
|
1344
|
+
"use, which favors ending on a clause a few words early), and\n"
|
|
1363
1345
|
"reports a sentence that ends in the middle of a source line\n"
|
|
1364
1346
|
"instead of at a line break. Prints 'file:line: message' for each\n"
|
|
1365
1347
|
"violation and exits non-zero if any are found. Takes the same\n"
|
|
@@ -253,49 +253,66 @@ def test_autofix_fixes_every_line_in_one_pass_from_the_end(tmp_path):
|
|
|
253
253
|
assert markdown_lint_issues_from_text(fixed, wrapnumber=55) == []
|
|
254
254
|
|
|
255
255
|
|
|
256
|
-
def
|
|
257
|
-
# from RM_ESR:
|
|
256
|
+
def test_only_lines_longer_than_the_width_are_too_long():
|
|
257
|
+
# from RM_ESR: short lines ending on a clause used to be flagged, since
|
|
258
|
+
# wr broke at a comma or paren even when the rest of the line fit
|
|
258
259
|
source = (
|
|
259
|
-
"
|
|
260
|
-
"
|
|
260
|
+
"(see @fig:CaldararuTau) indicates that\n"
|
|
261
|
+
"This is especially true, given that a comparison\n"
|
|
261
262
|
)
|
|
262
263
|
|
|
263
|
-
assert markdown_lint_issues_from_text(source, 55)
|
|
264
|
-
assert markdown_lint_issues_from_text(source,
|
|
264
|
+
assert markdown_lint_issues_from_text(source, 55) == []
|
|
265
|
+
assert markdown_lint_issues_from_text(source, 79) == []
|
|
266
|
+
assert [
|
|
267
|
+
message.split(":")[0]
|
|
268
|
+
for _, message in markdown_lint_issues_from_text(source, 40)
|
|
269
|
+
] == ["line too long"]
|
|
265
270
|
|
|
266
271
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
# from RM_ESR: a sentence that grew past 79 characters
|
|
272
|
+
def test_long_line_breaks_early_on_a_nearby_clause(tmp_path):
|
|
273
|
+
# from RM_ESR: several clauses on one line that grew past 79
|
|
270
274
|
line = (
|
|
271
|
-
|
|
272
|
-
"
|
|
273
|
-
"experiment.\n"
|
|
275
|
+
"Finally, it estimates the rotational correlation time, "
|
|
276
|
+
"*via* the classic Kivelson equation, as a function of temperature.\n"
|
|
274
277
|
)
|
|
275
278
|
path = tmp_path / "source.md"
|
|
276
279
|
path.write_text(line)
|
|
277
280
|
|
|
278
|
-
|
|
279
|
-
report = autofix_markdown_file(path, max_line_length=79)
|
|
281
|
+
report = autofix_markdown_file(path, wrapnumber=79)
|
|
280
282
|
|
|
281
283
|
fixed = path.read_text()
|
|
282
|
-
assert
|
|
283
|
-
"line over 79 characters"
|
|
284
|
-
]
|
|
285
|
-
assert "79 characters" in report["fixes"][0]["reason"]
|
|
284
|
+
assert fixed.split() == line.split()
|
|
286
285
|
assert all(len(text) <= 79 for text in fixed.splitlines())
|
|
287
|
-
|
|
288
|
-
#
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
286
|
+
# the widest break is after "classic" (72 characters); "time," is 18
|
|
287
|
+
# characters before that, within the slop, so the line ends on it
|
|
288
|
+
assert fixed.splitlines()[0].endswith("rotational correlation time,")
|
|
289
|
+
assert len(report["fixes"]) == 1
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
def test_clause_far_before_the_width_does_not_force_an_early_break():
|
|
293
|
+
line = (
|
|
294
|
+
"Finally, it estimates the rotational correlation time of the "
|
|
295
|
+
"probe and many other ordinary words here.\n"
|
|
296
|
+
)
|
|
297
|
+
|
|
298
|
+
first = wrap_prose(line, 79).splitlines()[0]
|
|
299
|
+
|
|
300
|
+
assert first.startswith("Finally, it estimates")
|
|
301
|
+
assert len(first) > 70
|
|
293
302
|
|
|
294
303
|
|
|
295
|
-
|
|
296
|
-
|
|
304
|
+
@pytest.mark.parametrize("width", [20, 45, 55, 79])
|
|
305
|
+
def test_wr_never_runs_past_the_width(width):
|
|
306
|
+
text = (
|
|
307
|
+
"This script determines the field positions, and amplitudes, of the "
|
|
308
|
+
"spectral lines (for an entire variable-temperature experiment) -- "
|
|
309
|
+
"and it implements spline-based smoothing of the spectra.\n"
|
|
310
|
+
)
|
|
311
|
+
|
|
312
|
+
wrapped = wrap_prose(text, width)
|
|
297
313
|
|
|
298
|
-
assert
|
|
314
|
+
assert all(len(line) <= width for line in wrapped.splitlines())
|
|
315
|
+
assert markdown_lint_issues_from_text(wrapped, width) == []
|
|
299
316
|
|
|
300
317
|
|
|
301
318
|
def test_unclosed_math_is_reported_after_fifty_lines():
|
|
@@ -416,7 +433,7 @@ def test_qt_fix_and_reload_windows_show_source_changes(tmp_path):
|
|
|
416
433
|
|
|
417
434
|
QTimer.singleShot(0, inspect_fix_window)
|
|
418
435
|
show_markdown_fix_dialog(report)
|
|
419
|
-
assert "↳ of words" in seen["preview"]
|
|
436
|
+
assert "↳ collection of words" in seen["preview"]
|
|
420
437
|
assert seen["button"] == "Done"
|
|
421
438
|
assert "1" in seen["line_gutter"]
|
|
422
439
|
assert "line 1" not in seen["heading"].lower()
|
|
@@ -423,7 +423,8 @@ def test_nested_containers_keep_terms_items_and_paragraphs_separate():
|
|
|
423
423
|
result = wrap_blocks(markdown_blocks(source), 25)
|
|
424
424
|
assert result.startswith("Term\n: first definition\n")
|
|
425
425
|
assert "\n - a nested item with\n" in result
|
|
426
|
-
|
|
426
|
+
# the quotation is 17 wide, so wr never lets it run past that
|
|
427
|
+
assert "\n > a nested\n" in result
|
|
427
428
|
assert "\n: a second definition\n" in result
|
|
428
429
|
assert "\n\nOutside prose" in result
|
|
429
430
|
assert wrap_blocks(markdown_blocks(result), 25) == result
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pydifftools-0.1.41 → pydifftools-0.1.42}/example_notebook/project1/.jupyter_cache/__version__.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pydifftools-0.1.41 → pydifftools-0.1.42}/example_notebook/project1/.jupyter_cache/global.db
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pydifftools-0.1.41 → pydifftools-0.1.42}/example_notebook/project1/subproject1/end_vs_he_sketch.jpg
RENAMED
|
File without changes
|
{pydifftools-0.1.41 → pydifftools-0.1.42}/example_notebook/project1/subproject1/independent.qmd
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pydifftools-0.1.41 → pydifftools-0.1.42}/example_notebook/project1/subproject1/test_include.qmd
RENAMED
|
File without changes
|
{pydifftools-0.1.41 → pydifftools-0.1.42}/example_notebook/project1/subproject1/tryforerror.qmd
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|