pyDiffTools 0.1.40__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.
Files changed (114) hide show
  1. {pydifftools-0.1.40/pyDiffTools.egg-info → pydifftools-0.1.42}/PKG-INFO +1 -1
  2. {pydifftools-0.1.40 → pydifftools-0.1.42/pyDiffTools.egg-info}/PKG-INFO +1 -1
  3. {pydifftools-0.1.40 → pydifftools-0.1.42}/pydifftools/continuous.py +9 -2
  4. {pydifftools-0.1.40 → pydifftools-0.1.42}/pydifftools/wrap_sentences.py +37 -11
  5. {pydifftools-0.1.40 → pydifftools-0.1.42}/pyproject.toml +1 -1
  6. {pydifftools-0.1.40 → pydifftools-0.1.42}/tests/test_wrap_check.py +63 -1
  7. {pydifftools-0.1.40 → pydifftools-0.1.42}/tests/test_wrapping.py +2 -1
  8. {pydifftools-0.1.40 → pydifftools-0.1.42}/LICENSE.md +0 -0
  9. {pydifftools-0.1.40 → pydifftools-0.1.42}/MANIFEST.in +0 -0
  10. {pydifftools-0.1.40 → pydifftools-0.1.42}/README.rst +0 -0
  11. {pydifftools-0.1.40 → pydifftools-0.1.42}/example_notebook/_quarto.yml +0 -0
  12. {pydifftools-0.1.40 → pydifftools-0.1.42}/example_notebook/project1/.jupyter_cache/__version__.txt +0 -0
  13. {pydifftools-0.1.40 → pydifftools-0.1.42}/example_notebook/project1/.jupyter_cache/executed/1a724af72b16f5a9e607e12b1c721645/base.ipynb +0 -0
  14. {pydifftools-0.1.40 → pydifftools-0.1.42}/example_notebook/project1/.jupyter_cache/executed/1b28fc9daac9081847e5161b2c546f8a/base.ipynb +0 -0
  15. {pydifftools-0.1.40 → pydifftools-0.1.42}/example_notebook/project1/.jupyter_cache/executed/231f64eee282fa225d1104935cf80a24/base.ipynb +0 -0
  16. {pydifftools-0.1.40 → pydifftools-0.1.42}/example_notebook/project1/.jupyter_cache/executed/26e56f6b0ff54851a45145157f2f0dc4/base.ipynb +0 -0
  17. {pydifftools-0.1.40 → pydifftools-0.1.42}/example_notebook/project1/.jupyter_cache/executed/311fabd7029ffd050d056e2f316eb50f/base.ipynb +0 -0
  18. {pydifftools-0.1.40 → pydifftools-0.1.42}/example_notebook/project1/.jupyter_cache/executed/57da2021e5b156ac3adf01398201c723/base.ipynb +0 -0
  19. {pydifftools-0.1.40 → pydifftools-0.1.42}/example_notebook/project1/.jupyter_cache/executed/62b24ea7da75011d92b0f8924faa208d/base.ipynb +0 -0
  20. {pydifftools-0.1.40 → pydifftools-0.1.42}/example_notebook/project1/.jupyter_cache/executed/7f1b20d69d889514ab5d1cc92e3cb14f/base.ipynb +0 -0
  21. {pydifftools-0.1.40 → pydifftools-0.1.42}/example_notebook/project1/.jupyter_cache/executed/86f74c8c54a87ff892d9b15dd714e8f0/base.ipynb +0 -0
  22. {pydifftools-0.1.40 → pydifftools-0.1.42}/example_notebook/project1/.jupyter_cache/executed/88893b4234eac2945d9d6cb2e277f186/base.ipynb +0 -0
  23. {pydifftools-0.1.40 → pydifftools-0.1.42}/example_notebook/project1/.jupyter_cache/executed/9a40046ada6f582ee34af00fbdbfb417/base.ipynb +0 -0
  24. {pydifftools-0.1.40 → pydifftools-0.1.42}/example_notebook/project1/.jupyter_cache/executed/a1bf4d270d0641ff41faf1d7cce3439a/base.ipynb +0 -0
  25. {pydifftools-0.1.40 → pydifftools-0.1.42}/example_notebook/project1/.jupyter_cache/executed/a3789f7d9585a781f2a1c60ce95ff10d/base.ipynb +0 -0
  26. {pydifftools-0.1.40 → pydifftools-0.1.42}/example_notebook/project1/.jupyter_cache/executed/be46ecba858d39ad5f0c46902ddf1c02/base.ipynb +0 -0
  27. {pydifftools-0.1.40 → pydifftools-0.1.42}/example_notebook/project1/.jupyter_cache/executed/d0cbc57a12f2ccce710a5afd04cc05e7/base.ipynb +0 -0
  28. {pydifftools-0.1.40 → pydifftools-0.1.42}/example_notebook/project1/.jupyter_cache/executed/d3e12d320b14228f701231ae32ddd7dd/base.ipynb +0 -0
  29. {pydifftools-0.1.40 → pydifftools-0.1.42}/example_notebook/project1/.jupyter_cache/executed/eb434f61555438d020a6970a5dbf9ee8/base.ipynb +0 -0
  30. {pydifftools-0.1.40 → pydifftools-0.1.42}/example_notebook/project1/.jupyter_cache/executed/f6b0e73aa7fa029134665d4dde57e096/base.ipynb +0 -0
  31. {pydifftools-0.1.40 → pydifftools-0.1.42}/example_notebook/project1/.jupyter_cache/executed/f719a6e4ff09873cb0ffb06ec9d232f9/base.ipynb +0 -0
  32. {pydifftools-0.1.40 → pydifftools-0.1.42}/example_notebook/project1/.jupyter_cache/executed/feeee244a7ce3d60e1a227eb604df823/base.ipynb +0 -0
  33. {pydifftools-0.1.40 → pydifftools-0.1.42}/example_notebook/project1/.jupyter_cache/global.db +0 -0
  34. {pydifftools-0.1.40 → pydifftools-0.1.42}/example_notebook/project1/example.qmd +0 -0
  35. {pydifftools-0.1.40 → pydifftools-0.1.42}/example_notebook/project1/example.tex +0 -0
  36. {pydifftools-0.1.40 → pydifftools-0.1.42}/example_notebook/project1/index.qmd +0 -0
  37. {pydifftools-0.1.40 → pydifftools-0.1.42}/example_notebook/project1/subproject1/.jupyter_cache/__version__.txt +0 -0
  38. {pydifftools-0.1.40 → pydifftools-0.1.42}/example_notebook/project1/subproject1/.jupyter_cache/executed/ca90e4df5f4f0583df6554156a68dc7f/base.ipynb +0 -0
  39. {pydifftools-0.1.40 → pydifftools-0.1.42}/example_notebook/project1/subproject1/.jupyter_cache/global.db +0 -0
  40. {pydifftools-0.1.40 → pydifftools-0.1.42}/example_notebook/project1/subproject1/end_vs_he_sketch.jpg +0 -0
  41. {pydifftools-0.1.40 → pydifftools-0.1.42}/example_notebook/project1/subproject1/independent.qmd +0 -0
  42. {pydifftools-0.1.40 → pydifftools-0.1.42}/example_notebook/project1/subproject1/index.qmd +0 -0
  43. {pydifftools-0.1.40 → pydifftools-0.1.42}/example_notebook/project1/subproject1/tasks.qmd +0 -0
  44. {pydifftools-0.1.40 → pydifftools-0.1.42}/example_notebook/project1/subproject1/test_include.qmd +0 -0
  45. {pydifftools-0.1.40 → pydifftools-0.1.42}/example_notebook/project1/subproject1/tryforerror.qmd +0 -0
  46. {pydifftools-0.1.40 → pydifftools-0.1.42}/example_notebook/project1/test_include.qmd +0 -0
  47. {pydifftools-0.1.40 → pydifftools-0.1.42}/pyDiffTools.egg-info/SOURCES.txt +0 -0
  48. {pydifftools-0.1.40 → pydifftools-0.1.42}/pyDiffTools.egg-info/dependency_links.txt +0 -0
  49. {pydifftools-0.1.40 → pydifftools-0.1.42}/pyDiffTools.egg-info/entry_points.txt +0 -0
  50. {pydifftools-0.1.40 → pydifftools-0.1.42}/pyDiffTools.egg-info/requires.txt +0 -0
  51. {pydifftools-0.1.40 → pydifftools-0.1.42}/pyDiffTools.egg-info/top_level.txt +0 -0
  52. {pydifftools-0.1.40 → pydifftools-0.1.42}/pydifftools/__init__.py +0 -0
  53. {pydifftools-0.1.40 → pydifftools-0.1.42}/pydifftools/bibliography.py +0 -0
  54. {pydifftools-0.1.40 → pydifftools-0.1.42}/pydifftools/browser_lifecycle.py +0 -0
  55. {pydifftools-0.1.40 → pydifftools-0.1.42}/pydifftools/check_numbers.py +0 -0
  56. {pydifftools-0.1.40 → pydifftools-0.1.42}/pydifftools/citation_dialog.py +0 -0
  57. {pydifftools-0.1.40 → pydifftools-0.1.42}/pydifftools/command_line.py +0 -0
  58. {pydifftools-0.1.40 → pydifftools-0.1.42}/pydifftools/command_registry.py +0 -0
  59. {pydifftools-0.1.40 → pydifftools-0.1.42}/pydifftools/comment_functions.py +0 -0
  60. {pydifftools-0.1.40 → pydifftools-0.1.42}/pydifftools/comment_migration.py +0 -0
  61. {pydifftools-0.1.40 → pydifftools-0.1.42}/pydifftools/comment_tags.lua +0 -0
  62. {pydifftools-0.1.40 → pydifftools-0.1.42}/pydifftools/comment_tags_margin.lua +0 -0
  63. {pydifftools-0.1.40 → pydifftools-0.1.42}/pydifftools/comment_tags_no_comments.lua +0 -0
  64. {pydifftools-0.1.40 → pydifftools-0.1.42}/pydifftools/comment_toggle.js +0 -0
  65. {pydifftools-0.1.40 → pydifftools-0.1.42}/pydifftools/comments.css +0 -0
  66. {pydifftools-0.1.40 → pydifftools-0.1.42}/pydifftools/copy_files.py +0 -0
  67. {pydifftools-0.1.40 → pydifftools-0.1.42}/pydifftools/diff-doc.js +0 -0
  68. {pydifftools-0.1.40 → pydifftools-0.1.42}/pydifftools/doc_contents.py +0 -0
  69. {pydifftools-0.1.40 → pydifftools-0.1.42}/pydifftools/flowchart/__init__.py +0 -0
  70. {pydifftools-0.1.40 → pydifftools-0.1.42}/pydifftools/flowchart/comparison.py +0 -0
  71. {pydifftools-0.1.40 → pydifftools-0.1.42}/pydifftools/flowchart/dot_to_yaml.py +0 -0
  72. {pydifftools-0.1.40 → pydifftools-0.1.42}/pydifftools/flowchart/graph.py +0 -0
  73. {pydifftools-0.1.40 → pydifftools-0.1.42}/pydifftools/flowchart/svg-pan-zoom.min.js +0 -0
  74. {pydifftools-0.1.40 → pydifftools-0.1.42}/pydifftools/flowchart/watch_graph.py +0 -0
  75. {pydifftools-0.1.40 → pydifftools-0.1.42}/pydifftools/flowchart/wgrph_view.js +0 -0
  76. {pydifftools-0.1.40 → pydifftools-0.1.42}/pydifftools/forward_search.py +0 -0
  77. {pydifftools-0.1.40 → pydifftools-0.1.42}/pydifftools/git_gd.py +0 -0
  78. {pydifftools-0.1.40 → pydifftools-0.1.42}/pydifftools/git_gd_history.py +0 -0
  79. {pydifftools-0.1.40 → pydifftools-0.1.42}/pydifftools/git_gd_image.py +0 -0
  80. {pydifftools-0.1.40 → pydifftools-0.1.42}/pydifftools/git_gd_qt.py +0 -0
  81. {pydifftools-0.1.40 → pydifftools-0.1.42}/pydifftools/html_comments.py +0 -0
  82. {pydifftools-0.1.40 → pydifftools-0.1.42}/pydifftools/html_uncomments.py +0 -0
  83. {pydifftools-0.1.40 → pydifftools-0.1.42}/pydifftools/log_example.py +0 -0
  84. {pydifftools-0.1.40 → pydifftools-0.1.42}/pydifftools/match_spaces.py +0 -0
  85. {pydifftools-0.1.40 → pydifftools-0.1.42}/pydifftools/notebook/__init__.py +0 -0
  86. {pydifftools-0.1.40 → pydifftools-0.1.42}/pydifftools/notebook/display.py +0 -0
  87. {pydifftools-0.1.40 → pydifftools-0.1.42}/pydifftools/notebook/fast_build.py +0 -0
  88. {pydifftools-0.1.40 → pydifftools-0.1.42}/pydifftools/notebook/tex_to_qmd.py +0 -0
  89. {pydifftools-0.1.40 → pydifftools-0.1.42}/pydifftools/onewordify.py +0 -0
  90. {pydifftools-0.1.40 → pydifftools-0.1.42}/pydifftools/onewordify_undo.py +0 -0
  91. {pydifftools-0.1.40 → pydifftools-0.1.42}/pydifftools/outline.py +0 -0
  92. {pydifftools-0.1.40 → pydifftools-0.1.42}/pydifftools/rearrange_tex.py +0 -0
  93. {pydifftools-0.1.40 → pydifftools-0.1.42}/pydifftools/searchacro.py +0 -0
  94. {pydifftools-0.1.40 → pydifftools-0.1.42}/pydifftools/separate_comments.py +0 -0
  95. {pydifftools-0.1.40 → pydifftools-0.1.42}/pydifftools/split_conflict.py +0 -0
  96. {pydifftools-0.1.40 → pydifftools-0.1.42}/pydifftools/unseparate_comments.py +0 -0
  97. {pydifftools-0.1.40 → pydifftools-0.1.42}/pydifftools/update_check.py +0 -0
  98. {pydifftools-0.1.40 → pydifftools-0.1.42}/pydifftools/xml2xlsx.vbs +0 -0
  99. {pydifftools-0.1.40 → pydifftools-0.1.42}/pydifftools/zotero.py +0 -0
  100. {pydifftools-0.1.40 → pydifftools-0.1.42}/setup.cfg +0 -0
  101. {pydifftools-0.1.40 → pydifftools-0.1.42}/tests/test_bibliography.py +0 -0
  102. {pydifftools-0.1.40 → pydifftools-0.1.42}/tests/test_browser_lifecycle.py +0 -0
  103. {pydifftools-0.1.40 → pydifftools-0.1.42}/tests/test_check_single_use.py +0 -0
  104. {pydifftools-0.1.40 → pydifftools-0.1.42}/tests/test_command_line_help.py +0 -0
  105. {pydifftools-0.1.40 → pydifftools-0.1.42}/tests/test_comment_migration.py +0 -0
  106. {pydifftools-0.1.40 → pydifftools-0.1.42}/tests/test_continuous_shutdown.py +0 -0
  107. {pydifftools-0.1.40 → pydifftools-0.1.42}/tests/test_forward_search.py +0 -0
  108. {pydifftools-0.1.40 → pydifftools-0.1.42}/tests/test_git_gd_history.py +0 -0
  109. {pydifftools-0.1.40 → pydifftools-0.1.42}/tests/test_git_gd_image.py +0 -0
  110. {pydifftools-0.1.40 → pydifftools-0.1.42}/tests/test_git_gd_qt.py +0 -0
  111. {pydifftools-0.1.40 → pydifftools-0.1.42}/tests/test_rrng.py +0 -0
  112. {pydifftools-0.1.40 → pydifftools-0.1.42}/tests/test_tex_to_qmd.py +0 -0
  113. {pydifftools-0.1.40 → pydifftools-0.1.42}/tests/test_update_check.py +0 -0
  114. {pydifftools-0.1.40 → pydifftools-0.1.42}/tests/test_zotero.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyDiffTools
3
- Version: 0.1.40
3
+ Version: 0.1.42
4
4
  Summary: Diff tools
5
5
  Author: J M Franck
6
6
  License: Copyright (c) 2015, jmfranck
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyDiffTools
3
- Version: 0.1.40
3
+ Version: 0.1.42
4
4
  Summary: Diff tools
5
5
  Author: J M Franck
6
6
  License: Copyright (c) 2015, jmfranck
@@ -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, wrapnumber=55)
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
- upto = min(range(len(counts)), key=lambda j: abs(counts[j] - wrapnumber))
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 (len(word) > 1 and word[-1] in ",;:)-") or offset + j in boundaries
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
- if actual_end > wr_end:
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]
@@ -1314,8 +1339,9 @@ def autofix_markdown_file(filename, wrapnumber=55, punctuation_slop=20):
1314
1339
  @register_command(
1315
1340
  "check wrapping and sentence-break rules (for markdown or latex).",
1316
1341
  "check that a file already obeys wr's wrapping rules -- without\n"
1317
- "rewriting anything. Reports a source line as too long if it holds\n"
1318
- "more words than wr's own greedy choice would put there, and\n"
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"
1319
1345
  "reports a sentence that ends in the middle of a source line\n"
1320
1346
  "instead of at a line break. Prints 'file:line: message' for each\n"
1321
1347
  "violation and exits non-zero if any are found. Takes the same\n"
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "pyDiffTools"
7
- version = "0.1.40"
7
+ version = "0.1.42"
8
8
  authors = [{ name = "J M Franck" }]
9
9
  description = "Diff tools"
10
10
  readme = "README.rst"
@@ -253,6 +253,68 @@ 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 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
259
+ source = (
260
+ "(see @fig:CaldararuTau) indicates that\n"
261
+ "This is especially true, given that a comparison\n"
262
+ )
263
+
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"]
270
+
271
+
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
274
+ line = (
275
+ "Finally, it estimates the rotational correlation time, "
276
+ "*via* the classic Kivelson equation, as a function of temperature.\n"
277
+ )
278
+ path = tmp_path / "source.md"
279
+ path.write_text(line)
280
+
281
+ report = autofix_markdown_file(path, wrapnumber=79)
282
+
283
+ fixed = path.read_text()
284
+ assert fixed.split() == line.split()
285
+ assert all(len(text) <= 79 for text in fixed.splitlines())
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
302
+
303
+
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)
313
+
314
+ assert all(len(line) <= width for line in wrapped.splitlines())
315
+ assert markdown_lint_issues_from_text(wrapped, width) == []
316
+
317
+
256
318
  def test_unclosed_math_is_reported_after_fifty_lines():
257
319
  short_math = "$$\n" + ("x = y\n" * 48)
258
320
  long_math = "$$\n" + ("x = y\n" * 49)
@@ -371,7 +433,7 @@ def test_qt_fix_and_reload_windows_show_source_changes(tmp_path):
371
433
 
372
434
  QTimer.singleShot(0, inspect_fix_window)
373
435
  show_markdown_fix_dialog(report)
374
- assert "↳ of words" in seen["preview"]
436
+ assert "↳ collection of words" in seen["preview"]
375
437
  assert seen["button"] == "Done"
376
438
  assert "1" in seen["line_gutter"]
377
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
- assert "\n > a nested quotation\n" in result
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