mirror of
https://github.com/lise-henry/crowbook
synced 2024-09-24 23:40:43 +02:00
Consider an image as standalone even if it is inside a link
This commit is contained in:
parent
b3ba91c424
commit
bed329466d
@ -380,7 +380,21 @@ fn find_standalone(ast: &mut Vec<Token>) {
|
||||
unreachable!();
|
||||
}
|
||||
} else {
|
||||
continue;
|
||||
// If paragraph only contains a link only containing an image, ok too
|
||||
if let Token::Link(ref url, ref alt, ref mut inner) = inner[0] {
|
||||
if inner[0].is_image() {
|
||||
if let Token::Image(source, title, inner) = mem::replace(&mut inner[0],
|
||||
Token::Rule) {
|
||||
Token::Link(url.clone(), alt.clone(), vec![Token::StandaloneImage(source, title, inner)])
|
||||
} else {
|
||||
unreachable!();
|
||||
}
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
continue;
|
||||
|
@ -160,6 +160,14 @@ fn image_standalone() {
|
||||
test_eq(&result, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn image_link_standalone() {
|
||||
let doc = "[![alt text](http://foo.bar/baz.png \"Title\")](http://foo.bar)";
|
||||
let expected = r#"[Link("http://foo.bar", "", [StandaloneImage("http://foo.bar/baz.png", "Title", [Str("alt text")])])]"#;
|
||||
let result = format!("{:?}", parse_from_str(doc));
|
||||
test_eq(&result, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn table_simple() {
|
||||
let doc = "
|
||||
|
Loading…
Reference in New Issue
Block a user