Convert HTML from titles into markdown (#2709)

Co-authored-by: Kradyz <k@radiz.nl>
This commit is contained in:
Kradyz 2023-02-07 03:27:17 +01:00 committed by GitHub
parent 7c1a37d584
commit ab9b60e86d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -23,6 +23,7 @@ use activitypub_federation::{
use activitystreams_kinds::public; use activitystreams_kinds::public;
use anyhow::anyhow; use anyhow::anyhow;
use chrono::NaiveDateTime; use chrono::NaiveDateTime;
use html2md::parse_html;
use lemmy_api_common::{ use lemmy_api_common::{
context::LemmyContext, context::LemmyContext,
request::fetch_site_data, request::fetch_site_data,
@ -183,7 +184,8 @@ impl ApubObject for ApubPost {
page page
.content .content
.clone() .clone()
.and_then(|c| c.lines().next().map(ToString::to_string)) .as_ref()
.and_then(|c| parse_html(c).lines().next().map(ToString::to_string))
}) })
.ok_or_else(|| anyhow!("Object must have name or content"))?; .ok_or_else(|| anyhow!("Object must have name or content"))?;
if name.chars().count() > MAX_TITLE_LENGTH { if name.chars().count() > MAX_TITLE_LENGTH {