Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
fix(help): treat an HTML comment inside a code block as content (#3908)
Worktrunk Bot496c5711541e
diff --git a/src/md_help.rs b/src/md_help.rsindex d9175d0b8..96e405c98 100644--- a/src/md_help.rs+++ b/src/md_help.rs@@ -85,7 +85,10 @@ fn render_markdown(help: &str, width: Option<usize>, code_blocks: CodeBlocks) ->// HTML comments are expansion markers for web docs (see readme_sync.rs) and// don't render. A `<!-- wt list … -->` marker tags the captured `wt list`// output that immediately follows, so the next code block is chopped (below).- if trimmed.starts_with("<!--") && trimmed.ends_with("-->") {+ // Only outside a fence: inside one the same text is content the block is+ // showing, and the picker's `pr`/comments panes render arbitrary forge+ // markdown, where a fenced HTML sample would otherwise lose the line.+ if !in_code_block && trimmed.starts_with("<!--") && trimmed.ends_with("-->") {let inner = trimmed.trim_start_matches("<!--").trim_end_matches("-->")@@ -719,6 +722,34 @@ mod tests {assert_snapshot!(result, @"visible");}+ #[test]+ fn test_html_comment_inside_a_code_block_is_content() {+ // The comment branch used to run before the fence check, so a fenced+ // line that happened to be an HTML comment was swallowed instead of+ // rendered. The picker's `pr` and comments panes render arbitrary forge+ // markdown through this function, where a fenced HTML sample is+ // ordinary content — and a fenced `<!-- wt list -->` would additionally+ // arm the chop marker for whatever block came next.+ let result = render_markdown_flush("```html\n<!-- a comment -->\n<p>body</p>\n```", None);+ assert_snapshot!(result, @"+ [2m<!-- a comment -->[0m+ [2m<p>body</p>[0m+ ");++ // The gutter path renders it too, and the marker inside the fence does+ // not leak into the following block.+ let guttered =+ render_markdown_in_help("```\n<!-- wt list -->\n```\n\n```console\n$ wt\n```");+ assert_snapshot!(guttered, @"+ [107m [0m [2m<!-- wt list -->[0m++ [107m [0m [2m[0m[2m[34mwt[0m+ ");++ // Outside a fence it is still a marker, not content.+ assert_snapshot!(render_markdown_in_help("<!-- wt list -->"), @"");+ }+#[test]fn test_render_markdown_in_help_plain_text() {let result = render_markdown_in_help("Just plain text");