mdformat-space-control 0.4.2__tar.gz → 0.4.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mdformat_space_control
3
- Version: 0.4.2
3
+ Version: 0.4.4
4
4
  Summary: An mdformat plugin for space control: EditorConfig indentation, tight lists, frontmatter spacing, smart dash conversion, explicit line breaks, and wikilinks.
5
5
  Project-URL: Homepage, https://github.com/jdmonaco/mdformat-space-control
6
6
  Author-email: Joseph Monaco <joe@selfmotion.net>
@@ -1,6 +1,6 @@
1
1
  """An mdformat plugin for space control: EditorConfig indentation, tight lists, frontmatter spacing, smart dash conversion, soft break joining, and wikilinks."""
2
2
 
3
- __version__ = "0.4.2"
3
+ __version__ = "0.4.4"
4
4
 
5
5
  from .config import (
6
6
  get_current_file,
@@ -411,8 +411,13 @@ def _convert_dash_sequences(text: str) -> str:
411
411
  em_dash_re = re.compile(r"(?<!-)---(?!-)")
412
412
  en_dash_re = re.compile(r"(?<!-)--(?!-)")
413
413
 
414
+ # CLI option pattern: --word or ---word preceded by whitespace or line start
415
+ cli_option_re = re.compile(r"(?<=\s)-{2,3}(?=\w)")
416
+
414
417
  # Lines that are only dashes (thematic breaks, frontmatter delimiters)
418
+ # or separator lines starting/ending with dashes (e.g., "--- Title ---")
415
419
  only_dashes_re = re.compile(r"^-{2,}\s*$")
420
+ separator_line_re = re.compile(r"^-{2,3}\s+.*\s+-{2,3}\s*$")
416
421
 
417
422
  lines = text.split("\n")
418
423
  result = []
@@ -431,7 +436,7 @@ def _convert_dash_sequences(text: str) -> str:
431
436
  if "-->" in line:
432
437
  in_html_comment = False
433
438
  result.append(line)
434
- elif only_dashes_re.match(line):
439
+ elif only_dashes_re.match(line) or separator_line_re.match(stripped):
435
440
  result.append(line)
436
441
  else:
437
442
  # Check for multi-line HTML comment opening (no closing on same line)
@@ -453,6 +458,9 @@ def _convert_dash_sequences(text: str) -> str:
453
458
  protected = html_comment_re.sub(_save_placeholder, protected)
454
459
  protected = html_tag_re.sub(_save_placeholder, protected)
455
460
 
461
+ # Protect CLI option dashes (e.g., --output, ---long-opt)
462
+ protected = cli_option_re.sub(_save_placeholder, protected)
463
+
456
464
  # Convert em-dash first (longer match), then en-dash
457
465
  protected = em_dash_re.sub("\u2014", protected)
458
466
  protected = en_dash_re.sub("\u2013", protected)