Repository: iced-rs/iced (language: rust)

Issue:
Incorrect parsing of nested lists in markdown
### Is your issue REALLY a bug?

- [X] My issue is indeed a bug!
- [X] I am not crazy! I will not fill out this form just to ask a question or request a feature. Pinky promise.

### Is there an existing issue for this?

- [X] I have searched the existing issues.

### Is this issue related to iced?

- [X] My hardware is compatible and my graphics drivers are up-to-date.

### What happened?

The `markdown::parse` function incorrectly parses nested lists, if there is no empty line before starting nested list.

Here is the problematic markdown content:
```markdown
**Expected**

- first
- second

    - nested first
    - nested second

- third


**Actual**

- first
- second
    - nested first
    - nested second
- third
```

# Rendered by Github
**Expected**

- first
- second

    - nested first
    - nested second

- third


**Actual**

- first
- second
    - nested first
    - nested second
- third

# Rendered in Iced
![image](https://github.com/user-attachments/assets/9828dfae-10ec-477d-82fa-5eb303537d18)



### What is the expected behavior?

I expected the lists to look like this:
![image](https://github.com/user-attachments/assets/45e1b34b-aa9e-43f6-899b-ca3883cb258a)

I already implemented this fix in my fork here: https://github.com/Jinderamarak/iced/commit/5e7faec3c49ad71c8ac103dd318adb38b3fb1582

### Version

crates.io release

### Operating System

Windows

### Do you have any log output?

_No response_


Discussion / hints:

Fix patch:
diff --git a/widget/src/markdown.rs b/widget/src/markdown.rs
index d6bebb9b82..c0648e9e10 100644
--- a/widget/src/markdown.rs
+++ b/widget/src/markdown.rs
@@ -305,12 +305,21 @@ pub fn parse(markdown: &str) -> impl Iterator<Item = Item> + '_ {
                 None
             }
             pulldown_cmark::Tag::List(first_item) if !metadata && !table => {
+                let prev = if spans.is_empty() {
+                    None
+                } else {
+                    produce(
+                        &mut lists,
+                        Item::Paragraph(Text::new(spans.drain(..).collect())),
+                    )
+                };
+
                 lists.push(List {
                     start: first_item,
                     items: Vec::new(),
                 });
 
-                None
+                prev
             }
             pulldown_cmark::Tag::Item => {
                 lists


Test patch: