Skip to content

Commit

Permalink
Fix KaTeX#136: Size commands generate fragments, not spans.
Browse files Browse the repository at this point in the history
This is so the size commands don't hide the types of their enclosed
atoms. Addresses KaTeX#136.

This slightly changes the vertical position of the Sizing test. Not
sure the vertical position matters, so change the test.
  • Loading branch information
kohler committed Nov 26, 2016
1 parent 86752d4 commit e95dda4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions src/buildHTML.js
Original file line number Diff line number Diff line change
Expand Up @@ -1116,18 +1116,25 @@ groupTypes.sizing = function(group, options, prev) {
var inner = buildExpression(group.value.value,
options.withSize(group.value.size), prev);

// Compute the correct maxFontSize.
var style = options.style;
var span = makeSpan(["mord"],
[makeSpan(["sizing", "reset-" + options.size, group.value.size,
style.cls()],
inner)],
options);

// Calculate the correct maxFontSize manually
var fontSize = buildCommon.sizingMultiplier[group.value.size];
span.maxFontSize = fontSize * style.sizeMultiplier;
fontSize = fontSize * style.sizeMultiplier;

// Add size-resetting classes to the inner list and set maxFontSize
// manually.
for (var i = 0; i < inner.length; i++) {
var pos = utils.indexOf(inner[i].classes, "sizing");
if (pos < 0) {
inner[i].classes.push("sizing", "reset-" + options.size,
group.value.size, style.cls());
inner[i].maxFontSize = fontSize;
} else if (inner[i].classes[pos + 1] === "reset-" + group.value.size) {
inner[i].classes[pos + 1] = "reset-" + options.size;
}
}

return span;
return buildCommon.makeFragment(inner);
};

groupTypes.styling = function(group, options, prev) {
Expand Down
Binary file modified test/screenshotter/images/Sizing-chrome.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/screenshotter/images/Sizing-firefox.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e95dda4

Please sign in to comment.