Skip to content
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

Preservation of text formatting #1053

Open
qaisjp opened this issue Mar 22, 2020 · 4 comments
Open

Preservation of text formatting #1053

qaisjp opened this issue Mar 22, 2020 · 4 comments
Labels
enhancement New feature or request

Comments

@qaisjp
Copy link
Collaborator

qaisjp commented Mar 22, 2020

Is your feature request related to a problem? Please describe.

Bridging between the same platform should transfer mentions, emoji and embeds better. Text formatting isn't consistent between platforms.

Describe the solution you'd like

Updating our config.Message to support something like Slack's blocks. We can have blocks for "text", "mentions", "emoji", and "embed" (similar to a Discord embed), and more if necessary.

However, for bold/italics/strike/urls and so on, instead of going crazy with blocks, we should instead normalise text markup.

We can do this by having source bridgers parse the text and convert the markup to a markdown dialect of our choice (CommonMark? GFM?). Then the destination bridgers will convert from our chosen markdown dialect, to the destination bridge's dialect.

For example, a user sends a message ~~markdown~~ on Discord. Our Bdiscord converts this to CommonMark, resulting in the config.Message.Text being ~~markdown~~ (no difference). The gateway sends this config.Message to Bslack. Inside Bslack we convert config.Message.Text to ~markdown~, making it appear correctly on Slack.

Note: Slack's markup language is called mrkdwn, and is described here as their "proprietary textual markup that's just different enough from Markdown to frustrate you". mrkdwn is specced out here.

Slack is a prick for calling it mrkdwn, and not SlackMarkdown or something more human-friendly.

Describe alternatives you've considered

Add CleanSourceMessage to the bridge.Bridger interface, which is called by the gateway per-message with a list of target platforms, so that e.g. Bdiscord.CleanSourceMessage can clean messages differently for different target platforms.

This involves hardcoding special behaviour for other bridges inside unrelated bridges.

Additional context

High level - see Slack's: layout blocks (specifically "section", but also "file" and "image") and composition objects (specifically "text").

It need not be as expansive as what Slack supports — it will be lossy. Slack's use case is too complicated and is meant for complex bot layouts.

When I tell people about matterbridge, I ask them if they've heard of pandoc, and say "it's basically pandoc but for chat platforms". This would extend the analogy and include support for converting text markup.

@qaisjp qaisjp added the enhancement New feature or request label Mar 22, 2020
@Mikaela
Copy link

Mikaela commented Apr 27, 2020

Does this issue include IRC formatting becoming emojis on the other sides of the matterbridge (Telegram, Matrix)?

IRC

Telegram

I guess this is related to #1022 ?

@qaisjp
Copy link
Collaborator Author

qaisjp commented Apr 27, 2020

Context: When a user sends :heart: on Discord, Discord automatically converts these to Unicode emoji.

We could probably integrate that into matterbridge at the gateway.go level?

@Avamander

This comment has been minimized.

@DarrenWhite99
Copy link

Please implement. :)

Just tested and confirmed the behavior.. Discord formatting for Bold/Italic/BoldItalic is different from Slack formatting for the
same, so messages are displayed "wrong" when bridged to the other side. Using a standard markup language and making each system convert it's unique markup syntax to the internal one and then converting back on the other side would allow for a much better experience on both sides, with formatting codes (not shown on the source) correctly mapped or at worst turned to plain text on the other side.

Example:
image

References:
https://support.discord.com/hc/en-us/articles/210298617-Markdown-Text-101-Chat-Formatting-Bold-Italic-Underline-
https://api.slack.com/reference/surfaces/formatting#basics

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants