From 6c026853e8888f6acc6fbee992f92f366202b500 Mon Sep 17 00:00:00 2001 From: jutty Date: Fri, 26 Dec 2025 01:17:27 -0300 Subject: [PATCH] Fix forced flanking anchor destination resolution --- src/syntax/content/parser.rs | 10 ++++++++++ src/syntax/content/parser/token/anchor.rs | 8 +++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/syntax/content/parser.rs b/src/syntax/content/parser.rs index 9e67f39..aee8e54 100644 --- a/src/syntax/content/parser.rs +++ b/src/syntax/content/parser.rs @@ -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#"

Node

"#); + } +} diff --git a/src/syntax/content/parser/token/anchor.rs b/src/syntax/content/parser/token/anchor.rs index ac9a488..d50e99b 100644 --- a/src/syntax/content/parser/token/anchor.rs +++ b/src/syntax/content/parser/token/anchor.rs @@ -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#"{}"#, - Anchor::resolve_destination(destination), + Anchor::resolve_destination(&non_empty_destination), &self.text ) }