Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions internal/richtext/richtext.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ func MarkdownToHTML(md string) string {
inList = true
listType = "ul"
}
pendingBreak = false // blank was between items, not after the list
listItems = append(listItems, convertInline(ulMatch[2]))
continue
}
Expand All @@ -241,15 +242,17 @@ func MarkdownToHTML(md string) string {
inList = true
listType = "ol"
}
pendingBreak = false // blank was between items, not after the list
listItems = append(listItems, convertInline(olMatch[2]))
continue
}

// Empty line - handle differently based on context
if strings.TrimSpace(line) == "" {
if inList {
// In a list: empty lines between items create spacing but don't break the list
// We'll track this for later when we render the list
// In a list: empty lines between items create spacing but don't break the list.
// Record pending break so content after the list gets proper separation.
pendingBreak = true
Comment thread
jeremy marked this conversation as resolved.
continue
Comment thread
jeremy marked this conversation as resolved.
}
// Not in a list: flush paragraph and record break
Expand All @@ -269,6 +272,7 @@ func MarkdownToHTML(md string) string {
// Append to last list item with <br> separator
lastItemIndex := len(listItems) - 1
listItems[lastItemIndex] = listItems[lastItemIndex] + "<br>\n" + convertInline(trimmedLine)
pendingBreak = false // blank was before continuation, not after the list
continue
}
}
Expand Down
10 changes: 10 additions & 0 deletions internal/richtext/richtext_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,16 @@ func TestMarkdownToHTML(t *testing.T) {
input: "1. **Item** - [Link](url) (time) \n Description here\n\n2. **Next** - [Link](url)",
expected: "<ol>\n<li><strong>Item</strong> - <a href=\"url\">Link</a> (time) <br>\nDescription here</li>\n<li><strong>Next</strong> - <a href=\"url\">Link</a></li>\n</ol>",
},
{
name: "list followed by blank line then paragraph",
input: "- Item 1\n- Item 2\n\nFollowing paragraph.",
expected: "<ul>\n<li>Item 1</li>\n<li>Item 2</li>\n</ul>\n<br>\n<p>Following paragraph.</p>",
},
{
name: "blank between list items does not leak break after list",
input: "- One\n\n- Two\nAfter",
expected: "<ul>\n<li>One</li>\n<li>Two</li>\n</ul>\n<p>After</p>",
},
{
name: "blockquote",
input: "> This is a quote",
Expand Down
Loading