forked from cadey/maj
Compare commits
4 Commits
preserve-c
...
main
Author | SHA1 | Date |
---|---|---|
Cadey Ratio | d437ac6e8f | |
Cadey Ratio | f2a251e829 | |
Cadey Ratio | e58a01d14d | |
Melody Horn | 3cd71ce302 |
10
CHANGELOG.md
10
CHANGELOG.md
|
@ -1,5 +1,15 @@
|
|||
# Changelog
|
||||
|
||||
## 0.6.2
|
||||
|
||||
Bump gemtext to 0.2.0
|
||||
|
||||
## 0.6.1
|
||||
|
||||
### FIXED
|
||||
|
||||
- [#9] Fixes from @boringcactus for gemtext rendering
|
||||
|
||||
## 0.6.0
|
||||
|
||||
### ADDED
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "maj"
|
||||
version = "0.6.0"
|
||||
version = "0.6.2"
|
||||
authors = ["Christine Dodrill <me@christine.website>"]
|
||||
edition = "2018"
|
||||
license = "0BSD"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "gemtext"
|
||||
version = "0.1.0"
|
||||
version = "0.2.0"
|
||||
authors = ["Christine Dodrill <me@christine.website>"]
|
||||
edition = "2018"
|
||||
license = "0BSD"
|
||||
|
|
|
@ -60,7 +60,13 @@ pub fn render(nodes: Vec<Node>, out: &mut impl Write) -> io::Result<()> {
|
|||
|
||||
for node in nodes {
|
||||
match node {
|
||||
Text(body) => write!(out, "{}\n", body)?,
|
||||
Text(body) => {
|
||||
let special_prefixes = ["=>", "```", "#", "*", ">"];
|
||||
if special_prefixes.iter().any(|prefix| body.starts_with(prefix)) {
|
||||
write!(out, " ")?;
|
||||
}
|
||||
write!(out, "{}\n", body)?
|
||||
},
|
||||
Link { to, name } => match name {
|
||||
Some(name) => write!(out, "=> {} {}\n", to, name)?,
|
||||
None => write!(out, "=> {}\n", to)?,
|
||||
|
@ -337,4 +343,15 @@ mod tests {
|
|||
];
|
||||
assert_eq!(expected, parse(msg));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ambiguous_text() {
|
||||
let _ = pretty_env_logger::try_init();
|
||||
let original = Node::Text("#1 World's Best Coder".to_string());
|
||||
let expected = " #1 World's Best Coder\n";
|
||||
let mut rendered: Vec<u8> = vec![];
|
||||
render(vec![original], &mut rendered).unwrap();
|
||||
let rendered = String::from_utf8(rendered).unwrap();
|
||||
assert_eq!(expected, rendered)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue