Fixed markdown white space issue.
This commit is contained in:
parent
b5897a2298
commit
9990a37352
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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(),
|
||||
|
|
Loading…
Reference in New Issue