-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add failing unit tests from wiki and try-ctop page
- Loading branch information
1 parent
9f17e8f
commit 7de63c7
Showing
76 changed files
with
6,058 additions
and
3,659 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,45 @@ | ||
CToP.transform(document.querySelectorAll('math')); | ||
function formatXml(xml) { | ||
var formatted = ''; | ||
var reg = /(>)(<)(\/*)/g; | ||
xml = xml.replace(reg, '$1\r\n$2$3'); | ||
var pad = 0; | ||
xml.split('\r\n').map(function(node,index) { | ||
var indent = 0; | ||
if (node.match( /.+<\/\w[^>]*>$/ )) { | ||
indent = 0; | ||
} else if (node.match( /^<\/\w/ )) { | ||
if (pad != 0) { | ||
pad -= 1; | ||
} | ||
} else if (node.match( /^<\w[^>]*[^\/]>.*$/ )) { | ||
indent = 1; | ||
} else { | ||
indent = 0; | ||
} | ||
|
||
var padding = ''; | ||
for (var i = 0; i < pad; i++) { | ||
padding += ' '; | ||
} | ||
|
||
formatted += padding + node + '\r\n'; | ||
pad += indent; | ||
}); | ||
|
||
return formatted; | ||
} | ||
|
||
Array.prototype.map.call(document.querySelectorAll('.unit'),function(unit) { | ||
var math = unit.querySelector('math').outerHTML; | ||
var t = document.createElement('pre'); | ||
t.textContent = math; | ||
unit.appendChild(t); | ||
try { | ||
var mathNodes = unit.querySelectorAll('math'); | ||
CToP.transform(mathNodes); | ||
var math = unit.querySelector('math').outerHTML; | ||
var t = document.createElement('pre'); | ||
t.textContent = formatXml(math); | ||
unit.appendChild(t); | ||
MathJax.Hub.Queue(["Typeset",MathJax.Hub,unit]); | ||
} | ||
catch(e) { | ||
console.log(e); | ||
} | ||
}) | ||
|
||
MathJax.Hub.Queue(["Typeset",MathJax.Hub]); |
Oops, something went wrong.