aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Campos <james.r.campos@gmail.com>2020-04-19 00:35:25 -0700
committerJames Campos <james.r.campos@gmail.com>2020-04-19 00:35:25 -0700
commitd2991ae015555d4982bc27e1e492c8483e5313c8 (patch)
treebf1bddee12a0e570a02d4df5a2dfcefa176d6739
parentee203199d2b270035122e67b56fa17b422a44703 (diff)
downloadbk-d2991ae015555d4982bc27e1e492c8483e5313c8.tar.gz
vertical padding
-rw-r--r--src/main.rs15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/main.rs b/src/main.rs
index 8ba4bca..877f9e3 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -133,17 +133,20 @@ impl Bk {
"h1" | "h2" | "h3" | "h4" | "h5" | "h6" => {
let text = n.descendants().find(|n| n.is_text()).unwrap();
chapter.push(format!("# {}", text.text().unwrap()));
+ chapter.push(String::from(""));
}
- "div" => chapter.push(String::from("")),
- "p" => chapter.push(
- n.descendants()
+ //"div" => chapter.push(String::from("")),
+ "p" => {
+ chapter.push(n.descendants()
.filter(|n| n.is_text())
.map(|n| n.text().unwrap())
- .collect(),
- ),
+ .collect());
+ chapter.push(String::from(""));
+ }
_ => (),
}
}
+ chapter.pop();//padding
self.chapter = wrap(chapter, self.cols - self.pad);
}
fn run(&mut self, code: KeyCode) -> bool {
@@ -180,7 +183,7 @@ impl Bk {
| KeyCode::Char('l')
| KeyCode::Char(' ') => {
self.pos += self.rows;
- if self.pos > self.chapter.len() {
+ if self.pos >= self.chapter.len() {
self.chapter_idx += 1;
self.load_chapter();
self.pos = 0;