diff options
author | Lars Wirzenius <liw@liw.fi> | 2023-10-31 09:52:34 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2023-10-31 09:52:34 +0200 |
commit | a53c5c551a513375bf66d551b9f72e02eb1003ff (patch) | |
tree | 41d50b6db9238b3ceb383b6032957e4c104ec9f2 | |
parent | 93b2a8382607d35435518ea73308dee72fb6e547 (diff) | |
download | subplot-a53c5c551a513375bf66d551b9f72e02eb1003ff.tar.gz |
feat: add some HTML class attributes
This is a start. We'll need to add more as we add more support for
styling the output.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
Sponsored-by: author
-rw-r--r-- | src/doc.rs | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -234,13 +234,19 @@ impl Document { assert!(level <= 6); let mut number = Element::new(ElementTag::Span); + number.push_attribute(Attribute::new("class", "heading-number")); number.push_child(Content::Text(numberer.number(level))); + let mut htext = Element::new(ElementTag::Span); + htext.push_attribute(Attribute::new("class", "heading-text")); + htext.push_child(Content::Text(text)); + let mut a = Element::new(ElementTag::A); a.push_attribute(crate::html::Attribute::new("href", &format!("#{}", id))); + a.push_attribute(Attribute::new("class", "toc-link")); a.push_child(Content::Elt(number)); a.push_child(Content::Text(" ".into())); - a.push_child(Content::Text(text)); + a.push_child(Content::Elt(htext)); let mut li = Element::new(ElementTag::Li); li.push_child(Content::Elt(a)); @@ -288,6 +294,7 @@ impl Document { fn typeset_meta(&self) -> Element { let mut div = Element::new(ElementTag::Div); + div.push_attribute(Attribute::new("class", "meta")); div.push_child(Content::Elt(Self::title(self.meta.title()))); @@ -304,12 +311,14 @@ impl Document { fn title(title: &str) -> Element { let mut e = Element::new(ElementTag::H1); + e.push_attribute(Attribute::new("class", "title")); e.push_child(Content::Text(title.into())); e } fn authors(authors: &[String]) -> Element { let mut list = Element::new(ElementTag::P); + list.push_attribute(Attribute::new("class", "authors")); list.push_child(Content::Text("By: ".into())); let mut first = true; for a in authors { @@ -324,6 +333,7 @@ impl Document { fn date(date: &str) -> Element { let mut e = Element::new(ElementTag::P); + e.push_attribute(Attribute::new("class", "date")); e.push_child(Content::Text(date.into())); e } |