mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-02 17:45:28 +00:00
add missed trailing slash condition based on the current url
This commit is contained in:
parent
6a3ee89d8b
commit
4d1fa804ba
1 changed files with 41 additions and 33 deletions
|
|
@ -51,6 +51,9 @@ impl Nex for TextView {
|
||||||
|
|
||||||
// Collect links
|
// Collect links
|
||||||
for line in data.lines() {
|
for line in data.lines() {
|
||||||
|
// * skip links processing when the current location does not contain trailing slash
|
||||||
|
// it may be confusing: gemini://bbs.geminispace.org/s/nex/29641
|
||||||
|
if base.to_string().ends_with("/") {
|
||||||
// just borrow ggemtext parser as compatible API
|
// just borrow ggemtext parser as compatible API
|
||||||
if let Some(link) = ggemtext::line::Link::parse(line) {
|
if let Some(link) = ggemtext::line::Link::parse(line) {
|
||||||
if let Some(uri) = link.uri(Some(base)) {
|
if let Some(uri) = link.uri(Some(base)) {
|
||||||
|
|
@ -79,7 +82,11 @@ impl Nex for TextView {
|
||||||
&[&a],
|
&[&a],
|
||||||
);
|
);
|
||||||
if let Some(alt) = link.alt {
|
if let Some(alt) = link.alt {
|
||||||
buffer.insert_with_tags(&mut buffer.end_iter(), &format!(" {alt}"), &[&p]);
|
buffer.insert_with_tags(
|
||||||
|
&mut buffer.end_iter(),
|
||||||
|
&format!(" {alt}"),
|
||||||
|
&[&p],
|
||||||
|
);
|
||||||
}
|
}
|
||||||
buffer.insert(&mut buffer.end_iter(), NEW_LINE);
|
buffer.insert(&mut buffer.end_iter(), NEW_LINE);
|
||||||
|
|
||||||
|
|
@ -88,6 +95,7 @@ impl Nex for TextView {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Nothing match custom tags above,
|
// Nothing match custom tags above,
|
||||||
// just append plain text covered in empty tag (to handle controller events properly)
|
// just append plain text covered in empty tag (to handle controller events properly)
|
||||||
buffer.insert_with_tags(&mut buffer.end_iter(), line, &[&p]);
|
buffer.insert_with_tags(&mut buffer.end_iter(), line, &[&p]);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue