forked from cadey/maj
majc: fix rendering of gemlog.blue
This commit is contained in:
parent
70074e0075
commit
93a5dd445a
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "maj"
|
name = "maj"
|
||||||
version = "0.4.1"
|
version = "0.4.2"
|
||||||
authors = ["Christine Dodrill <me@christine.website>"]
|
authors = ["Christine Dodrill <me@christine.website>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
license = "0BSD"
|
license = "0BSD"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "majc"
|
name = "majc"
|
||||||
version = "0.2.0"
|
version = "0.2.1"
|
||||||
authors = ["Christine Dodrill <me@christine.website>"]
|
authors = ["Christine Dodrill <me@christine.website>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,16 @@ use cursive::{
|
||||||
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) {
|
pub fn help(siv: &mut Cursive) {
|
||||||
let content = include_str!("./help.gmi");
|
let content = include_str!("./help.gmi");
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
use cursive::{
|
use cursive::{
|
||||||
theme::{Effect, Style},
|
theme::{BaseColor, Color, Effect, Style},
|
||||||
traits::*,
|
traits::*,
|
||||||
utils::markup::StyledString,
|
utils::markup::StyledString,
|
||||||
views::{Dialog, EditView, ResizedView, SelectView, TextView},
|
views::{Dialog, EditView, ResizedView, SelectView, TextView},
|
||||||
Cursive,
|
Cursive,
|
||||||
};
|
};
|
||||||
use maj::{self, Response};
|
use maj::{self, Response};
|
||||||
use std::str;
|
|
||||||
use rustls::ClientConfig;
|
use rustls::ClientConfig;
|
||||||
|
use std::str;
|
||||||
|
|
||||||
/// The state of the browser.
|
/// The state of the browser.
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
@ -225,7 +225,10 @@ pub fn render(body: &str) -> StyledString {
|
||||||
Style::from(Effect::Bold),
|
Style::from(Effect::Bold),
|
||||||
)),
|
)),
|
||||||
ListItem(item) => styled.append(StyledString::plain(format!("* {}", item))),
|
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"));
|
styled.append(StyledString::plain("\n"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use cursive::{event::Key, menu::MenuTree};
|
use cursive::{event::Key, menu::MenuTree, Cursive};
|
||||||
|
|
||||||
pub(crate) mod commands;
|
pub(crate) mod commands;
|
||||||
pub(crate) mod gemini;
|
pub(crate) mod gemini;
|
||||||
|
@ -17,8 +17,8 @@ fn main() {
|
||||||
siv.add_global_callback('c', |s| {
|
siv.add_global_callback('c', |s| {
|
||||||
s.pop_layer();
|
s.pop_layer();
|
||||||
});
|
});
|
||||||
siv.add_global_callback('q', cursive::Cursive::quit);
|
siv.add_global_callback('q', commands::quit);
|
||||||
siv.add_global_callback('~', cursive::Cursive::toggle_debug_console);
|
siv.add_global_callback('~', Cursive::toggle_debug_console);
|
||||||
siv.add_global_callback('h', gemini::history);
|
siv.add_global_callback('h', gemini::history);
|
||||||
siv.add_global_callback('l', gemini::links);
|
siv.add_global_callback('l', gemini::links);
|
||||||
siv.add_global_callback('o', gemini::open_prompt);
|
siv.add_global_callback('o', gemini::open_prompt);
|
||||||
|
|
|
@ -162,7 +162,7 @@ pub fn parse(doc: &str) -> Vec<Node> {
|
||||||
let mut preformatted_buffer: Vec<u8> = vec![];
|
let mut preformatted_buffer: Vec<u8> = vec![];
|
||||||
|
|
||||||
for line in doc.lines() {
|
for line in doc.lines() {
|
||||||
if line == "```" {
|
if line.starts_with("```") {
|
||||||
collect_preformatted = !collect_preformatted;
|
collect_preformatted = !collect_preformatted;
|
||||||
if !collect_preformatted {
|
if !collect_preformatted {
|
||||||
result.push(Node::Preformatted(
|
result.push(Node::Preformatted(
|
||||||
|
@ -320,4 +320,15 @@ mod tests {
|
||||||
];
|
];
|
||||||
assert_eq!(expected, parse(msg));
|
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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
``` foo
|
||||||
|
FOO
|
||||||
|
```
|
||||||
|
Foo bar
|
Loading…
Reference in New Issue