mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-03-31 16:45:27 +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,41 +51,49 @@ impl Nex for TextView {
|
||||||
|
|
||||||
// Collect links
|
// Collect links
|
||||||
for line in data.lines() {
|
for line in data.lines() {
|
||||||
// just borrow ggemtext parser as compatible API
|
// * skip links processing when the current location does not contain trailing slash
|
||||||
if let Some(link) = ggemtext::line::Link::parse(line) {
|
// it may be confusing: gemini://bbs.geminispace.org/s/nex/29641
|
||||||
if let Some(uri) = link.uri(Some(base)) {
|
if base.to_string().ends_with("/") {
|
||||||
let a = TextTag::builder()
|
// just borrow ggemtext parser as compatible API
|
||||||
.foreground_rgba(&link_color.0)
|
if let Some(link) = ggemtext::line::Link::parse(line) {
|
||||||
// .foreground_rgba(&adw::StyleManager::default().accent_color_rgba()) @TODO adw 1.6 / ubuntu 24.10+
|
if let Some(uri) = link.uri(Some(base)) {
|
||||||
.sentence(true)
|
let a = TextTag::builder()
|
||||||
.wrap_mode(WrapMode::Word)
|
.foreground_rgba(&link_color.0)
|
||||||
.build();
|
// .foreground_rgba(&adw::StyleManager::default().accent_color_rgba()) @TODO adw 1.6 / ubuntu 24.10+
|
||||||
|
.sentence(true)
|
||||||
|
.wrap_mode(WrapMode::Word)
|
||||||
|
.build();
|
||||||
|
|
||||||
if !tags.add(&a) {
|
if !tags.add(&a) {
|
||||||
panic!()
|
panic!()
|
||||||
|
}
|
||||||
|
|
||||||
|
buffer.insert_with_tags(
|
||||||
|
&mut buffer.end_iter(),
|
||||||
|
&format!(
|
||||||
|
"{} {}",
|
||||||
|
if uri.scheme() == base.scheme() {
|
||||||
|
"=>"
|
||||||
|
} else {
|
||||||
|
"<="
|
||||||
|
},
|
||||||
|
link.url
|
||||||
|
),
|
||||||
|
&[&a],
|
||||||
|
);
|
||||||
|
if let Some(alt) = link.alt {
|
||||||
|
buffer.insert_with_tags(
|
||||||
|
&mut buffer.end_iter(),
|
||||||
|
&format!(" {alt}"),
|
||||||
|
&[&p],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
buffer.insert(&mut buffer.end_iter(), NEW_LINE);
|
||||||
|
|
||||||
|
links.insert(a, uri);
|
||||||
|
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer.insert_with_tags(
|
|
||||||
&mut buffer.end_iter(),
|
|
||||||
&format!(
|
|
||||||
"{} {}",
|
|
||||||
if uri.scheme() == base.scheme() {
|
|
||||||
"=>"
|
|
||||||
} else {
|
|
||||||
"<="
|
|
||||||
},
|
|
||||||
link.url
|
|
||||||
),
|
|
||||||
&[&a],
|
|
||||||
);
|
|
||||||
if let Some(alt) = link.alt {
|
|
||||||
buffer.insert_with_tags(&mut buffer.end_iter(), &format!(" {alt}"), &[&p]);
|
|
||||||
}
|
|
||||||
buffer.insert(&mut buffer.end_iter(), NEW_LINE);
|
|
||||||
|
|
||||||
links.insert(a, uri);
|
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Nothing match custom tags above,
|
// Nothing match custom tags above,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue