diff options
| author | Ben Bridle <ben@derelict.engineering> | 2026-11-10 11:42:48 +1300 |
|---|---|---|
| committer | Ben Bridle <ben@derelict.engineering> | 2026-11-10 11:42:48 +1300 |
| commit | 44ef17ff1a6c69a73ad5fd1e9e727386ef1890ee (patch) | |
| tree | 1e4ff637a743a7aa9216055decb0cd385893cc80 | |
| parent | e7691befe7322df597c97d54c82d143eb1247555 (diff) | |
| download | toaster-44ef17ff1a6c69a73ad5fd1e9e727386ef1890ee.zip | |
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.
| -rw-r--r-- | src/generate_html.rs | 19 |
1 files changed, 14 insertions, 5 deletions
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"); } |
