Skip to content

Commit b003242

Browse files
committed
katex [nfc]: Join the CSS-class switch statements into one
Conveniently, the two redundant rules say the exact same thing when they apply. So the first one has no effect, and we can ignore it.
1 parent 3ac0037 commit b003242

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

lib/model/katex.dart

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ class _KatexParser {
141141
// Aggregate the CSS styles that apply, in the same order as the CSS
142142
// classes specified for this span, mimicking the behaviour on web.
143143
//
144-
// Each case in the switch blocks below is a separate CSS class definition
144+
// Each case in the switch block below is a separate CSS class definition
145145
// in the same order as in katex.scss :
146146
// https://github.com/KaTeX/KaTeX/blob/2fe1941b/src/styles/katex.scss
147147
// A copy of class definition (where possible) is accompanied in a comment
@@ -178,10 +178,10 @@ class _KatexParser {
178178
styles.fontFamily = 'KaTeX_Main';
179179
classFound = true;
180180

181-
case 'textsf':
182-
// .textsf { font-family: KaTeX_SansSerif; }
183-
styles.fontFamily = 'KaTeX_SansSerif';
184-
classFound = true;
181+
// case 'textsf':
182+
// // .textsf { font-family: KaTeX_SansSerif; }
183+
// This CSS rule has no effect, because the other `.textsf` rule below
184+
// has the exact same list of declarations. Handle it there instead.
185185

186186
case 'texttt':
187187
// .texttt { font-family: KaTeX_Typewriter; }
@@ -261,13 +261,7 @@ class _KatexParser {
261261
// .textscr { font-family: KaTeX_Script; }
262262
styles.fontFamily = 'KaTeX_Script';
263263
classFound = true;
264-
}
265264

266-
// We can't add the case for the next class (.mathsf, .textsf) in the
267-
// above switch block, because there is already a case for .textsf above.
268-
// So start a new block, to keep the order of the cases here same as the
269-
// CSS class definitions in katex.scss .
270-
switch (spanClass) {
271265
case 'mathsf':
272266
case 'textsf':
273267
// .mathsf,
@@ -378,13 +372,11 @@ class _KatexParser {
378372
throw KatexHtmlParseError();
379373

380374
// TODO handle more classes from katex.scss
381-
}
382375

383-
// Ignore these classes because they don't have a CSS definition
384-
// in katex.scss, but we encounter them in the generated HTML.
385-
switch (spanClass) {
386376
case 'mord':
387377
case 'mopen':
378+
// Ignore these classes because they don't have a CSS definition
379+
// in katex.scss, but we encounter them in the generated HTML.
388380
classFound = true;
389381
}
390382

0 commit comments

Comments
 (0)