diff --git a/TODO/Widgets.md b/TODO/Widgets.md index f20f116c0..7de54a16e 100644 --- a/TODO/Widgets.md +++ b/TODO/Widgets.md @@ -15,14 +15,13 @@ Widget that need to be implemented. * Slider. * ToolTip. * Resize parent. -* Basic markdown view. * Charts. * Media (audio & video). * Image effects. -* Markdown. * Massive images (deep zoom). * SVG images. -* Html (CSS, no Js). +* HTML (CSS, no Js). +* Full Markdown (HTML+CSS). * Diagram editor. * Rich text editor. * Browser hosting. diff --git a/TODO/_current.md b/TODO/_current.md index f93084a11..cd4ccd443 100644 --- a/TODO/_current.md +++ b/TODO/_current.md @@ -48,7 +48,6 @@ # Markdown/Scroll -* Markdown "can `inline`" does not render separated with space. * Markdown scrolls on init if only focusable is not in view. # Publish diff --git a/zero-ui/src/widgets/markdown.rs b/zero-ui/src/widgets/markdown.rs index 549862943..52d9baed5 100644 --- a/zero-ui/src/widgets/markdown.rs +++ b/zero-ui/src/widgets/markdown.rs @@ -430,7 +430,7 @@ fn markdown_view_fn(md: &str) -> impl UiNode { match WhiteSpace::MergeAll.transform(&txt) { std::borrow::Cow::Borrowed(_) => { if starts_with_space && last_txt_end != '\0' || !txt.is_empty() && last_txt_end.is_whitespace() { - txt.to_mut().insert(0, '\u{20}'); + txt.to_mut().insert(0, ' '); } txt.end_mut(); last_txt_end = txt_end; @@ -439,7 +439,7 @@ fn markdown_view_fn(md: &str) -> impl UiNode { txt = t; if !txt.is_empty() { if starts_with_space && last_txt_end != '\0' || !txt.is_empty() && last_txt_end.is_whitespace() { - txt.to_mut().insert(0, '\u{20}'); + txt.to_mut().insert(0, ' '); txt.end_mut(); } last_txt_end = txt_end; @@ -468,6 +468,21 @@ fn markdown_view_fn(md: &str) -> impl UiNode { } Event::Code(txt) => { let txt = html_escape::decode_html_entities(txt.as_ref()); + + if last_txt_end.is_whitespace() { + inlines.push( + text_view(TextFnArgs { + txt: ' '.into(), + style: MarkdownStyle { + strong: strong > 0, + emphasis: emphasis > 0, + strikethrough: strikethrough > 0, + }, + }) + .boxed(), + ); + } + inlines.push( code_inline_view(CodeInlineFnArgs { txt: txt.to_text(),