mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-02 17:45:28 +00:00
disable multiline format on at least one closing tag not found
This commit is contained in:
parent
58d6e5dda3
commit
a68033bc01
1 changed files with 90 additions and 75 deletions
|
|
@ -14,7 +14,7 @@ use tag::Tag;
|
|||
use super::{ItemAction, WindowAction};
|
||||
use crate::app::browser::window::action::Position;
|
||||
use ggemtext::line::{
|
||||
code::{Inline, Multiline},
|
||||
code::*,
|
||||
header::{Header, Level},
|
||||
link::Link,
|
||||
list::List,
|
||||
|
|
@ -103,6 +103,19 @@ impl Gemini {
|
|||
// Init gutter widget (the tooltip on URL tags hover)
|
||||
let gutter = Gutter::build(&text_view);
|
||||
|
||||
// Disable multiline format on at least one closing tag not found
|
||||
let is_multiline_enabled = {
|
||||
let mut m = Vec::new();
|
||||
for (i, l) in gemtext.lines().enumerate() {
|
||||
if (l.starts_with(multiline::TAG) || l.ends_with(multiline::TAG))
|
||||
&& Inline::from(l).is_none()
|
||||
{
|
||||
m.push(i);
|
||||
}
|
||||
}
|
||||
m.len() % 2 == 0
|
||||
};
|
||||
|
||||
// Parse gemtext lines
|
||||
for line in gemtext.lines() {
|
||||
// Is inline code
|
||||
|
|
@ -144,6 +157,7 @@ impl Gemini {
|
|||
}
|
||||
|
||||
// Is multiline code
|
||||
if is_multiline_enabled {
|
||||
match multiline {
|
||||
None => {
|
||||
// Open tag found
|
||||
|
|
@ -223,7 +237,8 @@ impl Gemini {
|
|||
Err(e) => return Err(Error::Gemtext(e.to_string())),
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// Is header
|
||||
if let Some(header) = Header::from(line) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue