Single-character macros like active characters#973
Merged
k4b7 merged 3 commits intoKaTeX:masterfrom Nov 24, 2017
Merged
Conversation
Collaborator
|
Cool. This will be helpful for double-struck Unicode characters like ℂ or ℕ. |
Merged
Member
Author
|
@ronkok Great! More motivation for this change. |
k4b7
reviewed
Nov 24, 2017
README.md
Outdated
| - `throwOnError`: `boolean`. If `true`, KaTeX will throw a `ParseError` when it encounters an unsupported command. If `false`, KaTeX will render the unsupported command as text in the color given by `errorColor`. (default: `true`) | ||
| - `errorColor`: `string`. A color string given in the format `"#XXX"` or `"#XXXXXX"`. This option determines the color which unsupported commands are rendered in. (default: `#cc0000`) | ||
| - `macros`: `object`. A collection of custom macros. Each macro is a property with a name like `\name` (written `"\\name"` in JavaScript) which maps to a string that describes the expansion of the macro. | ||
| - `macros`: `object`. A collection of custom macros. Each macro is a property with a name like `\name` (written `"\\name"` in JavaScript) which maps to a string that describes the expansion of the macro. The behavior of single characters can also be redefined by a macro (similar to TeX active characters). |
Member
There was a problem hiding this comment.
The tests allow single characters for the names, but reading this it sounds like only things like \name are accepted. Maybe change the last sentence to read like:
Single characters keys can also be included in which case the character will be redefined as the given macro (similar to TeX active characters).
| it("should allow aliasing characters", function() { | ||
| compareParseTree("x’=c", "x'=c", { | ||
| "’": "'", | ||
| }); |
Member
|
@edemaine thanks for making this change. It's really going to help with the unicode effort. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This tiny PR adds support for redefining single characters by arbitrary macros, while also simplifying the code slightly. I don't see a reason not to allow this, and it would be immediately useful for resolving #967, as well as e.g. users adding support for Unicode characters that KaTeX doesn't already support, or which KaTeX already supports but the user wants to override in a different way. Overall seems like a win.