summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/markdown/src/main.rs2
-rw-r--r--widget/src/markdown.rs10
2 files changed, 6 insertions, 6 deletions
diff --git a/examples/markdown/src/main.rs b/examples/markdown/src/main.rs
index 2361b7b7..5b9a3b4a 100644
--- a/examples/markdown/src/main.rs
+++ b/examples/markdown/src/main.rs
@@ -74,7 +74,7 @@ impl Markdown {
if enable_stream {
self.mode = Mode::Stream {
pending: self.content.text(),
- parsed: markdown::Content::parse(""),
+ parsed: markdown::Content::new(),
};
scrollable::snap_to(
diff --git a/widget/src/markdown.rs b/widget/src/markdown.rs
index 77a560ec..b4b89095 100644
--- a/widget/src/markdown.rs
+++ b/widget/src/markdown.rs
@@ -66,13 +66,17 @@ pub use core::text::Highlight;
pub use pulldown_cmark::HeadingLevel;
pub use url::Url;
-#[derive(Debug)]
+#[derive(Debug, Default)]
pub struct Content {
items: Vec<Item>,
state: State,
}
impl Content {
+ pub fn new() -> Self {
+ Self::default()
+ }
+
pub fn parse(markdown: &str) -> Self {
let mut state = State::default();
let items = parse_with(&mut state, markdown).collect();
@@ -595,16 +599,12 @@ fn parse_with<'a>(
pulldown_cmark::Event::Text(text) if !metadata && !table => {
#[cfg(feature = "highlighter")]
if let Some(highlighter) = &mut highlighter {
- let start = std::time::Instant::now();
-
for line in text.lines() {
spans.extend_from_slice(
highlighter.highlight_line(&format!("{line}\n")),
);
}
- dbg!(start.elapsed());
-
return None;
}