mathjax / MathJax-docs

MathJax documentation. Beautiful math in all browsers. Beautifully documented.
Apache License 2.0
548 stars 231 forks source link

[tagformat] correct way to disable id generation entirely #318

Closed pkra closed 1 year ago

pkra commented 1 year ago

This is more of a question but possibly something worth documenting.

We control the IDs across the document (and specify them in mathjax input via \cssId). We currently strip out mathjax-generated IDs in post processing (as they can cause trouble for us, e.g., duplicate IDs when cloning pieces of the document for UI purposes).

I was finally looking again to see if I could disable ID generation via the tagformat extension. It seems like specifying id: () => undefined, would work.

I noticed that this caused some mild changes to the output - the hacky text element with data-id-align and the group withdata-idbox was removed this way. Not a loss for us since we're not using them anyway (though it made me wonder why cssId is not using the same hack).

So I'm wondering if disabling id generation this way might have any drawbacks and/or if there is (or could be) a "proper" way to disable ID generation.

dpvc commented 1 year ago

I took a look at the tagging code, and it looks like what you re doing is OK, as long as you aren't using \ref or \eqref, since they won't know what to link to.

I noticed that this caused some mild changes to the output - the hacky text element with data-id-align and the group with data-idbox was removed this way.

Yes, those are generated for elements that have id attributes, but only when they don't fall on the baseline (that is, ones that are placed explicitly with a vertical offset). So you can get those from your \cssId usage, but only if they are on certain kinds of elements.

The purpose of those is to allow WebKit to scroll to the correct location when the id is the target of a link, like for \ref and \eqref.

pkra commented 1 year ago

Thanks for clarifying.