From 44ef17ff1a6c69a73ad5fd1e9e727386ef1890ee Mon Sep 17 00:00:00 2001 From: Ben Bridle Date: Tue, 10 Nov 2026 11:42:48 +1300 Subject: Add 'faded' class to parenthesised text in table cells If the entire span of text in a table cell is wrapped in parentheses, that text is now marked with the 'faded' class in the generated HTML to allow the CSS to make it display less prominently. --- src/generate_html.rs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'src/generate_html.rs') diff --git a/src/generate_html.rs b/src/generate_html.rs index 353d1fb..6919b5f 100644 --- a/src/generate_html.rs +++ b/src/generate_html.rs @@ -378,12 +378,12 @@ pub fn document_to_html(page: &Page, website: &Website) -> String { for section in &table.sections { wrap!("tbody", for row in section { wrap!("tr", for (column, cell) in std::iter::zip(&table.columns, row) { - let text_raw = line_to_html!(cell).trim().to_string(); - let text_cmp = text_raw.to_lowercase().to_string(); + let text_html = line_to_html!(cell).trim().to_string(); + let text_cmp = cell.to_string().trim().to_lowercase().to_string(); let text = match text_cmp.as_str() { "yes" => "✓", "no" => "✗", - _ => &text_raw, + _ => &text_html, }; let mut class = match text { "--" => "c", @@ -393,9 +393,18 @@ pub fn document_to_html(page: &Page, website: &Website) -> String { Alignment::Right => "r", }, }.to_string(); - if ["no", "--", "0"].contains(&text_cmp.as_str()) { + let is_null = ["no", "--", "0"].contains(&text_cmp.as_str()); + let is_paren = text_cmp.starts_with('(') && text_cmp.ends_with(')'); + let is_regular_text = cell.tokens.iter().all(|t| match t { + Token::Normal(_) | Token::Bold(_) | Token::Italic(_) => true, + _ => false, + }); + if is_null { class.push_str(" dim"); - }; + } + if is_paren && is_regular_text { + class.push_str(" faded"); + } if column.border_right { class.push_str(" border"); } -- cgit v1.3.1