Add ops
Summary: Add named functions like \sin, \cos, etc. Reviewers: spicyj Reviewed By: spicyj Differential Revision: http://phabricator.benalpert.com/D51
This commit is contained in:
parent
4a3ed8dce0
commit
42cc8b1a12
|
@ -90,6 +90,8 @@ var buildGroup = function(group, prev) {
|
|||
return makeSpan("mpunct", textit(group.value));
|
||||
} else if (group.type === "ordgroup") {
|
||||
return makeSpan("mord", buildExpression(group.value));
|
||||
} else if (group.type === "namedfn") {
|
||||
return makeSpan("mop", textit(group.value.slice(1)));
|
||||
} else {
|
||||
console.log("Unknown type:", group.type);
|
||||
}
|
||||
|
|
4
lexer.js
4
lexer.js
|
@ -27,6 +27,10 @@ var funcs = [
|
|||
'qquad', 'quad', ' ', 'space', ',', ':', ';',
|
||||
// Colors
|
||||
'blue', 'orange', 'pink', 'red', 'green', 'gray', 'purple',
|
||||
// Mathy functions
|
||||
"arcsin", "arccos", "arctan", "arg", "cos", "cosh", "cot", "coth", "csc",
|
||||
"deg", "dim", "exp", "hom", "ker", "lg", "ln", "log", "sec", "sin", "sinh",
|
||||
"tan", "tanh",
|
||||
// Other functions
|
||||
'dfrac', 'llap', 'rlap'
|
||||
];
|
||||
|
|
44
parser.jison
44
parser.jison
|
@ -96,6 +96,50 @@ func
|
|||
{$$ = [{type: 'llap', value: $2}];}
|
||||
| 'rlap' group
|
||||
{$$ = [{type: 'rlap', value: $2}];}
|
||||
| 'arcsin'
|
||||
{$$ = [{type: 'namedfn', value: yytext}];}
|
||||
| 'arccos'
|
||||
{$$ = [{type: 'namedfn', value: yytext}];}
|
||||
| 'arctan'
|
||||
{$$ = [{type: 'namedfn', value: yytext}];}
|
||||
| 'arg'
|
||||
{$$ = [{type: 'namedfn', value: yytext}];}
|
||||
| 'cos'
|
||||
{$$ = [{type: 'namedfn', value: yytext}];}
|
||||
| 'cosh'
|
||||
{$$ = [{type: 'namedfn', value: yytext}];}
|
||||
| 'cot'
|
||||
{$$ = [{type: 'namedfn', value: yytext}];}
|
||||
| 'coth'
|
||||
{$$ = [{type: 'namedfn', value: yytext}];}
|
||||
| 'csc'
|
||||
{$$ = [{type: 'namedfn', value: yytext}];}
|
||||
| 'deg'
|
||||
{$$ = [{type: 'namedfn', value: yytext}];}
|
||||
| 'dim'
|
||||
{$$ = [{type: 'namedfn', value: yytext}];}
|
||||
| 'exp'
|
||||
{$$ = [{type: 'namedfn', value: yytext}];}
|
||||
| 'hom'
|
||||
{$$ = [{type: 'namedfn', value: yytext}];}
|
||||
| 'ker'
|
||||
{$$ = [{type: 'namedfn', value: yytext}];}
|
||||
| 'lg'
|
||||
{$$ = [{type: 'namedfn', value: yytext}];}
|
||||
| 'ln'
|
||||
{$$ = [{type: 'namedfn', value: yytext}];}
|
||||
| 'log'
|
||||
{$$ = [{type: 'namedfn', value: yytext}];}
|
||||
| 'sec'
|
||||
{$$ = [{type: 'namedfn', value: yytext}];}
|
||||
| 'sin'
|
||||
{$$ = [{type: 'namedfn', value: yytext}];}
|
||||
| 'sinh'
|
||||
{$$ = [{type: 'namedfn', value: yytext}];}
|
||||
| 'tan'
|
||||
{$$ = [{type: 'namedfn', value: yytext}];}
|
||||
| 'tanh'
|
||||
{$$ = [{type: 'namedfn', value: yytext}];}
|
||||
;
|
||||
|
||||
atom
|
||||
|
|
|
@ -124,6 +124,46 @@ big parens
|
|||
margin-left: 0.16667em;
|
||||
}
|
||||
|
||||
.mop + .mord {
|
||||
margin-left: 0.16667em;
|
||||
}
|
||||
|
||||
.mop + .mop {
|
||||
margin-left: 0.16667em;
|
||||
}
|
||||
|
||||
.mop + .mrel {
|
||||
margin-left: 0.27778em;
|
||||
}
|
||||
|
||||
.mop + .minner {
|
||||
margin-left: 0.16667em;
|
||||
}
|
||||
|
||||
.mord + .mop {
|
||||
margin-left: 0.16667em;
|
||||
}
|
||||
|
||||
.mbin + .mop {
|
||||
margin-left: 0.22222em;
|
||||
}
|
||||
|
||||
.mrel + .mop {
|
||||
margin-left: 0.27778em;
|
||||
}
|
||||
|
||||
.mclose + .mop {
|
||||
margin-left: 0.16667em;
|
||||
}
|
||||
|
||||
.mpunct + .mop {
|
||||
margin-left: 0.16667em;
|
||||
}
|
||||
|
||||
.minner + .mop {
|
||||
margin-left: 0.16667em;
|
||||
}
|
||||
|
||||
.msub {
|
||||
vertical-align: bottom;
|
||||
font-size: 70%;
|
||||
|
|
Loading…
Reference in New Issue
Block a user