(grp, options)
| 7473 | |
| 7474 | // NOTE: Unlike most `htmlBuilder`s, this one handles not only "accent", but |
| 7475 | var accent_htmlBuilder = function htmlBuilder(grp, options) { |
| 7476 | // Accents are handled in the TeXbook pg. 443, rule 12. |
| 7477 | var base; |
| 7478 | var group; |
| 7479 | var supSub = checkNodeType(grp, "supsub"); |
| 7480 | var supSubGroup; |
| 7481 | |
| 7482 | if (supSub) { |
| 7483 | // If our base is a character box, and we have superscripts and |
| 7484 | // subscripts, the supsub will defer to us. In particular, we want |
| 7485 | // to attach the superscripts and subscripts to the inner body (so |
| 7486 | // that the position of the superscripts and subscripts won't be |
| 7487 | // affected by the height of the accent). We accomplish this by |
| 7488 | // sticking the base of the accent into the base of the supsub, and |
| 7489 | // rendering that, while keeping track of where the accent is. |
| 7490 | // The real accent group is the base of the supsub group |
| 7491 | group = assertNodeType(supSub.base, "accent"); // The character box is the base of the accent group |
| 7492 | |
| 7493 | base = group.base; // Stick the character box into the base of the supsub group |
| 7494 | |
| 7495 | supSub.base = base; // Rerender the supsub group with its new base, and store that |
| 7496 | // result. |
| 7497 | |
| 7498 | supSubGroup = assertSpan(buildHTML_buildGroup(supSub, options)); // reset original base |
| 7499 | |
| 7500 | supSub.base = group; |
| 7501 | } else { |
| 7502 | group = assertNodeType(grp, "accent"); |
| 7503 | base = group.base; |
| 7504 | } // Build the base group |
| 7505 | |
| 7506 | |
| 7507 | var body = buildHTML_buildGroup(base, options.havingCrampedStyle()); // Does the accent need to shift for the skew of a character? |
| 7508 | |
| 7509 | var mustShift = group.isShifty && utils.isCharacterBox(base); // Calculate the skew of the accent. This is based on the line "If the |
| 7510 | // nucleus is not a single character, let s = 0; otherwise set s to the |
| 7511 | // kern amount for the nucleus followed by the \skewchar of its font." |
| 7512 | // Note that our skew metrics are just the kern between each character |
| 7513 | // and the skewchar. |
| 7514 | |
| 7515 | var skew = 0; |
| 7516 | |
| 7517 | if (mustShift) { |
| 7518 | // If the base is a character box, then we want the skew of the |
| 7519 | // innermost character. To do that, we find the innermost character: |
| 7520 | var baseChar = utils.getBaseElem(base); // Then, we render its group to get the symbol inside it |
| 7521 | |
| 7522 | var baseGroup = buildHTML_buildGroup(baseChar, options.havingCrampedStyle()); // Finally, we pull the skew off of the symbol. |
| 7523 | |
| 7524 | skew = assertSymbolDomNode(baseGroup).skew; // Note that we now throw away baseGroup, because the layers we |
| 7525 | // removed with getBaseElem might contain things like \color which |
| 7526 | // we can't get rid of. |
| 7527 | // TODO(emily): Find a better way to get the skew |
| 7528 | } // calculate the amount of space between the body and the accent |
| 7529 | |
| 7530 | |
| 7531 | var clearance = Math.min(body.height, options.fontMetrics().xHeight); // Build the accent |
| 7532 |
nothing calls this directly
no test coverage detected