Add \ion, \positiveion, \negativeion commands for chemistry notation#45
Open
drdrew42 wants to merge 1 commit into
Open
Add \ion, \positiveion, \negativeion commands for chemistry notation#45drdrew42 wants to merge 1 commit into
drdrew42 wants to merge 1 commit into
Conversation
Ion charge notation — `\ion[+]{2}` rendering the "2+" of a 2+ cation — is a superscript-only command: an editable charge block followed by a fixed sign. `\positiveion` and `\negativeion` are sign-bound shorthands.
These commands existed in a downstream MathQuill fork used for WeBWorK chemistry problems (the chemQuill answer-entry toolbars); this restores them on @openwebwork/mathquill so that work can drop the private fork.
Ion extends SupSub, mirroring the existing subscript/superscript classes. latex() serializes to \ion[sign]{charge}; \positiveion / \negativeion canonicalize to the same. Round-trip tests added to test/latex.test.ts.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
What
Adds three LaTeX commands for chemistry ion-charge notation:
\ion[sign]{charge}— a superscript-only command: an editable charge block followed by a fixed+/-sign, rendering e.g. the "2+" of a 2+ cation.\positiveion/\negativeion— sign-bound shorthands that canonicalize to\ion[+]{…}/\ion[-]{…}.Why
These commands existed in a downstream MathQuill fork used for WeBWorK chemistry problems — the chemistry answer-entry toolbars drive
\positiveion/\negativeionfor entering ion charges. They were lost when that work moved onto@openwebwork/mathquill, silently breaking those toolbar buttons. Restoring them upstream lets the downstream work drop the private fork.How
IonextendsSupSub, mirroring the existing subscript/superscript classes incommands.ts—supsub = 'sup', anhtmlTemplatecarrying the editable charge block plus a.mq-ion-classed sign span, and aparser()built onlatexMathParser.optBlock/.blockexactly likeNthRoot.latex()serializes to\ion[sign]{charge}; an absent optional sign defaults to+, and an empty charge block to1..mq-ionis a styling hook on the sign span — no CSS rule is added; it renders correctly with the existingmq-supstyles.Testing
npm run build,npm run lint:check, andnpm run format:checkall pass.test/latex.test.ts(theion chargestest), following the existingassertParsesLatexpattern.🤖 Generated with Claude Code