mirror of
https://github.com/typecho/plugins.git
synced 2024-12-21 20:40:08 +08:00
29 lines
672 B
JavaScript
29 lines
672 B
JavaScript
(function(global) {
|
|
var previousLatex = global.latex;
|
|
|
|
global.latex = {
|
|
parse: function(mark) {
|
|
if (!mark) {
|
|
return;
|
|
}
|
|
|
|
var $ = document.querySelectorAll.bind(document);
|
|
var nodes = $('code.lang-' + mark);
|
|
for (var i = 0, l = nodes.length; i < l; i++) {
|
|
var node = nodes[i];
|
|
var latex_image = document.createElement("img");
|
|
latex_image.src = "http://latex.codecogs.com/png.latex?" + node.innerHTML;
|
|
// replace with image
|
|
var parent = node.parentNode;
|
|
parent.insertBefore(latex_image, node);
|
|
parent.removeChild(node);
|
|
}
|
|
|
|
},
|
|
noConflict: function() {
|
|
global.latex = previousLatex;
|
|
return this;
|
|
}
|
|
}
|
|
|
|
})(this); |