DioxusLabs / dioxus

Fullstack GUI library for web, desktop, mobile, and more.
https://dioxuslabs.com
Apache License 2.0
18.65k stars 711 forks source link

MathML support #1778

Closed stefnotch closed 3 months ago

stefnotch commented 4 months ago

Specific Demand

MathML Core is implemented in every major browser, and it adds a HTML element, and child elements. (Similar to SVG)

https://developer.mozilla.org/en-US/docs/Web/MathML/Authoring#mathml_in_html_pages

However, Dioxus does not seem to expose it

fn MathElement(cx: Scope) -> Element {
    cx.render(rsx! {
        math {
            "Hello, world!"
        }
    })
}

Implement Suggestion

Would it be possible to add the MathML Core elements, minus the deprecated ones to https://github.com/DioxusLabs/dioxus/blob/master/packages/html/src/elements.rs ? See also documentation on MDN https://developer.mozilla.org/en-US/docs/Web/MathML/Element .

P.S. There's also a MathML Full, which was never properly supported by browsers. The creators realised that that's a problem, and thus came up with a much smaller subset called MathML Core.

Jah-On commented 4 months ago

I second this feature request.

ealmloff commented 4 months ago

Adding support for MathML elements would be great! It is a pretty easy part of the codebase to get started with, if anyone is interested in adding support. You just need to add each element and attribute in this format to the end of this list:

// elementname (with no underscores) namespace
math "http://www.w3.org/1998/Math/MathML" {
    // rust name of the attribute | unit (this is currently ignored, you can use String as a default) | the HTML attribute name (this can be DEFAULT for a stringified name or a custom string like "display2")
    display: String DEFAULT,
};
Ameyanagi commented 4 months ago

I am interested in adding this feature.

stefnotch commented 4 months ago

@Ameyanagi That'd be awesome! If you do find the time to make a pull request which adds this feature, please do ping me. I'll be more than happy to review it. (Even if I know very little about the dioxus code base)

Jah-On commented 4 months ago

@Ameyanagi That'd be awesome! If you do find the time to make a pull request which adds this feature, please do ping me. I'll be more than happy to review it. (Even if I know very little about the dioxus code base)

Same for me!

Ameyanagi commented 4 months ago

@stefnotch @Jah-On I will do!

Ameyanagi commented 4 months ago

@ealmloff Hi, I am working on this, and I implemented most of the MathML core tags, except for https://developer.mozilla.org/en-US/docs/Web/MathML/Element/semantics

In my understanding, we cannot use "-" or "_" for the rsx tag names, and are there any naming conventions that should be applied here?

I was initially thinking something like the following, but I saw in your comment that underscore is not allowed.

/// Build a
/// [`<annotation-xml>`](https://w3c.github.io/mathml-core/#dfn-annotation-xml)
/// element.
annotation_xml ["annotation-xml", "http://www.w3.org/1998/Math/MathML"] {};
ealmloff commented 4 months ago

@ealmloff Hi, I am working on this, and I implemented most of the MathML core tags, except for https://developer.mozilla.org/en-US/docs/Web/MathML/Element/semantics

In my understanding, we cannot use "-" or "_" for the rsx tag names, and are there any naming conventions that should be applied here?

I was initially thinking something like the following, but I saw in your comment that underscore is not allowed.

/// Build a
/// [`<annotation-xml>`](https://w3c.github.io/mathml-core/#dfn-annotation-xml)
/// element.
annotation_xml ["annotation-xml", "http://www.w3.org/1998/Math/MathML"] {};

We cant use underscores because they mark a name as a component instead of an element. We can use lower camel case: annitationXml

ealmloff commented 3 months ago

Closed by https://github.com/DioxusLabs/dioxus/pull/1846