mirror of
https://github.com/YGGverse/ggemtext.git
synced 2026-03-31 17:15:33 +00:00
trim alt text for multiline code
This commit is contained in:
parent
65b051f23e
commit
dbb443d361
2 changed files with 3 additions and 3 deletions
|
|
@ -11,10 +11,10 @@ impl Multiline {
|
||||||
/// return Self constructed on success or None
|
/// return Self constructed on success or None
|
||||||
pub fn begin_from(line: &str) -> Option<Self> {
|
pub fn begin_from(line: &str) -> Option<Self> {
|
||||||
if line.starts_with("```") {
|
if line.starts_with("```") {
|
||||||
let alt = line.trim_start_matches("```");
|
let alt = line.trim_start_matches("```").trim();
|
||||||
|
|
||||||
return Some(Self {
|
return Some(Self {
|
||||||
alt: match alt.trim().is_empty() {
|
alt: match alt.is_empty() {
|
||||||
true => None,
|
true => None,
|
||||||
false => Some(GString::from(alt)),
|
false => Some(GString::from(alt)),
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ fn gemtext() {
|
||||||
|
|
||||||
{
|
{
|
||||||
let item = code_multiline.get(0).unwrap();
|
let item = code_multiline.get(0).unwrap();
|
||||||
assert_eq!(item.alt.clone().unwrap(), " alt text");
|
assert_eq!(item.alt.clone().unwrap(), "alt text");
|
||||||
assert_eq!(item.buffer.len(), 3);
|
assert_eq!(item.buffer.len(), 3);
|
||||||
assert_eq!(item.buffer.get(0).unwrap(), "multi");
|
assert_eq!(item.buffer.get(0).unwrap(), "multi");
|
||||||
assert_eq!(item.buffer.get(1).unwrap(), " preformatted line");
|
assert_eq!(item.buffer.get(1).unwrap(), " preformatted line");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue