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

Support Unicode Symbols #950

Merged
merged 5 commits into from Nov 24, 2017
Merged

Support Unicode Symbols #950

merged 5 commits into from Nov 24, 2017

Conversation

ronkok
Copy link
Collaborator

@ronkok ronkok commented Oct 24, 2017

This is the third in a series of PRs to give KaTeX the ability to recognize Unicode character input. This one supports some but not all letter-like symbols and some other symbols. All the characters in this PR will produce textord atoms in math mode.

The list is not comprehensive. It’s a bit eclectic. Some of these characters are important. Others were just easy to include. A few important characters are omitted because it wasn’t clear to me which is the best way to implement them. I’ll address those characters in future PRs.

This is the third in a series of PRs to give KaTeX the ability to recognize Unicode character input. This one supports some but not all letter-like symbols and some other symbols. All the characters in this PR will produce `textord` atoms in `math` mode.

The list is not comprehensive. It’s a bit eclectic. Some of these characters are important. Others were just easy to include. A few important characters are omitted because it wasn’t clear to me which is the best way to implement them. I’ll address those characters in future PRs.
@ronkok
Copy link
Collaborator Author

ronkok commented Oct 24, 2017

Double-struck characters cannot be done with current fonts by just setting a flag in symbols.js. Take ℂ, for example. In the katex-ams font, the character that looks like ℂ is not at code point U+2102 but is instead at code point U+0043. So, the symbols.js flag technique doesn’t work. Rather than wait for font revisions, I wrote macros.

@ronkok
Copy link
Collaborator Author

ronkok commented Oct 24, 2017

As in PR #933, the following table shows the KaTeX function to which each character is mapped and confirmation whether unicode math and/or John Cook’s conversion page map it the same way.

Character Code point Maps to unicode math Cook Other
£ U+00A3 \pounds \mathsterling \sterling \textsterling
¥ U+00A5 \yen \mathyen
ð U+00F0 \eth \matheth \dh
U+2102 \mathbb{C} \BbbC \BbbC
U+210D \mathbb{H} \BbbH \BbbH
U+2111 \Im \frakI
U+2113 \ell
U+2115 \mathbb{N} \BbbN \BbbN
U+2118 \wp
U+2119 \mathbb{P} \BbbP \BbbP
U+211A \mathbb{Q} \BbbQ \BbbQ
U+211C \Re \frakR
U+211D \mathbb{R} \BbbR \BbbR
U+2124 \mathbb{Z} \BbbZ \BbbZ
U+2132 \Finv
U+2135 \aleph
U+2136 \beth
U+2137 \gimel
U+2138 \daleth
U+2141 \Game
U+2200 \forall
U+2201 \complement
U+2202 \partial
U+2203 \exists
U+2207 \nabla \del
U+221E \infty
U+2220 \angle
U+2221 \measuredangle
U+2222 \sphericalangle \sphericalangle \ltrpar
U+2660 \spadesuit
U+2661 \heartsuit
U+2662 \diamondsuit
U+2663 \clubsuit
U+266D \flat
U+266E \natural
U+266F \sharp
U+2713 \checkmark

@kevinbarabash
Copy link
Member

Rather than wait for font revisions, I wrote macros.

I think that's sensible. I think revising the fonts would introduce other complications as it relates to handling font commands such as \mathbb, etc.

@ronkok
Copy link
Collaborator Author

ronkok commented Nov 19, 2017

Let's hold off on this until after PR #973 lands. I'll revise this PR accordingly.

@ronkok
Copy link
Collaborator Author

ronkok commented Nov 23, 2017

The most recent commit reverts a RegEx in MacroExpander.js. So the code in this PR is now dependent on PR #973.

@ronkok
Copy link
Collaborator Author

ronkok commented Nov 24, 2017

Now that PR #973 has landed, this should be good to go.

Copy link
Member

@kevinbarabash kevinbarabash left a comment

Choose a reason for hiding this comment

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

LGTM

defineMacro("\u2119", "\\mathbb{P}");
defineMacro("\u211A", "\\mathbb{Q}");
defineMacro("\u211D", "\\mathbb{R}");
defineMacro("\u2124", "\\mathbb{Z}");
Copy link
Member

Choose a reason for hiding this comment

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

nice!

@kevinbarabash kevinbarabash merged commit a028590 into KaTeX:master Nov 24, 2017
@ronkok ronkok deleted the unicode-symbols branch November 24, 2017 19:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants