mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-08-31 00:42:01 +00:00
generate document title based on first non-empty line matches condition
This commit is contained in:
parent
1fa8f3f29d
commit
67072eb8ea
@ -55,15 +55,16 @@ impl Nex for TextView {
|
|||||||
// Init new text buffer
|
// Init new text buffer
|
||||||
let buffer = TextBuffer::new(Some(&tags));
|
let buffer = TextBuffer::new(Some(&tags));
|
||||||
|
|
||||||
// Collect links
|
// Collect markup tags
|
||||||
for (i, line) in data.lines().enumerate() {
|
for line in data.lines() {
|
||||||
// Generate document title based on first line
|
// Generate document title, based on the first non-empty line
|
||||||
if i == 0 {
|
if title.is_none() {
|
||||||
let l = line.trim();
|
let l = line.trim();
|
||||||
if !l.starts_with("=>") {
|
if !l.is_empty() && !l.starts_with("=>") {
|
||||||
*title = Some(l.into())
|
*title = Some(l.into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Collect links
|
||||||
// * skip links processing when the current location does not contain trailing slash
|
// * skip links processing when the current location does not contain trailing slash
|
||||||
// it may be confusing: gemini://bbs.geminispace.org/s/nex/29641
|
// it may be confusing: gemini://bbs.geminispace.org/s/nex/29641
|
||||||
if base.to_string().ends_with("/") {
|
if base.to_string().ends_with("/") {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user