Module: Coradoc::IncludeSelectors::LevelOffset
- Defined in:
- lib/coradoc/include_selectors/level_offset.rb
Overview
Shifts section heading levels in a parsed CoreModel subtree.
Applied AFTER parsing — works on SectionElement instances. Two modes:
relative (+N / -N) every SectionElement#level += delta
absolute (N) the FIRST section's level becomes N, and
descendants shift by the same delta so their
relative structure is preserved (asciidoctor
behavior).
The processor passes a freshly-parsed subtree to this selector, so there are no external references and in-place mutation is safe.
Class Method Summary collapse
-
.call(core, options:) ⇒ Coradoc::CoreModel::Base
The same core (mutated).
Class Method Details
.call(core, options:) ⇒ Coradoc::CoreModel::Base
Returns the same core (mutated).
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/coradoc/include_selectors/level_offset.rb', line 21 def self.call(core, options:) offset = .leveloffset return core if offset.nil? first_level = find_first_level(core) actual_delta = compute_actual_delta(offset, first_level) return core if actual_delta.zero? walk_and_shift(core, actual_delta) core end |