mathjax / mathjax/MathJax-src

Dedicated interface for options

Open
#524 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
2.4k
Forks
245
Avg merge
5d 2h
Merged PRs (30d)
2

Description

I'm not sure this is the right place to discuss this issue, it is about the interface of SVG and CHTML class.

https://github.com/mathjax/MathJax-src/blob/b526361f6d036772491f4b521361664df44b2768/ts/output/svg.ts#L112-L115
https://github.com/mathjax/MathJax-src/blob/b526361f6d036772491f4b521361664df44b2768/ts/output/chtml.ts#L127-L130

Currently, SVG and CHTML class takes option params which are defined as OptionList.

https://github.com/mathjax/MathJax-src/blob/b526361f6d036772491f4b521361664df44b2768/ts/util/Options.ts#L40

OptionList is an object with an index signature that accepts any key and value, resulting TypeScript won't check key of a passed parameter so that it is hard for users to tell what options are available for SVG or CHTML class without seeing the document.

I've already written these interfaces for another project and feel like it should be bundled with MathJax by default.
https://github.com/remarkjs/remark-math/pull/48

interface MathJaxSVGOptions {
  scale: number
  minScale: number
  mtextInheritFont: boolean
  merrorInheritFont: boolean
  mathmlSpacing: boolean
  skipAttributes: {[index: string]: boolean}
  exFactor: number
  displayAlign: 'left' | 'center' | 'right'
  displayIndent: string
  fontCache: 'local' | 'global'
  localID: string | null
  internalSpeechTitles: boolean
  titleID: number
}

Is it ok to send a PR to include these interfaces?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the SVG and CHTML constructors in ts/output/svg.ts and ts/output/chtml.ts, then inspect OptionList in ts/util/Options.ts. Define dedicated option interfaces for the two classes based on their existing options, and confirm that the public parameter types expose valid option keys without breaking current usage.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
developer-experience
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.