Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
49f85211
Commit
49f85211
authored
Mar 08, 2013
by
Peter Baratta
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More documentation for the javascript
parent
c6545eb0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
16 deletions
+29
-16
common/static/js/capa/symbolic_mathjax_preprocessor.js
+29
-16
No files found.
common/static/js/capa/symbolic_mathjax_preprocessor.js
View file @
49f85211
/* This file defines a processor in between the student's math input
(AsciiMath) and what is read by MathJax. It allows for our own
customizations, such as use of the syntax "a_b__x" in superscripts, or
possibly coloring certain variables, etc&.
It is used in the <textline> definition like the following:
<symbolicresponse expect="a_b^c + b_x__d" size="30">
<textline math="1"
preprocessorClassName="SymbolicMathjaxPreprocessor"
preprocessorSrc="/static/js/capa/symbolic_mathjax_preprocessor.js"/>
</symbolicresponse>
*/
window
.
SymbolicMathjaxPreprocessor
=
function
()
{
window
.
SymbolicMathjaxPreprocessor
=
function
()
{
this
.
fn
=
function
(
eqn
)
{
this
.
fn
=
function
(
eqn
)
{
// flags and config
// flags and config
var
superscriptsOn
=
true
;
var
superscriptsOn
=
true
;
if
(
superscriptsOn
)
{
if
(
superscriptsOn
)
{
// find instances of "__" and make them superscripts ("^") and tag them
// find instances of "__" and make them superscripts ("^") and tag them
// as such. Specifcally replace instances of "__X" or "__{XYZ}" with
// as such. Specifcally replace instances of "__X" or "__{XYZ}" with
// "^{CHAR$1}", marking superscripts as different from powers
// "^{CHAR$1}", marking superscripts as different from powers
// a zero width space--this is an invisible character that no one would
// a zero width space--this is an invisible character that no one would
// use, that gets passed through MathJax and to the server
// use, that gets passed through MathJax and to the server
var
c
=
"
\
u200b"
;
var
c
=
"
\
u200b"
;
eqn
=
eqn
.
replace
(
/__
(?:([^\{])
|
\{([^\}]
+
)\})
/g
,
'^{'
+
c
+
'$1$2}'
);
eqn
=
eqn
.
replace
(
/__
(?:([^\{])
|
\{([^\}]
+
)\})
/g
,
'^{'
+
c
+
'$1$2}'
);
// NOTE: MathJax supports '\class{name}{mathcode}' but not for asciimath
// NOTE: MathJax supports '\class{name}{mathcode}' but not for asciimath
// input, which is too bad. This would be preferable to the
char tag
// input, which is too bad. This would be preferable to this
char tag
}
}
return
eqn
;
return
eqn
;
};
};
};
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment