(grp, options)
| 7366 | |
| 7367 | // NOTE: Unlike most `htmlBuilder`s, this one handles not only "accent", but |
| 7368 | const htmlBuilder = (grp, options) => { |
| 7369 | // Accents are handled in the TeXbook pg. 443, rule 12. |
| 7370 | let base; |
| 7371 | let group; |
| 7372 | const supSub = checkNodeType(grp, "supsub"); |
| 7373 | let supSubGroup; |
| 7374 | |
| 7375 | if (supSub) { |
| 7376 | // If our base is a character box, and we have superscripts and |
| 7377 | // subscripts, the supsub will defer to us. In particular, we want |
| 7378 | // to attach the superscripts and subscripts to the inner body (so |
| 7379 | // that the position of the superscripts and subscripts won't be |
| 7380 | // affected by the height of the accent). We accomplish this by |
| 7381 | // sticking the base of the accent into the base of the supsub, and |
| 7382 | // rendering that, while keeping track of where the accent is. |
| 7383 | // The real accent group is the base of the supsub group |
| 7384 | group = assertNodeType(supSub.base, "accent"); // The character box is the base of the accent group |
| 7385 | |
| 7386 | base = group.base; // Stick the character box into the base of the supsub group |
| 7387 | |
| 7388 | supSub.base = base; // Rerender the supsub group with its new base, and store that |
| 7389 | // result. |
| 7390 | |
| 7391 | supSubGroup = assertSpan(buildGroup(supSub, options)); // reset original base |
| 7392 | |
| 7393 | supSub.base = group; |
| 7394 | } else { |
| 7395 | group = assertNodeType(grp, "accent"); |
| 7396 | base = group.base; |
| 7397 | } // Build the base group |
| 7398 | |
| 7399 | |
| 7400 | const body = buildGroup(base, options.havingCrampedStyle()); // Does the accent need to shift for the skew of a character? |
| 7401 | |
| 7402 | const mustShift = group.isShifty && utils.isCharacterBox(base); // Calculate the skew of the accent. This is based on the line "If the |
| 7403 | // nucleus is not a single character, let s = 0; otherwise set s to the |
| 7404 | // kern amount for the nucleus followed by the \skewchar of its font." |
| 7405 | // Note that our skew metrics are just the kern between each character |
| 7406 | // and the skewchar. |
| 7407 | |
| 7408 | let skew = 0; |
| 7409 | |
| 7410 | if (mustShift) { |
| 7411 | // If the base is a character box, then we want the skew of the |
| 7412 | // innermost character. To do that, we find the innermost character: |
| 7413 | const baseChar = utils.getBaseElem(base); // Then, we render its group to get the symbol inside it |
| 7414 | |
| 7415 | const baseGroup = buildGroup(baseChar, options.havingCrampedStyle()); // Finally, we pull the skew off of the symbol. |
| 7416 | |
| 7417 | skew = assertSymbolDomNode(baseGroup).skew; // Note that we now throw away baseGroup, because the layers we |
| 7418 | // removed with getBaseElem might contain things like \color which |
| 7419 | // we can't get rid of. |
| 7420 | // TODO(emily): Find a better way to get the skew |
| 7421 | } // calculate the amount of space between the body and the accent |
| 7422 | |
| 7423 | |
| 7424 | let clearance = Math.min(body.height, options.fontMetrics().xHeight); // Build the accent |
| 7425 |
nothing calls this directly
no test coverage detected