Skip to content

Handle discussion issues and html body better #387

@CoderJoshDK

Description

@CoderJoshDK

If the top of an issue doesn't have the moved discussion header,
Image

The code that cleans it up, doesn't.

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
Image

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions