The discussion revolves around improving the algorithm for generating pinned topic excerpts in Discourse. sam criticizes the current method, which blindly takes the first 220 characters and often results in poor excerpts, advocating for a simpler approach that uses the first paragraph without cutting words mid-sentence. codinghorror argues against limiting excerpts to the first paragraph, noting that Gmail and other platforms do not do this and that a better solution might involve custom markup for finer control. sam introduces a new feature allowing moderators to manually define excerpts using <span class='excerpt'> tags, which resolves the lack of control. However, mcwumbly points out that this only works if the tag is near the start of the post, leading to further discussion on how to improve this. meglio reports a bug where the excerpt tag isn’t properly applied, and JamesDb seeks alternatives, such as CSS or duplicating posts. haydenjames confirms that the <span class='excerpt'> solution works but wonders about workarounds for existing topics. The conversation highlights the need for better control over excerpts and ongoing efforts to refine the system.
I actually think all the ones you posted screenshots of look fine.
Blindly stripping pin excerpts at the first para would literally break the excerpt of every single one of the pinned topics you just screenshotted.. hard to see why you’re even proposing that.
Have you looked at GMail? It also concats in a similar way.
I thought the simplest thing here that at least grants control is to say break on html comment <!-- break -->, unfortunately we now strip out html comments from rendered markdown so its non trivial.
Other option is HR but is litters the post. Last option is custom markup, but it also is confusing.
My major issue is that there is zero mod control here, you have an excerpt and can not control how it looks or when it stops.
I dunno, I think the major pain point is lack of control. No matter what fancy algorithm we come with we will mess up sometimes. Plenty of improvement though we can do with current system, like stop cutting words in half (gmail does not) and some other bits an pieces.
I just added trivial support for cutting exceprts, was a fairly trivial change
<span class='excerpt'>My excerpt here</span>
Allows you to control the excerpt as a mod. Will fix the word truncating as well, surprisingly it is ever so slightly more complicated than this change.
Thanks for this. I just found that it only seems to work if the markup is at the beginning of the post. Would be nice if we could snip an excerpt from anywhere in the post.
@sam - do you think that the length of the content within the <span class='excerpt'> tags should obey the max excerpt length site setting? or should it override it in some manner? (like allow it to be up to 2x the length of the site setting?).
I know I’m overthinking it, but figured I’d ask in case there are any strong opinions either way…