feat(outline): convert to post — S4 (#114)
CI / ci (push) Canceled after 0s
CI / ci (push) Canceled after 0s
In-place outline→post conversion on the piece: id, folder, Pass State, origin kept, type frontmatter flips to post, body transforms once. The ask picks the transform — Verbatim Bullets (default, lossless) or Headings ladder (roots ##, stepping to the ###### floor, deeper stays bullets), with a warning when the ladder would drop paragraph lines between bullets. The open session flushes first, then reopens routed to prose via proseOverridePostID (lastDraftWasOutline's machinery reversed). An outline that went lossy on disk behind an unwarned ask aborts the convert; an unanswered #67 conflict aborts every flush-first op (shared flushOrAbort seam); rescan no longer hands a same-id reopened session its predecessor's stale disk text; a held #111 guard ask dies with the outline it pointed at. Audit round (finish-audit, three reviewers) included: 13 new pins, 206 tests green, pin discrimination verified. Record: docs/devlog/20261016-issue114-convert-to-post_log.md
This commit is contained in:
1 parent
21e2f27450
commit
c0513aae85
14 files changed
+547
-19
No files matched your search
@@ -72,6 +72,25 @@ nonisolated enum OutlineTree {
|
||||
return lines.joined(separator: "\n")
|
||||
}
|
||||
|
||||
/// #114 (S4): the headings-ladder conversion body — outline body in,
|
||||
/// post body out. Roots become `##`, each deeper level steps one
|
||||
/// heading down to the `######` floor; deeper levels stay bullets
|
||||
/// (indent re-based so the first bullet level sits flush under the
|
||||
/// floor). Preamble rides verbatim above — `# Title` survives.
|
||||
/// Mixed content: parse drops prose lines (the convert ask warns).
|
||||
static func headingsLadderBody(_ markdown: String) -> String {
|
||||
let (preamble, items) = scan(markdown)
|
||||
var lines = preamble
|
||||
for (depth, text) in items {
|
||||
if depth <= 4 {
|
||||
lines.append(String(repeating: "#", count: depth + 2) + " " + text)
|
||||
} else {
|
||||
lines.append(String(repeating: " ", count: depth - 5) + "- " + text)
|
||||
}
|
||||
}
|
||||
return lines.joined(separator: "\n")
|
||||
}
|
||||
|
||||
/// Lines → (verbatim preamble, flat clamped items). Trailing blank lines
|
||||
/// are noise — dropping them makes "" parse to ([], []).
|
||||
private static func scan(_ markdown: String) -> (preamble: [String], items: [(depth: Int, text: String)]) {
|
||||
|
||||
Reference in new issue
Block a user