mattermost-plugin-github icon indicating copy to clipboard operation
mattermost-plugin-github copied to clipboard

double underscores in name eaten by markdown

Open doc-sheet opened this issue 1 year ago • 2 comments

Hi.

GitHub version: 2.2.0, 376f881, built Tue, 13 Feb 2024 15:14:53 UTC with go1.21.7

I have no idea how to show an example so I'll try to describe it.

When you paste a link to a file with dunders in it's name like https://github.com/mattermost/mattermost-data-warehouse/blob/5a88112086f5aefc88ca60ebbbc3668a4ee35ffb/utils/geolite/__main__.py#L10

Link above code preview in chat treats __main__ as markdown

Like this:

https://github.com/mattermost/mattermost-data-warehouse/utils/geolite/main.py

1.
2.
3.

doc-sheet avatar Jun 24 '24 16:06 doc-sheet

Hi @doc-sheet, thanks for filing this issue. This one is interesting.

So when the user posts https://github.com/mattermost/mattermost-data-warehouse/blob/5a88112086f5aefc88ca60ebbbc3668a4ee35ffb/utils/geolite/__main__.py#L10, we create a post with a link like:

[mattermost/mattermost-data-warehouse/utils/geolite/__main__.py](https://github.com/mattermost/mattermost-data-warehouse/blob/5a88112086f5aefc88ca60ebbbc3668a4ee35ffb/utils/geolite/__main__.py#L10), with the underscores being treated as bold instead of preserving them:

image

@hmhealey What are your thoughts on this? When creating a markdown link with custom text, some characters can be unintentionally treated as markdown formatting, when they are meant to be kept in tact (such as __main__.py). If I put backslashes in the link, the markdown is correctly ignored, so the plugin could do this for underscores:

[mattermost/mattermost-data-warehouse/utils/geolite/\_\_main\_\_.py](https://github.com/mattermost/mattermost-data-warehouse/blob/5a88112086f5aefc88ca60ebbbc3668a4ee35ffb/utils/geolite/__main__.py#L10)

rendered as this without the bold markdown:

mattermost/mattermost-data-warehouse/utils/geolite/__main__.py

So the solution could just be to have the plugin prepend underscores in the URL with backslashes

mickmister avatar Jun 24 '24 16:06 mickmister

Yeah, that makes sense to me. You'd just be escaping the special characters which seems like a decent fix to me

hmhealey avatar Jun 24 '24 19:06 hmhealey

Is the issue solved?

bharateshwq avatar Jul 13 '24 07:07 bharateshwq