use crate::citation_regex::CITATION_REGEX; use pulldown_cmark::CodeBlockKind; use pulldown_cmark::CowStr; use pulldown_cmark::Event; use pulldown_cmark::HeadingLevel; use pulldown_cmark::Options; use pulldown_cmark::Parser; use pulldown_cmark::Tag; use pulldown_cmark::TagEnd; use ratatui::style::Style; use ratatui::style::Stylize; use ratatui::text::Line; use ratatui::text::Span; use ratatui::text::Text; use std::borrow::Cow; use std::path::Path; #[derive(Clone, Debug)] struct IndentContext { prefix: Vec>, marker: Option>>, is_list: bool, } impl IndentContext { fn new(prefix: Vec>, marker: Option>>, is_list: bool) -> Self { Self { prefix, marker, is_list, } } } #[allow(dead_code)] pub(crate) fn render_markdown_text(input: &str) -> Text<'static> { let mut options = Options::empty(); options.insert(Options::ENABLE_STRIKETHROUGH); let parser = Parser::new_ext(input, options); let mut w = Writer::new(parser, None, None); w.run(); w.text } pub(crate) fn render_markdown_text_with_citations( input: &str, scheme: Option<&str>, cwd: &Path, ) -> Text<'static> { let mut options = Options::empty(); options.insert(Options::ENABLE_STRIKETHROUGH); let parser = Parser::new_ext(input, options); let mut w = Writer::new(parser, scheme.map(str::to_string), Some(cwd.to_path_buf())); w.run(); w.text } struct Writer<'a, I> where I: Iterator>, { iter: I, text: Text<'static>, inline_styles: Vec