aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJames Campos <james.r.campos@gmail.com>2020-04-20 18:13:59 -0700
committerJames Campos <james.r.campos@gmail.com>2020-04-20 18:13:59 -0700
commit2b5cb5ebf0ee18dc90fa50947a99eb5b8960eb2d (patch)
treee2eb5a0eb86bea5bdb1b114a4bd2565cf299605f /src
parentbca9e9a25abd144d0c2a81a03dcb0e14e7ac257d (diff)
downloadbk-2b5cb5ebf0ee18dc90fa50947a99eb5b8960eb2d.tar.gz
bold headers
Diffstat (limited to 'src')
-rw-r--r--src/main.rs18
1 files changed, 16 insertions, 2 deletions
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())