mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-08 12:38:39 +00:00
Fix interaction between styles and sizes. (#719)
* Fix interaction between styles and sizes by implementing styles as sizes. Rather than having both `textstyle` CSS classes and `size5` CSS classes affect the font size (and step on each other), implement sizes more the way TeX does: a command like `\displaystyle` changes the current size. This is actually a simplification, since now only `size` affects the size. Simplifies CSS and computation. Many screenshotter tests change; they change to be more like TeX. For instance, `\sqrt` fixes some discrepancies in size treatment. Also: Remove the `Options.withX()` methods in favor of `.havingX()`, which might return the same `options`. Remove `Style.cls()` and `Style.reset()`. Remove `Options.reset()`. You should never modify an `Options`; they should change only by the `havingX()` methods. * Implement TeX sizing for scriptsize/scriptscriptsize. At every size level. Also make the sizes match TeX to the last decimal. * Review comments.
This commit is contained in:
committed by
Kevin Barabash
parent
4f57d53f6e
commit
b866cd5224
@@ -480,7 +480,8 @@ groupTypes.styling = function(group, options) {
|
||||
};
|
||||
|
||||
groupTypes.sizing = function(group, options) {
|
||||
const inner = buildExpression(group.value.value, options);
|
||||
const newOptions = options.havingSize(group.value.size);
|
||||
const inner = buildExpression(group.value.value, newOptions);
|
||||
|
||||
const node = new mathMLTree.MathNode("mstyle", inner);
|
||||
|
||||
@@ -489,8 +490,7 @@ groupTypes.sizing = function(group, options) {
|
||||
// in, so we can't reset the size to normal before changing it. Now
|
||||
// that we're passing an options parameter we should be able to fix
|
||||
// this.
|
||||
node.setAttribute(
|
||||
"mathsize", buildCommon.sizingMultiplier[group.value.size] + "em");
|
||||
node.setAttribute("mathsize", newOptions.sizeMultiplier + "em");
|
||||
|
||||
return node;
|
||||
};
|
||||
|
Reference in New Issue
Block a user