mathjax / MathJax-src

MathJax source code for version 3 and beyond

Home Page:https://www.mathjax.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SVG StyleList unused styles?

pkra opened this issue · comments

The styles for the SVG output include .mjx-dashed and .mjx-dotted:

'g[data-mml-node="mtable"] > .mjx-dashed, svg[data-table] > g > .mjx-dashed': {
'stroke-dasharray': '140'
},
'g[data-mml-node="mtable"] > .mjx-dotted, svg[data-table] > g > .mjx-dotted': {
'stroke-linecap': 'round',
'stroke-dasharray': '0,140'
},

Since I couldn't find any content with either class on the AMS end, I looked where these classes might get added - and didn't find anything. It looks like addBorderBroken does the job of handling these borders.

if (style[i] === 'dashed' || style[i] === 'dotted') {
this.addBorderBroken(path, color[i], style[i], width[i], i);
} else {

Perhaps the classes are leftovers from v2 or there was a later change or (more likely) I didn't spot where these classes are actually used.

These are used for the lines within a matrix (from the rowlines and columnlines attributes of mtable), and are created in the lineClass() function

protected lineClass(style: string): string {
return CLASSPREFIX + style;
}

It constructs the class name dynamically, which is why searching for mjx-dashed or mjx-dotted won't find it.

This method is used in the makeFrame(), makeVLine(), and makeHLine() methods that follow it.

Thanks for clarifying!

Just to follow up and more FYI.

Looking at lineClass, I noticed (from AMS content) that this generates one class name (mjx-solid) that has no declaration in StyleList. So IIUC since authors could specify random attributes, this generates random class names, but only dotted and dashed do anything. I guess that's nice for authors who want to add custom styles.

This reminds me that in AMS content I found that the complex selectors in StyleList never matter (to the content), except for the overflow related one (which we actually replace with a helper class). Now it looks there's also always a class; that's nice (unless mjx-solid is likely to be removed).

I also noticed that data-line has two different attribute values that are never used (and data-frame doesn't really need "true" either). So switching to mjx-solid offers additional opportunities to clean up bloat in post - which is nice.

I realize I'm playing with fire but for SVG this has worked out well over the past few years.