Populate content
with HTML, and source
with markdown (ref #1220) #141
Loading…
Reference in New Issue
No description provided.
Delete Branch "apub-media-type2"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Here we go, doing it the proper way.
@ -49,2 +55,4 @@
if let Some(bio) = &self.bio {
set_content_and_source(&mut person, bio)?;
// Also set summary for compatibility with older Lemmy versions. Remove this after a while.
person.set_summary(bio.to_owned());
I had to change the user bio from
summary
tocontent
, because the spec says that summary can only be HTML, with no option to specify a different mime type.I'm re-running this on travis right now, you needed to merge from main because the builds are broken otherwise.
@ -61,0 +76,4 @@
.set_content(markdown_text)
.set_media_type(mime_markdown()?);
object.set_source(source.into_any_base()?);
object.set_content(markdown_to_html(markdown_text));
This seems really dangerous, why do we need to convert to html? Why not just content: mardownText, type: 'markdown'
We could also put Markdown into the top-level
content
and set mediaType totext/markdown
. But doing it this way ensures compatibility with software which doesnt support Markdown. Anyway, Lemmy doesnt read the HTML, only Markdown fromsource.content
, so this doesnt change anything.Except, now that I'm thinking about it, federation with instances without and with this commit will be broken.
I suppose for compatibility we could change both
content
andsource.content
to Markdown, then later changecontent
to HTML. But that gets quite complicated really.@ -125,3 +128,1 @@
.map(|s| s.as_single_xsd_string())
.flatten()
.map(|s| s.to_string());
let bio = get_source_markdown_value(person)?;
Seems to be good, but we'll have to test manually before we merge.
Populate `content` with HTML, and `source` with markdown (ref #1220)to WIP: Populate `content` with HTML, and `source` with markdown (ref #1220)WIP: Populate `content` with HTML, and `source` with markdown (ref #1220)to Populate `content` with HTML, and `source` with markdown (ref #1220)I added a commit to make this change backwards compatible, meaning both
content
andsource.content
contain Markdown for now. We will have to revert that in a while for maximum compatibility.I tested by running that new commit on ds9, and it federates fine with voyager.
https://ds9.lemmy.ml/post/137
https://voyager.lemmy.ml/post/120
Note that the documentation is wrong now, cause I dont want to change that back and forth.
Seems good. About the html stuff (we can talk about this later on), I assumed it was up to the receiving server to decide what to do with the parsed info:
IE you receive `{content: "some italicized text", type: "text/markdown"}, so that server has to get that type and convert it to whatever their DB / front end representation requires.
We could just set the
mediaType
totext/markdown
and call it a day, but then software that doesnt support Markdown might not be able to handle it at all. On the other hand, HTML is the default encoding forcontent
, and presumably supported by most implementations. So by putting both HTML and Markdown into our objects, we ensure maximum compatibility without any negative effect on Lemmy.Here is an explanation how it works in the client-to-server part of ActivityPub, but I think the same logic applies for server-to-server too.
https://www.w3.org/TR/activitypub/#source-property
Ohhh okay I see, I didn't realize it was like this:
Ya in that case the converter is fine, as long as lemmy knows to only read the content that's inside the source object.
For now it will keep reading the top-level content from older versions (because they dont set the source). So we will have this in the next Lemmy version, and one version later we can remove the compatibility code (or even later). That means we need to put more focus on announcing new Lemmy versions from now on.