-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do not localize dates that appear within code, hyperlinks and quote blocks #48
Conversation
This dependency spec is copied from the mattermost-webapp package.json file
Hello @jayaddison-collabora, Thanks for your pull request! A Core Committer will review your pull request soon. For code contributions, you can learn more about the review process here. |
This comment was marked as outdated.
This comment was marked as outdated.
This comment has been minimized.
This comment has been minimized.
const filterRenderer = new marked.Renderer(); | ||
filterRenderer.code = () => ''; | ||
filterRenderer.codespan = () => ''; | ||
filterRenderer.link = () => ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like there may be other cases that would make sense to ignore too; blockquote
for example. Perhaps it'd make sense to create an array of the renderer properties to override and assign to each of them in a loop.
@mkraft apologies for the repeat notifications; here's another, slightly more involved, merge request. We deployed a version of The code from that deployment is visible at https://gitlab.collabora.com/tools/mattermost/mattermost-plugin-walltime/-/commits/deploys/test-20220105 -- it includes most of the changes here albeit without the hyperlink and code block filtering. |
Please note that the merge commit here (7b11ab0) involved some manual conflict resolution regarding the NPM It wasn't possible to (easily) have the That's potentially related to some kind of change that NPM made regarding the calculation of integrity checksums. There's a possible note about that here (I'm not really completely clear on the root cause of this, but have seen the same problem occur within other projects as well). |
This PR has been automatically labelled "stale" because it hasn't had recent activity. /cc @aspleenic |
A personal update: I'm planning to resign from @collabora effective Friday 2022-04-01, so this pull request may go unmaintained from that point. |
Summary
Currently this plugin localizes dates within the full raw message text (that may include Markdown) as sent by a user.
Dates that appear within code blocks should not be localized, since they represent a form of quoted context that should be rendered as-is to recipients. The same is true for blockquotes.
The same is true of hyperlinks, as reported in #49.
To detect and ignore those elements, this change uses the Mattermost-flavoured fork of the
marked
Markdown processor (as used bymattermost-webapp
) to filter them out from the text that is scanned for localizable dates.Ticket Link
Resolves #25.
Resolves #49.