Lenient scan for a single `:::memory` container fence, returning its inner body if present. Unlike the closed-vocabulary [`crate::directive`] parser, this never errors on unrelated `::`/`:::` tokens in the open memory prose — only a recognized fence (a name in [`LIFTED_MEMORY_DIRECTIVES`]) is treated as structure; everything else is content. An unterminated fence falls back to the whole body (fail
(body: &str)
| 183 | /// as structure; everything else is content. An unterminated fence falls back |
| 184 | /// to the whole body (fail-open, preserving content). |
| 185 | fn extract_memory_container(body: &str) -> Option<String> { |
| 186 | let lines: Vec<&str> = body.lines().collect(); |
| 187 | let mut i = 0; |
| 188 | while i < lines.len() { |
| 189 | if let Some(name) = container_open_name(lines[i].trim_start()) { |
| 190 | if LIFTED_MEMORY_DIRECTIVES.contains(&name) { |
| 191 | let mut collected: Vec<&str> = Vec::new(); |
| 192 | i += 1; |
| 193 | while i < lines.len() { |
| 194 | if lines[i].trim() == ":::" { |
| 195 | return Some(collected.join("\n").trim().to_string()); |
| 196 | } |
| 197 | collected.push(lines[i]); |
| 198 | i += 1; |
| 199 | } |
| 200 | return None; // unterminated → fall back to whole body |
| 201 | } |
| 202 | } |
| 203 | i += 1; |
| 204 | } |
| 205 | None |
| 206 | } |
| 207 | |
| 208 | /// If `line` opens a container directive (`:::name` optionally with `{...}`), |
| 209 | /// return the directive name. A bare `:::` (a close) yields `None`. |
no test coverage detected