(delim, height, sequence, options)
| 8614 | |
| 8615 | |
| 8616 | var traverseSequence = function traverseSequence(delim, height, sequence, options) { |
| 8617 | // Here, we choose the index we should start at in the sequences. In smaller |
| 8618 | // sizes (which correspond to larger numbers in style.size) we start earlier |
| 8619 | // in the sequence. Thus, scriptscript starts at index 3-3=0, script starts |
| 8620 | // at index 3-2=1, text starts at 3-1=2, and display starts at min(2,3-0)=2 |
| 8621 | var start = Math.min(2, 3 - options.style.size); |
| 8622 | |
| 8623 | for (var i = start; i < sequence.length; i++) { |
| 8624 | if (sequence[i].type === "stack") { |
| 8625 | // This is always the last delimiter, so we just break the loop now. |
| 8626 | break; |
| 8627 | } |
| 8628 | |
| 8629 | var metrics = delimiter_getMetrics(delim, delimTypeToFont(sequence[i]), "math"); |
| 8630 | var heightDepth = metrics.height + metrics.depth; // Small delimiters are scaled down versions of the same font, so we |
| 8631 | // account for the style change size. |
| 8632 | |
| 8633 | if (sequence[i].type === "small") { |
| 8634 | var newOptions = options.havingBaseStyle(sequence[i].style); |
| 8635 | heightDepth *= newOptions.sizeMultiplier; |
| 8636 | } // Check if the delimiter at this size works for the given height. |
| 8637 | |
| 8638 | |
| 8639 | if (heightDepth > height) { |
| 8640 | return sequence[i]; |
| 8641 | } |
| 8642 | } // If we reached the end of the sequence, return the last sequence element. |
| 8643 | |
| 8644 | |
| 8645 | return sequence[sequence.length - 1]; |
| 8646 | }; |
| 8647 | /** |
| 8648 | * Make a delimiter of a given height+depth, with optional centering. Here, we |
| 8649 | * traverse the sequences, and create a delimiter that the sequence tells us to. |
no test coverage detected