mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-11 05:58:40 +00:00
Add some AMS characters
Summary: \nleq and \ngeq are AMS characters, so add support for parsing and showing those. Also, add font metrics from the ams_regular font. Test Plan: View `\ngeq \geq`, make sure that they look the same but with a slash through `\ngeq`. View `a \ngeq b`, make sure there's the right spacing for a rel. Reviewers: alpert Reviewed By: alpert Differential Revision: http://phabricator.khanacademy.org/D3547
This commit is contained in:
@@ -265,11 +265,13 @@ var copyFuncs = {
|
|||||||
"\\leftarrow",
|
"\\leftarrow",
|
||||||
"\\leq",
|
"\\leq",
|
||||||
"\\neq",
|
"\\neq",
|
||||||
"\\ngeq",
|
|
||||||
"\\nleq",
|
|
||||||
"\\rightarrow",
|
"\\rightarrow",
|
||||||
"\\to"
|
"\\to"
|
||||||
],
|
],
|
||||||
|
"amsrel": [
|
||||||
|
"\\ngeq",
|
||||||
|
"\\nleq"
|
||||||
|
],
|
||||||
"spacing": [
|
"spacing": [
|
||||||
"\\ ",
|
"\\ ",
|
||||||
"\\,",
|
"\\,",
|
||||||
|
@@ -40,6 +40,7 @@ var groupToType = {
|
|||||||
textord: "mord",
|
textord: "mord",
|
||||||
bin: "mbin",
|
bin: "mbin",
|
||||||
rel: "mrel",
|
rel: "mrel",
|
||||||
|
amsrel: "mrel",
|
||||||
open: "mopen",
|
open: "mopen",
|
||||||
close: "mclose",
|
close: "mclose",
|
||||||
frac: "minner",
|
frac: "minner",
|
||||||
@@ -90,6 +91,10 @@ var groupTypes = {
|
|||||||
return makeSpan(["mrel", options.color], [mathrm(group.value)]);
|
return makeSpan(["mrel", options.color], [mathrm(group.value)]);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
amsrel: function(group, options, prev) {
|
||||||
|
return makeSpan(["mrel", options.color], [amsrm(group.value)]);
|
||||||
|
},
|
||||||
|
|
||||||
supsub: function(group, options, prev) {
|
supsub: function(group, options, prev) {
|
||||||
var base = buildGroup(group.value.base, options.reset());
|
var base = buildGroup(group.value.base, options.reset());
|
||||||
|
|
||||||
@@ -467,6 +472,10 @@ var mathrm = function(value) {
|
|||||||
return makeText(value, "main-regular");
|
return makeText(value, "main-regular");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var amsrm = function(value) {
|
||||||
|
return makeSpan(["amsrm"], [makeText(value, "ams-regular")]);
|
||||||
|
};
|
||||||
|
|
||||||
var buildTree = function(tree) {
|
var buildTree = function(tree) {
|
||||||
// Setup the default options
|
// Setup the default options
|
||||||
var options = new Options(Style.TEXT, "");
|
var options = new Options(Style.TEXT, "");
|
||||||
|
File diff suppressed because one or more lines are too long
@@ -39,7 +39,7 @@ end
|
|||||||
font_dir = File.join(File.dirname(__FILE__), 'static/fonts/')
|
font_dir = File.join(File.dirname(__FILE__), 'static/fonts/')
|
||||||
metrics = {}
|
metrics = {}
|
||||||
|
|
||||||
%w[main-regular math-italic].each do |face|
|
%w[main-regular math-italic ams-regular].each do |face|
|
||||||
metrics[face] = metrics_for_file(File.join(font_dir, 'katex_%s.ttf' % face))
|
metrics[face] = metrics_for_file(File.join(font_dir, 'katex_%s.ttf' % face))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@@ -30,6 +30,10 @@ big parens
|
|||||||
font-style: italic;
|
font-style: italic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.amsrm {
|
||||||
|
font-family: katex_ams;
|
||||||
|
}
|
||||||
|
|
||||||
@thinspace: 0.16667em;
|
@thinspace: 0.16667em;
|
||||||
@mediumspace: 0.22222em;
|
@mediumspace: 0.22222em;
|
||||||
@thickspace: 0.27778em;
|
@thickspace: 0.27778em;
|
||||||
|
Reference in New Issue
Block a user