ratatui_toolkit/widgets/markdown_widget/extensions/toc/methods/required_height.rs
1//! Static method to calculate required TOC height.
2
3use super::super::Toc;
4
5impl<'a> Toc<'a> {
6 /// Calculate the required height for expanded mode.
7 ///
8 /// Accounts for border (2 rows) and one row per entry.
9 ///
10 /// # Arguments
11 ///
12 /// * `content` - The markdown content to scan.
13 /// * `show_border` - Whether the border is shown.
14 ///
15 /// # Returns
16 ///
17 /// The required height in rows.
18 pub fn required_height(content: &str, show_border: bool) -> u16 {
19 let heading_count = Self::count_headings(content) as u16;
20 let border_height = if show_border { 2 } else { 0 };
21 heading_count + border_height
22 }
23}