From 2b5cb5ebf0ee18dc90fa50947a99eb5b8960eb2d Mon Sep 17 00:00:00 2001 From: James Campos Date: Mon, 20 Apr 2020 18:13:59 -0700 Subject: bold headers --- src/main.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index fd09913..47a1c66 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,7 +6,7 @@ use crossterm::{ cursor, event::{read, Event, KeyCode, KeyEvent}, queue, - style::Print, + style::{Attribute, Print}, terminal, }; @@ -137,7 +137,21 @@ impl Bk { let mut chapter = Vec::new(); for n in doc.descendants() { match n.tag_name().name() { - "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "p" => { + "h1" | "h2" | "h3" | "h4" | "h5" | "h6" => { + let text: String = n + .descendants() + .filter(|n| n.is_text()) + .map(|n| n.text().unwrap()) + .collect(); + chapter.push(format!( + "{}{}{}", + Attribute::Bold, + text, + Attribute::Reset + )); + chapter.push(String::from("")); + } + "p" => { chapter.push( n.descendants() .filter(|n| n.is_text()) -- cgit v1.2.3