Skip to content

feat(reflow): add atomic_spans configuration and refactor inline wrapping#742

Merged
rvben merged 6 commits into
rvben:mainfrom
chandlerc:featreflow-add-atomicspans-configuration/zovxzmvkpnzv
Jul 19, 2026
Merged

feat(reflow): add atomic_spans configuration and refactor inline wrapping#742
rvben merged 6 commits into
rvben:mainfrom
chandlerc:featreflow-add-atomicspans-configuration/zovxzmvkpnzv

Conversation

@chandlerc

Copy link
Copy Markdown
Contributor

Introduce atomic_spans configuration (defaulting to true) to MD013
to control whether inline formatting spans (emphasis, strong, strikethrough,
and code spans) are treated as atomic units or allowed to wrap at whitespace.

Refactor wrapping and sentence-splitting logic with extensive optimizations:

  • Add safety guards in eligibility checks to prevent wrapping inside spans
    that contain nested format markers (*, _, ~, ```), preventing syntax
    corruption.
  • Prevent wrapping from starting a line with definition lists (:), Pandoc
    divs (:::), or table rows (|) to avoid accidental block construct triggers.
  • Optimize sentence boundary checks from O(N^2) to O(1) by passing pre-computed
    byte offsets, resolving performance scaling bottlenecks.
  • Eliminate paragraph-sized Vec<bool> mask allocations for inline code spans by
    maintaining sorted code span indexes inline.
  • Implement allocation-free Element::display_len to avoid string formatting
    just to measure visual lengths, and defer format!("{element}") calls to the
    final emission.
  • Optimize config budget calculation in min_effective_line_length using stack-
    allocated arrays instead of vectors.
  • Single-pass character collection in the sentence splitter.

Reverts the three emphasis_spans commits that this replaces.

Assisted-by: Antigravity with Gemini

chandlerc and others added 6 commits July 18, 2026 20:34
…ping

Introduce `atomic_spans` configuration (defaulting to true) to MD013
to control whether inline formatting spans (emphasis, strong, strikethrough,
and code spans) are treated as atomic units or allowed to wrap at whitespace.

Refactor wrapping and sentence-splitting logic with extensive optimizations:
- Add safety guards in eligibility checks to prevent wrapping inside spans
  that contain nested format markers (`*`, `_`, `~`, `` ` ``), preventing syntax
  corruption.
- Prevent wrapping from starting a line with definition lists (`:`), Pandoc
  divs (`:::`), or table rows (`|`) to avoid accidental block construct triggers.
- Optimize sentence boundary checks from O(N^2) to O(1) by passing pre-computed
  byte offsets, resolving performance scaling bottlenecks.
- Eliminate paragraph-sized `Vec<bool>` mask allocations for inline code spans by
  maintaining sorted code span indexes inline.
- Implement allocation-free `Element::display_len` to avoid string formatting
  just to measure visual lengths, and defer `format!("{element}")` calls to the
  final emission.
- Optimize config budget calculation in `min_effective_line_length` using stack-
  allocated arrays instead of vectors.
- Single-pass character collection in the sentence splitter.

Assisted-by: Antigravity with Gemini
@rvben
rvben merged commit aeabec1 into rvben:main Jul 19, 2026
14 checks passed
@chandlerc
chandlerc deleted the featreflow-add-atomicspans-configuration/zovxzmvkpnzv branch July 20, 2026 08:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants