diff --git a/plume-common/src/utils.rs b/plume-common/src/utils.rs index b82a4734..7ca49234 100644 --- a/plume-common/src/utils.rs +++ b/plume-common/src/utils.rs @@ -85,7 +85,6 @@ pub fn md_to_html(md: &str) -> (String, HashSet, HashSet) { } } State::Ready => { - text_acc.push(c); if c == '@' { events.push(Event::Text(text_acc.into())); (events, State::Mention, String::new(), n + 1, mentions, hashtags) @@ -93,11 +92,13 @@ pub fn md_to_html(md: &str) -> (String, HashSet, HashSet) { events.push(Event::Text(text_acc.into())); (events, State::Hashtag, String::new(), n + 1, mentions, hashtags) } else if c.is_alphanumeric() { + text_acc.push(c); if n >= (txt.chars().count() - 1) { // Add the text after at the end, even if it is not followed by a mention. events.push(Event::Text(text_acc.clone().into())) } (events, State::Word, text_acc, n + 1, mentions, hashtags) } else { + text_acc.push(c); if n >= (txt.chars().count() - 1) { // Add the text after at the end, even if it is not followed by a mention. events.push(Event::Text(text_acc.clone().into())) } diff --git a/plume-models/src/posts.rs b/plume-models/src/posts.rs index c7e46b30..068a06eb 100644 --- a/plume-models/src/posts.rs +++ b/plume-models/src/posts.rs @@ -719,7 +719,7 @@ impl Post { } } - for ot in old_tags { + for ot in old_tags.iter().filter(|t| !t.is_hashtag) { if !tags_name.contains(&ot.tag) { ot.delete(conn); } @@ -756,7 +756,7 @@ impl Post { } } - for ot in old_tags { + for ot in old_tags.into_iter().filter(|t| t.is_hashtag) { if !tags_name.contains(&ot.tag) { ot.delete(conn); } diff --git a/src/routes/posts.rs b/src/routes/posts.rs index e0e8266b..4c9bdb8d 100644 --- a/src/routes/posts.rs +++ b/src/routes/posts.rs @@ -231,7 +231,7 @@ fn update(blog: String, slug: String, user: User, conn: DbConn, data: LenientFor let hashtags = hashtags.into_iter().map(|h| h.to_camel_case()).collect::>() .into_iter().map(|t| Tag::build_activity(&conn, t)).collect::>(); - post.update_tags(&conn, hashtags); + post.update_hashtags(&conn, hashtags); if post.published { if newly_published {