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

MSC2191: Markup for mathematical messages #2191

Merged
merged 7 commits into from
Apr 15, 2024

Conversation

uhoreg
Copy link
Member

@uhoreg uhoreg commented Jul 26, 2019

Rendered

This proposal is related to element-hq/element-web#1945, and is a counter-proposal to #1722

Implementations:

FCP tickyboxes

@uhoreg uhoreg added proposal A matrix spec change proposal proposal-in-review labels Jul 26, 2019
@turt2live turt2live changed the title add proposal for using LaTeX for maths display MSC2191: Proposal for using LaTeX for maths display Jul 26, 2019
@Half-Shot
Copy link
Contributor

Half-Shot commented Jul 27, 2019

(FYI, matrix-org/matrix-react-sdk#3251 just arrived)

Copy link
Member

@KitsuneRal KitsuneRal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I don't have a conclusive "ship it!" opinion about this I certainly believe we should pursue the LaTeX path rather than the MathML one. To alleviate the mentioned issues it may make sense to select the allowed subset of LaTeX - ultimately it's a language for document preparation, not just math rendering, so has much more than necessary to facilitate math chatting.

proposals/2191-maths.md Show resolved Hide resolved
proposals/2191-maths.md Outdated Show resolved Hide resolved
proposals/2191-maths.md Show resolved Hide resolved
@thosgood
Copy link

(FYI, matrix-org/matrix-react-sdk#3251 just arrived)

@Half-Shot This pull request should be compatible with either proposal choice, but tends more towards this one than the other.

@turt2live turt2live self-requested a review August 1, 2019 17:02
Copy link
Member

@turt2live turt2live left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not my sphere of knowledge at all, but LaTeX seems like the better of the options.

proposals/2191-maths.md Outdated Show resolved Hide resolved
proposals/2191-maths.md Show resolved Hide resolved
@turt2live turt2live added the kind:feature MSC for not-core and not-maintenance stuff label Apr 20, 2020
NickHu added a commit to NickHu/element-android that referenced this pull request Sep 18, 2020
(matrix-org/matrix-spec-proposals#2191)

Firstly, this implements a commonmark-java plugin which is solely used to parse
LaTeX input in the composer box, so that they can be rendered into
`<span data-mx-maths=...>fallback</span>` and `<div
data-mx-maths=...>fallback</div>` for inline and display maths
respectively in the sent message.

Secondly, received messages of this form are pre-processed by a simple
regex into a form which markwon (which performs the rendering) expects.
NickHu added a commit to NickHu/element-android that referenced this pull request Sep 18, 2020
(matrix-org/matrix-spec-proposals#2191)

Firstly, this implements a commonmark-java plugin which is solely used to parse
LaTeX input in the composer box, so that they can be rendered into
`<span data-mx-maths=...>fallback</span>` and `<div
data-mx-maths=...>fallback</div>` for inline and display maths
respectively in the sent message.

Secondly, received messages of this form are pre-processed by a simple
regex into a form which markwon (which performs the rendering) expects.
NickHu added a commit to NickHu/element-android that referenced this pull request Oct 19, 2020
(matrix-org/matrix-spec-proposals#2191)

Firstly, this implements a commonmark-java plugin which is solely used to parse
LaTeX input in the composer box, so that they can be rendered into
`<span data-mx-maths=...>fallback</span>` and `<div
data-mx-maths=...>fallback</div>` for inline and display maths
respectively in the sent message.

Secondly, received messages of this form are pre-processed by a simple
regex into a form which markwon (which performs the rendering) expects.
@uhoreg uhoreg changed the title MSC2191: Proposal for using LaTeX for maths display MSC2191: Markup for mathematical messaging Oct 19, 2020
@uhoreg uhoreg changed the title MSC2191: Markup for mathematical messaging MSC2191: Markup for mathematical messages Oct 19, 2020
@Evidlo
Copy link

Evidlo commented Oct 20, 2020

This may be the wrong place, but what are people's thoughts about blocking this on extensible events? I don't

It seems like exactly the sort of thing extensible events and this might provide enough motivation to get that issue resolved, finally.

@Cadair
Copy link
Contributor

Cadair commented Oct 20, 2020

This may be the wrong place, but what are people's thoughts about blocking this on extensible events?

While this could definitely make use of extensible events to provide richer fallbacks, I don't want to block this on it. Extensible events are a massive change and this is reasonably trivial. Would rather see this land imperfectly than wait an undefined amount of time behind a major change to the protocol.

@behrmann
Copy link

Just to throw in a user perspective: This is a killer feature for users in a university natural sciences setting and the people who would use this, would mostly not care about having to read LaTeX as a fallback since they use it all the time anyways.

@uhoreg
Copy link
Member Author

uhoreg commented Oct 20, 2020

This may be the wrong place, but what are people's thoughts about blocking this on extensible events?

Extensible events is solving a different problem. Extensible events is aimed at the situation where the entire message is some strange new thing, not for when the new thing is part of a message. As an example, suppose that both spoilers and this MSC were implemented using extensible events. How would you send a message that had both a spoiler and math? (e.g. What is <span data-mx-latex="x^2">x^2</span> at <span data-mx-latex="x=1">x=1</span>? <span data-mx-spoiler="answer"><span data-mx-latex="1">1</span>) That's not something that extensible events would be able to do very well.

@Evidlo
Copy link

Evidlo commented Oct 20, 2020

Extensible events is solving a different problem. Extensible events is aimed at the situation where the entire message is some strange new thing, not for when the new thing is part of a message.

I guess I misinterpreted m.message, then. I thought it was an ordered list and that the messages of different types were supposed to be concatenated after rendering.

How would you send a message that had both a spoiler and math? (e.g. What is <span data-mx-latex="x^2">x^2</span> at <span data-mx-latex="x=1">x=1</span>? <span data-mx-spoiler="answer"><span data-mx-latex="1">1</span>) That's not something that extensible events would be able to do very well.

    "m.message": [
        {
            "mimetype": "text/x-latex",
            "body": "What is $x^2$ at $x=1$?",
            "formatted_body": "What is x^2 at x=1?"
        },
        {
            "mimetype": "text/html",
            "body": "<span data-mx-spoiler=\"answer\">1</span>",
            "formatted_body": "1",
        }
    ],

If I was writing a TUI client, it seems like the above would be easier, as I could just use off the shelf TeX->plaintext and HTML->plaintext rendering libs for each message part and not need to parse html. If my client doesn't support the message type, then it can just use the fallback for that message part.

@Sorunome
Copy link
Contributor

Extensible events is solving a different problem. Extensible events is aimed at the situation where the entire message is some strange new thing, not for when the new thing is part of a message.

I guess I misinterpreted m.message, then. I thought it was an ordered list and that the messages of different types were supposed to be concatenated after rendering.

How would you send a message that had both a spoiler and math? (e.g. What is <span data-mx-latex="x^2">x^2</span> at <span data-mx-latex="x=1">x=1</span>? <span data-mx-spoiler="answer"><span data-mx-latex="1">1</span>) That's not something that extensible events would be able to do very well.

    "m.message": [
        {
            "mimetype": "text/x-latex",
            "body": "What is $x^2$ at $x=1$?",
            "formatted_body": "What is x^2 at x=1?"
        },
        {
            "mimetype": "text/html",
            "body": "<span data-mx-spoiler=\"answer\">1</span>",
            "formatted_body": "1",
        }
    ],

If I was writing a TUI client, it seems like the above would be easier, as I could just use off the shelf TeX->plaintext and HTML->plaintext rendering libs for each message part and not need to parse html. If my client doesn't support the message type, then it can just use the fallback for that message part.

Your example did not make the 1 answer latex. The idea was to put latex inside a spoiler, which is not possible with that proposed approach

@mscbot mscbot added final-comment-period This MSC has entered a final comment period in interest to approval, postpone, or delete in 5 days. and removed proposed-final-comment-period Currently awaiting signoff of a majority of team members in order to enter the final comment period. labels Apr 9, 2024
Comment on lines +3 to +6
Some people write using an odd language that has strange symbols. No, I'm not
talking about computer programmers; I'm talking about mathematicians. In order
to aid these people in communicating, Matrix should define a standard way of
including mathematical notation in messages.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would argue that the vast majority of users will never send mathematical expression to each other. Is the complexity really worth it? LaTeX is non-trivial to parse nor to render.

Also, if Matrix is going to access mathematical notations, what about other domains, like chemistry, physics, … al the myriad of other notations?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clients aren't required to render or parse the notation, which is why a fallback is present. Several clients do wish to represent mathematical expressions to users though, and having a consistent and standardized way to do so is important.

MSCs for other notations are equally accepted, provided they have similar fallback mechanics.

@K4LCIFER
Copy link

Is this proposal only limited to LaTeX, or would it also extend to more modern alternatives like Typst?

@turt2live
Copy link
Member

This proposal is limited to the expression format of LaTeX, whereas Typst appears to be a full document editor. A separate proposal would be required to express Typst, I believe, as it has a different scope.

@K4LCIFER
Copy link

whereas Typst appears to be a full document editor.

Errr, well, no — Typst is a typsetting language like LaTeX. They do offer a sort of IDE on the side (which functions similaraly to overleaf) to help fund the project.

@mscbot
Copy link
Collaborator

mscbot commented Apr 14, 2024

The final comment period, with a disposition to merge, as per the review above, is now complete.

@mscbot mscbot added finished-final-comment-period and removed disposition-merge final-comment-period This MSC has entered a final comment period in interest to approval, postpone, or delete in 5 days. labels Apr 14, 2024
@turt2live turt2live merged commit d73124c into matrix-org:old_master Apr 15, 2024
@turt2live turt2live added spec-pr-missing Proposal has been implemented and is being used in the wild but hasn't yet been added to the spec and removed finished-final-comment-period labels Apr 15, 2024
turt2live added a commit that referenced this pull request Apr 15, 2024
* add proposal for using LaTeX for maths display

* rename to match MSC number

* change title

* update based on feedback

* up to clients how to deal with potentially-dangerous commands

* fix typo

Co-authored-by: Travis Ralston <travpc@gmail.com>

* small typo fix

---------

Co-authored-by: Travis Ralston <travpc@gmail.com>
Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
@uhoreg
Copy link
Member Author

uhoreg commented Apr 23, 2024

Is this proposal only limited to LaTeX, or would it also extend to more modern alternatives like Typst?

This proposal states what it is proposing, which is only adding support for the mathematical markup from LaTeX. Any other markup could be proposed in a different proposal.

@uhoreg
Copy link
Member Author

uhoreg commented May 8, 2024

spec PR: matrix-org/matrix-spec#1816

@uhoreg uhoreg added spec-pr-in-review A proposal which has been PR'd against the spec and is in review and removed spec-pr-missing Proposal has been implemented and is being used in the wild but hasn't yet been added to the spec labels May 8, 2024
@uhoreg uhoreg added merged A proposal whose PR has merged into the spec! and removed spec-pr-in-review A proposal which has been PR'd against the spec and is in review labels May 28, 2024
@uhoreg
Copy link
Member Author

uhoreg commented May 28, 2024

Merged! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:feature MSC for not-core and not-maintenance stuff merged A proposal whose PR has merged into the spec! proposal A matrix spec change proposal
Projects
Status: Done to some definition
Development

Successfully merging this pull request may close these issues.