fix: convert markdown headings to bold in show command for Matrix rendering
Element X doesn't style <h2> tags distinctly. Convert ## headings to **bold** text with a blank line above for consistent rendering across all Matrix clients. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -34,9 +34,31 @@ pub(super) fn handle_show(ctx: &CommandContext) -> Option<String> {
|
|||||||
|
|
||||||
// `content` comes from the CRDT / content store. If unavailable, report
|
// `content` comes from the CRDT / content store. If unavailable, report
|
||||||
// it rather than silently reading a stale on-disk copy.
|
// it rather than silently reading a stale on-disk copy.
|
||||||
Some(content.unwrap_or_else(|| {
|
let text = content.unwrap_or_else(|| {
|
||||||
format!("Story {story_id} found in pipeline but its content is unavailable.")
|
format!("Story {story_id} found in pipeline but its content is unavailable.")
|
||||||
}))
|
});
|
||||||
|
|
||||||
|
// Convert markdown headings to bold text for consistent rendering across
|
||||||
|
// Matrix clients. Element X doesn't style <h2> tags distinctly, but bold
|
||||||
|
// text renders consistently everywhere.
|
||||||
|
let formatted = text
|
||||||
|
.lines()
|
||||||
|
.map(|line| {
|
||||||
|
let trimmed = line.trim_start();
|
||||||
|
if let Some(rest) = trimmed.strip_prefix("### ") {
|
||||||
|
format!("\n**{}**", rest)
|
||||||
|
} else if let Some(rest) = trimmed.strip_prefix("## ") {
|
||||||
|
format!("\n**{}**", rest)
|
||||||
|
} else if let Some(rest) = trimmed.strip_prefix("# ") {
|
||||||
|
format!("\n**{}**", rest)
|
||||||
|
} else {
|
||||||
|
line.to_string()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.collect::<Vec<_>>()
|
||||||
|
.join("\n");
|
||||||
|
|
||||||
|
Some(formatted)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|||||||
Reference in New Issue
Block a user