Skip to content

Commit 095859e

Browse files
committed
Add new constructor for markdown::Content
1 parent bc2d662 commit 095859e

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

examples/markdown/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ impl Markdown {
7474
if enable_stream {
7575
self.mode = Mode::Stream {
7676
pending: self.content.text(),
77-
parsed: markdown::Content::parse(""),
77+
parsed: markdown::Content::new(),
7878
};
7979

8080
scrollable::snap_to(

widget/src/markdown.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,17 @@ pub use core::text::Highlight;
6666
pub use pulldown_cmark::HeadingLevel;
6767
pub use url::Url;
6868

69-
#[derive(Debug)]
69+
#[derive(Debug, Default)]
7070
pub struct Content {
7171
items: Vec<Item>,
7272
state: State,
7373
}
7474

7575
impl Content {
76+
pub fn new() -> Self {
77+
Self::default()
78+
}
79+
7680
pub fn parse(markdown: &str) -> Self {
7781
let mut state = State::default();
7882
let items = parse_with(&mut state, markdown).collect();
@@ -595,16 +599,12 @@ fn parse_with<'a>(
595599
pulldown_cmark::Event::Text(text) if !metadata && !table => {
596600
#[cfg(feature = "highlighter")]
597601
if let Some(highlighter) = &mut highlighter {
598-
let start = std::time::Instant::now();
599-
600602
for line in text.lines() {
601603
spans.extend_from_slice(
602604
highlighter.highlight_line(&format!("{line}\n")),
603605
);
604606
}
605607

606-
dbg!(start.elapsed());
607-
608608
return None;
609609
}
610610

0 commit comments

Comments
 (0)