Simplify Anchor context parser
This commit is contained in:
parent
48765de3b6
commit
cbefcdcad7
3 changed files with 90 additions and 50 deletions
|
|
@ -5,6 +5,7 @@ pub struct Anchor {
|
|||
pub text: String,
|
||||
pub destination: Option<String>,
|
||||
pub leading: bool,
|
||||
pub balanced: bool,
|
||||
pub external: bool,
|
||||
}
|
||||
|
||||
|
|
@ -45,12 +46,14 @@ impl Anchor {
|
|||
destination: &str,
|
||||
leading: bool,
|
||||
external: bool,
|
||||
balanced: bool,
|
||||
) -> Anchor {
|
||||
Anchor {
|
||||
text: text.to_owned(),
|
||||
destination: Some(Anchor::resolve_destination(destination)),
|
||||
leading,
|
||||
external,
|
||||
balanced,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -70,7 +73,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn render_anchor() {
|
||||
let anchor = Anchor::new("AnchorText", "AnchorDest", true, false);
|
||||
let anchor = Anchor::new("AnchorText", "AnchorDest", true, false, false);
|
||||
assert_eq!(
|
||||
anchor.render(),
|
||||
r#"<a href="/node/AnchorDest">AnchorText</a>"#
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue