Render markdown with caching. Returns cached result if content+width match.
(&mut self, content: &str, width: usize)
| 38 | |
| 39 | /// Render markdown with caching. Returns cached result if content+width match. |
| 40 | pub fn render_cached(&mut self, content: &str, width: usize) -> Vec<Line<'static>> { |
| 41 | let key = Self::cache_key(content, width); |
| 42 | if let Some(cached) = self.cache.get(&key) { |
| 43 | return cached.clone(); |
| 44 | } |
| 45 | let lines = self.render(content, width); |
| 46 | self.cache.insert(key, lines.clone()); |
| 47 | lines |
| 48 | } |
| 49 | |
| 50 | /// Clear the markdown render cache (e.g. on session switch) |
| 51 | pub fn clear_cache(&mut self) { |
no test coverage detected