mirror of
https://github.com/TxtDot/dalet-rs.git
synced 2024-11-24 17:46:20 +03:00
refactor: fix name of list
This commit is contained in:
parent
6265701499
commit
accf9aae58
1 changed files with 8 additions and 8 deletions
|
@ -10,16 +10,16 @@ pub fn parse_gemtext(s: String) -> Result<Vec<Tag>, GemTextParseError> {
|
||||||
let mut preformatted = false;
|
let mut preformatted = false;
|
||||||
let mut preformatted_text = String::new();
|
let mut preformatted_text = String::new();
|
||||||
|
|
||||||
let mut before_is_ordered_list = false;
|
let mut list_before = false;
|
||||||
let mut ordered_list: Vec<Tag> = Vec::new();
|
let mut list: Vec<Tag> = Vec::new();
|
||||||
|
|
||||||
for line in s.lines() {
|
for line in s.lines() {
|
||||||
let mut line = line.trim().to_owned();
|
let mut line = line.trim().to_owned();
|
||||||
|
|
||||||
if before_is_ordered_list && !line.starts_with("* ") {
|
if list_before && !line.starts_with("* ") {
|
||||||
page.push(Tag::Ul(ordered_list.clone()));
|
page.push(Tag::Ul(list.clone()));
|
||||||
before_is_ordered_list = false;
|
list_before = false;
|
||||||
ordered_list.clear();
|
list.clear();
|
||||||
} else if preformatted && !line.starts_with("```") {
|
} else if preformatted && !line.starts_with("```") {
|
||||||
preformatted_text.push_str(&line);
|
preformatted_text.push_str(&line);
|
||||||
preformatted_text.push('\n');
|
preformatted_text.push('\n');
|
||||||
|
@ -46,9 +46,9 @@ pub fn parse_gemtext(s: String) -> Result<Vec<Tag>, GemTextParseError> {
|
||||||
let body = line.split_off(4);
|
let body = line.split_off(4);
|
||||||
page.push(Tag::H(body.trim().to_owned(), HeadingLevel::Three));
|
page.push(Tag::H(body.trim().to_owned(), HeadingLevel::Three));
|
||||||
} else if line.starts_with("* ") {
|
} else if line.starts_with("* ") {
|
||||||
before_is_ordered_list = true;
|
list_before = true;
|
||||||
let body = line.split_off(2);
|
let body = line.split_off(2);
|
||||||
ordered_list.push(Tag::El(NotNullBody::Text(body)));
|
list.push(Tag::El(NotNullBody::Text(body)));
|
||||||
} else if line.starts_with("> ") {
|
} else if line.starts_with("> ") {
|
||||||
let body = line.split_off(2);
|
let body = line.split_off(2);
|
||||||
page.push(Tag::Bq(NotNullBody::Text(body)));
|
page.push(Tag::Bq(NotNullBody::Text(body)));
|
||||||
|
|
Loading…
Add table
Reference in a new issue