majc: fix rendering of gemlog.blue

This commit is contained in:
Cadey Ratio 2020-07-28 16:02:48 -04:00
parent 70074e0075
commit 93a5dd445a
7 changed files with 37 additions and 9 deletions

View File

@ -1,6 +1,6 @@
[package]
name = "maj"
version = "0.4.1"
version = "0.4.2"
authors = ["Christine Dodrill <me@christine.website>"]
edition = "2018"
license = "0BSD"

View File

@ -1,6 +1,6 @@
[package]
name = "majc"
version = "0.2.0"
version = "0.2.1"
authors = ["Christine Dodrill <me@christine.website>"]
edition = "2018"

View File

@ -4,6 +4,16 @@ use cursive::{
Cursive,
};
pub fn quit(siv: &mut Cursive) {
siv.add_layer(
Dialog::text("Are you sure you want to quit?")
.button("No", |s| {
s.pop_layer();
})
.button("Yes", Cursive::quit),
);
}
pub fn help(siv: &mut Cursive) {
let content = include_str!("./help.gmi");

View File

@ -1,13 +1,13 @@
use cursive::{
theme::{Effect, Style},
theme::{BaseColor, Color, Effect, Style},
traits::*,
utils::markup::StyledString,
views::{Dialog, EditView, ResizedView, SelectView, TextView},
Cursive,
};
use maj::{self, Response};
use std::str;
use rustls::ClientConfig;
use std::str;
/// The state of the browser.
#[derive(Clone)]
@ -225,7 +225,10 @@ pub fn render(body: &str) -> StyledString {
Style::from(Effect::Bold),
)),
ListItem(item) => styled.append(StyledString::plain(format!("* {}", item))),
Quote(quote) => styled.append(StyledString::plain(format!("> {}", quote))),
Quote(quote) => styled.append(StyledString::styled(
format!("> {}", quote),
Style::from(Color::Dark(BaseColor::Green)),
)),
}
styled.append(StyledString::plain("\n"));
}

View File

@ -1,4 +1,4 @@
use cursive::{event::Key, menu::MenuTree};
use cursive::{event::Key, menu::MenuTree, Cursive};
pub(crate) mod commands;
pub(crate) mod gemini;
@ -17,8 +17,8 @@ fn main() {
siv.add_global_callback('c', |s| {
s.pop_layer();
});
siv.add_global_callback('q', cursive::Cursive::quit);
siv.add_global_callback('~', cursive::Cursive::toggle_debug_console);
siv.add_global_callback('q', commands::quit);
siv.add_global_callback('~', Cursive::toggle_debug_console);
siv.add_global_callback('h', gemini::history);
siv.add_global_callback('l', gemini::links);
siv.add_global_callback('o', gemini::open_prompt);

View File

@ -162,7 +162,7 @@ pub fn parse(doc: &str) -> Vec<Node> {
let mut preformatted_buffer: Vec<u8> = vec![];
for line in doc.lines() {
if line == "```" {
if line.starts_with("```") {
collect_preformatted = !collect_preformatted;
if !collect_preformatted {
result.push(Node::Preformatted(
@ -320,4 +320,15 @@ mod tests {
];
assert_eq!(expected, parse(msg));
}
#[test]
fn ambiguous_preformatted() {
let _ = pretty_env_logger::try_init();
let msg = include_str!("../testdata/ambig_preformatted.gmi");
let expected: Vec<Node> = vec![
Node::Preformatted("FOO".to_string()),
Node::Text("Foo bar".to_string()),
];
assert_eq!(expected, parse(msg));
}
}

4
testdata/ambig_preformatted.gmi vendored Normal file
View File

@ -0,0 +1,4 @@
``` foo
FOO
```
Foo bar