mirror of
https://github.com/typecho/plugins.git
synced 2024-12-21 20:40:08 +08:00
upgrade LaTex Plugin: customize ```mark enabled
This commit is contained in:
parent
6e0762e2eb
commit
7c3892302e
@ -41,7 +41,7 @@ class GoogleAnalytics_Plugin implements Typecho_Plugin_Interface
|
||||
public static function config(Typecho_Widget_Helper_Form $form)
|
||||
{
|
||||
/** 分类名称 */
|
||||
$account = new Typecho_Widget_Helper_Form_Element_Text('account', NULL, 'UA-XXXXXXX-X', _t('Google Analytics 帐号'));
|
||||
$account = new Typecho_Widget_Helper_Form_Element_Text('account', NULL, 'UA-XXXXXXX-X', _t('Google Analytics 帐号'), _t('此帐号可在 GA 管理平台查询;格式为 UA-XXXXXXX-X 。'));
|
||||
$form->addInput($account);
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* @package LaTex
|
||||
* @author mutoo
|
||||
* @version 1.0.0
|
||||
* @version 1.1.0
|
||||
* @link http://blog.mutoo.im/LaTex.html
|
||||
*/
|
||||
class LaTex_Plugin implements Typecho_Plugin_Interface
|
||||
@ -39,7 +39,10 @@ class LaTex_Plugin implements Typecho_Plugin_Interface
|
||||
* @param Typecho_Widget_Helper_Form $form 配置面板
|
||||
* @return void
|
||||
*/
|
||||
public static function config(Typecho_Widget_Helper_Form $form){}
|
||||
public static function config(Typecho_Widget_Helper_Form $form){
|
||||
$mark = new Typecho_Widget_Helper_Form_Element_Text('mark', NULL, 'latex', _t('自定义标记'), _t('在 Markdown 语法环境下使用以下代码进行公式转换:<blockquote>```自定义标记<br/>公式<br/>```</blockquote>'));
|
||||
$form->addInput($mark);
|
||||
}
|
||||
|
||||
/**
|
||||
* 个人用户的配置面板
|
||||
@ -60,5 +63,7 @@ class LaTex_Plugin implements Typecho_Plugin_Interface
|
||||
public static function footer() {
|
||||
$jsUrl = Helper::options()->pluginUrl . '/LaTex/latex.js';
|
||||
echo '<script type="text/javascript" src="'. $jsUrl .'"></script>';
|
||||
$mark = Typecho_Widget::widget('Widget_Options')->plugin('LaTex')->mark;
|
||||
echo '<script type="text/javascript">latex.parse("'. $mark. '");</script>';
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,29 @@
|
||||
(function() {
|
||||
var $ = document.querySelectorAll.bind(document);
|
||||
var latex = $('code.lang-LaTex, code.lang-latex, code.lang-tex');
|
||||
for (var i = 0, l = latex.length; i < l; i++) {
|
||||
var node = latex[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);
|
||||
(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);
|
@ -2250,7 +2250,7 @@ var zen_editor = (function(){
|
||||
* @include "editor.js"
|
||||
* @include "../../aptana/lib/html_matcher.js"
|
||||
* @include "../../aptana/lib/zen_coding.js"
|
||||
*/
|
||||
*/
|
||||
|
||||
/**
|
||||
* Search for abbreviation in editor from current caret position
|
||||
|
Loading…
Reference in New Issue
Block a user