Make the text attribute "technically optional" by giving it a default.
Apparently in OPML 1.0 text attributes are not required, so this should make it work for all versions.
This commit is contained in:
parent
18c8284ba9
commit
a9c0deac33
|
@ -3,7 +3,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "opml"
|
name = "opml"
|
||||||
authors = ["Holllo <helllo@holllo.cc>"]
|
authors = ["Holllo <helllo@holllo.cc>"]
|
||||||
version = "0.2.3"
|
version = "0.2.4"
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
description = "An OPML parser for Rust."
|
description = "An OPML parser for Rust."
|
||||||
repository = "https://git.holllo.cc/holllo/opml"
|
repository = "https://git.holllo.cc/holllo/opml"
|
||||||
|
|
|
@ -273,8 +273,9 @@ pub struct Body {
|
||||||
#[xml(tag = "outline")]
|
#[xml(tag = "outline")]
|
||||||
pub struct Outline {
|
pub struct Outline {
|
||||||
/// Every outline element must have at least a text attribute, which is what is displayed when an outliner opens the OPML document.
|
/// Every outline element must have at least a text attribute, which is what is displayed when an outliner opens the OPML document.
|
||||||
|
/// Version 1.0 OPML documents may omit this attribute, so for compatibility and strictness this attribute is "technically optional" as it will be replaced by an empty String if it is omitted.
|
||||||
/// Text attributes may contain encoded HTML markup.
|
/// Text attributes may contain encoded HTML markup.
|
||||||
#[xml(attr = "text")]
|
#[xml(default, attr = "text")]
|
||||||
pub text: String,
|
pub text: String,
|
||||||
|
|
||||||
/// A string that indicates how the other attributes of the [Outline](struct.Outline.html) should be interpreted.
|
/// A string that indicates how the other attributes of the [Outline](struct.Outline.html) should be interpreted.
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
<opml version="1.0">
|
||||||
|
<head/>
|
||||||
|
<body>
|
||||||
|
<outline title="Outline Title"/>
|
||||||
|
</body>
|
||||||
|
</opml>
|
|
@ -77,3 +77,21 @@ fn test_valid_opml_with_everything() {
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_valid_opml_1_0() {
|
||||||
|
assert_eq!(
|
||||||
|
OPML::new(&read("tests/samples/valid_opml_1_0.opml").unwrap()).unwrap(),
|
||||||
|
OPML {
|
||||||
|
version: "1.0".to_string(),
|
||||||
|
head: Some(Head::default()),
|
||||||
|
body: Body {
|
||||||
|
outlines: vec![Outline {
|
||||||
|
text: String::default(),
|
||||||
|
title: Some("Outline Title".to_string()),
|
||||||
|
..Outline::default()
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue