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

Some Greek Capital Letter render mathml confused with Latin Letter #3025

Open
3 tasks done
nfer opened this issue May 16, 2021 · 3 comments · May be fixed by #3029
Open
3 tasks done

Some Greek Capital Letter render mathml confused with Latin Letter #3025

nfer opened this issue May 16, 2021 · 3 comments · May be fixed by #3029
Labels

Comments

@nfer
Copy link
Contributor

nfer commented May 16, 2021

Before reporting a bug

Describe the bug:
Greek Capital Letter Alpha looks similarly with Latin Capital Letter A, but they have different unicode number. One is U+0391 and the another is U+0041. Now the KaTeX(0.13.11) render them mathml both get result 'Latin Capital Letter A'.

To Reproduce:
Steps to reproduce the behavior:

  1. run below test case
describe("A Greek MathML builder", function() {
    it("should properly render greek accents", function() {
        // Greek Capital Letter Alpha
        const tex = String.fromCharCode(Number.parseInt('0391', 16));
        const tree = getParsed(tex);
        const markup = buildMathML(tree, tex, defaultOptions).toMarkup();
        expect(markup).toContain(`<mi mathvariant="normal">${tex}</mi>`);
    });
});
  1. See error

Expected behavior:
Greek Capital Letters should render greek mathml letters but not Latin letters.

Environment (please complete the following information):

  • KaTeX Version: [0.13.11]
  • Device: [Desktop]
  • OS: [Mac]
  • Browser: [Chrome]
  • Version: [90]

Additional context:
Add any other context about the problem here. If you're using a library to use KaTeX, please include its name and setup.

@nfer nfer added the bug label May 16, 2021
@nfer
Copy link
Contributor Author

nfer commented May 16, 2021

I have read PR #1285 and issue #1282.
But I still think the correct mathml is an issue.
If for some reason, should render it like latin letter, but for mathml, it should keep it original info.

@edemaine
Copy link
Member

edemaine commented May 16, 2021

Good catch! If we changed the definitions of capital Alpha and Beta from symbols to macros (like #1283 or rather #1284, but maybe using \mathrm instead of \rm? does it interact correctly with \mathbf and/or \boldsymbol?), then we could use \html@mathml to use Unicode in the MathML output. (For reference, we didn't have \html@mathml back when these PRs were written.)

Honestly I don't remember why we had a preference for symbol aliases, because it doesn't seem that they have "the correct interaction with fonts" given this MathML behavior (and the wrong copy/paste behavior mentioned in #1285). @ronkok, do you remember a reason why we preferred this way? Maybe it's to deal with \mathbf/\boldsymbol/\mathit etc. correctly...

An alternative of course would be to add the characters to the fonts, which should be really easy (as it's just duplication), and maybe the "right" way to do things. (Maybe a good test of our new fonts infrastructure.)

@ronkok
Copy link
Collaborator

ronkok commented May 16, 2021

I do think a macro that returned a \rm or \mathrm would probably act incorrectly if nested inside some combination of \text, \mathbf, \boldsymbol, \mathit, etc. And the current symbol table method does return an incorrect Unicode point in MathML.

I suppose we could get the best of both by creating a new file in the functions folder just for upper case Greek letters. That method affords a lower level access to parse nodes.

I can probably do that, but not right away. Got something else cooking.

edemaine added a commit that referenced this issue May 18, 2021
Improves MathML output and copy/paste behavior.

Fixes #3025
edemaine added a commit that referenced this issue May 18, 2021
Improves MathML output and copy/paste behavior.

Fixes #3025
edemaine added a commit that referenced this issue Aug 28, 2021
Improves MathML output and copy/paste behavior.

Fixes #3025
edemaine added a commit that referenced this issue Aug 28, 2021
Improves MathML output and copy/paste behavior.

Fixes #3025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants