Expand description
Shared sentinel-block primitives used by shells::profile and
sys::profile to find, extract, remove, and insert the
# >>> ... >>> / # <<< ... <<< blocks shine writes into user-owned
shell profile files.
Two removal styles are kept deliberately separate (remove_block_bytewise
vs remove_block_linewise): they differ in preceding-blank-line
handling and CRLF behavior (see each function’s docs), and canonicalizing
them without golden-output proof that neither caller depends on the
difference would risk a silent formatting regression in a file shine does
not own. Do not merge them without characterization tests confirming both
callers’ current byte-for-byte output is preserved.
Structs§
- Sentinel
- A sentinel marker pair, e.g.
("# >>> shine >>>", "# <<< shine <<<").
Enums§
- Insert
At - Where to insert a block relative to existing content, for
insert_block.
Functions§
- extract_
block_ with_ newline - Like
find_block, but also includes one trailing'\n'immediately after the end marker if present. The end marker is searched for only after the start marker, so an end marker that appears before the start marker is not matched. - find_
block - Returns the substring from the start marker through the end marker
(inclusive), or
Noneif either marker is missing. Does not include any trailing newline after the end marker. - insert_
block - Inserts
blockintocontent, separated from any existing content by exactly one blank line (regardless of whetherblockorcontentalready end/start with a newline). Whencontentis empty, no leading/trailing blank line is added — the result is justblock. - remove_
block_ bytewise - Byte-offset block removal (
shells::profile’s semantics). - remove_
block_ linewise - Line-based block removal (
sys::profile’s semantics). - trim_
outer_ blank_ lines - Trims all leading and trailing
'\n'characters (not just one).