Fix forced flanking anchor destination resolution
This commit is contained in:
parent
c9109e9775
commit
6c026853e8
2 changed files with 17 additions and 1 deletions
|
|
@ -240,3 +240,13 @@ fn parse(tokens: &[Token]) -> String {
|
|||
pub(super) fn read(text: &str) -> String {
|
||||
parse(&lex(text, LEXMAP))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn force_flanking() {
|
||||
assert_eq!(read("|Node||"), r#"<p><a href="/node/Node">Node</a></p>"#);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,9 +25,15 @@ impl Parseable for Anchor {
|
|||
)
|
||||
};
|
||||
|
||||
let non_empty_destination = if destination.is_empty() {
|
||||
self.text.clone()
|
||||
} else {
|
||||
destination.to_owned()
|
||||
};
|
||||
|
||||
format!(
|
||||
r#"<a href="{}">{}</a>"#,
|
||||
Anchor::resolve_destination(destination),
|
||||
Anchor::resolve_destination(&non_empty_destination),
|
||||
&self.text
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue