-
Notifications
You must be signed in to change notification settings - Fork 12
Description
If the top of an issue doesn't have the moved discussion header,
The code that cleans it up, doesn't.
discord-bot/app/components/github_integration/webhooks/issues.py
Lines 30 to 38 in aa37d19
def reformat_converted_discussion_header(body: str | None, repo_url: str) -> str | None: | |
if body is None or not (match := CONVERTED_DISCUSSION_HEADER.match(body)): | |
return body | |
d, subtext = match["discussion_number"], match["subtext"] | |
new_heading = f"### Discussed in [#{d}]({repo_url}/discussions/{d})\n-# {subtext}\n" | |
_, end = match.span() | |
return new_heading + "".join(body[end:].lstrip().rsplit("</div>", maxsplit=1)) |
This is a good opportunity to generally improve the display of content. More specifically, cleanup raw HTML
Bike shed
Convert links and references in the same manner that GH does. For example, #387
becomes a link #387 (This has a lot of edge cases and might be impossible. But it would also inherently solve the converted discussion issue)
This would require a bit of movie magic to pull off. And so maybe should only be done against full fat GitHub links.
One edge case to be really careful about is truncated text. We don't want to truncate a created link. This can be difficult because you would need to know the character length of the shown text and not the markdown, and take that into account.