This repository has been archived by the owner on May 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit bad01ce
Showing
66 changed files
with
821 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,116 @@ | ||
<?php | ||
/** | ||
* 自动渲染 KaTeX 公式 | ||
* | ||
* @package AutoKaTeX | ||
* @author SkyWT | ||
* @version 0.1.0 | ||
* @link https://skywt.cn | ||
*/ | ||
class AutoKaTeX_Plugin implements Typecho_Plugin_Interface { | ||
/** | ||
* 激活插件方法,如果激活失败,直接抛出异常 | ||
* | ||
* @access public | ||
* @return void | ||
* @throws Typecho_Plugin_Exception | ||
*/ | ||
public static function activate() { | ||
Typecho_Plugin::factory('Widget_Archive')->header = array(__CLASS__, 'header'); | ||
Typecho_Plugin::factory('Widget_Archive')->footer = array(__CLASS__, 'footer'); | ||
Typecho_Plugin::factory('admin/write-post.php')->content = array(__CLASS__, 'header'); | ||
Typecho_Plugin::factory('admin/write-post.php')->bottom = array(__CLASS__, 'footer'); | ||
} | ||
|
||
/** | ||
* 禁用插件方法,如果禁用失败,直接抛出异常 | ||
* | ||
* @static | ||
* @access public | ||
* @return void | ||
* @throws Typecho_Plugin_Exception | ||
*/ | ||
public static function deactivate() {} | ||
|
||
/** | ||
* 获取插件配置面板 | ||
* | ||
* @access public | ||
* @param Typecho_Widget_Helper_Form $form 配置面板 | ||
* @return void | ||
*/ | ||
public static function config(Typecho_Widget_Helper_Form $form) {} | ||
|
||
/** | ||
* 个人用户的配置面板 | ||
* | ||
* @access public | ||
* @param Typecho_Widget_Helper_Form $form | ||
* @return void | ||
*/ | ||
public static function personalConfig(Typecho_Widget_Helper_Form $form) {} | ||
|
||
/** | ||
* 插件实现方法 | ||
* | ||
* @access public | ||
* @return void | ||
*/ | ||
public static function render() {} | ||
|
||
/** | ||
* 添加额外输出到 Header | ||
* | ||
* @access public | ||
* @return void | ||
*/ | ||
public static function header() { | ||
$pluginDir = Helper::options()->pluginUrl . '/AutoKaTeX'; | ||
echo <<<HTML | ||
<link href="{$pluginDir}/KaTeX/katex.min.css" rel="stylesheet"> | ||
HTML; | ||
} | ||
|
||
/** | ||
* 添加额外输出到 Footer | ||
* | ||
* @access public | ||
* @return void | ||
*/ | ||
public static function footer() { | ||
$pluginDir = Helper::options()->pluginUrl . '/AutoKaTeX'; | ||
echo <<<HTML | ||
<script src="{$pluginDir}/KaTeX/katex.min.js"></script> | ||
<script src="{$pluginDir}/KaTeX/auto-render.min.js"></script> | ||
<script> | ||
function triggerRenderingLaTeX(element) { | ||
renderMathInElement( | ||
element, | ||
{ | ||
delimiters: [ | ||
{left: "$$", right: "$$", display: true}, | ||
{left: "$", right: "$", display: false}, | ||
] | ||
} | ||
); | ||
} | ||
document.addEventListener("DOMContentLoaded", function() { | ||
triggerRenderingLaTeX(document.body); | ||
}); | ||
</script> | ||
HTML; | ||
echo <<<HTML | ||
<script> | ||
document.addEventListener("DOMContentLoaded", function() { | ||
var wmdPreviewLink = document.querySelector("a[href='#wmd-preview']"); | ||
var wmdPreviewContainer = document.querySelector("#wmd-preview"); | ||
if(wmdPreviewLink && wmdPreviewContainer) { | ||
wmdPreviewLink.onclick = function() { | ||
triggerRenderingLaTeX(wmdPreviewContainer); | ||
}; | ||
} | ||
}); | ||
</script> | ||
HTML; | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# AutoKaTeX | ||
|
||
## Intro | ||
|
||
自动用 KaTeX 渲染 LaTeX 公式 | ||
|
||
基于 Typecho 插件 [AutoLaTeX](https://github.com/dreamerblue/AutoLaTeX)修改而来,原作者为 [bLue](https://dreamer.blue)。 | ||
|
||
主要更改: | ||
- 更新 KaTeX 版本为 1.11.1,一部分问题(如公式过长不解析)得以修复。 | ||
- 去除 MathJax 的支持,现在直接(只能)使用 KaTeX。同时删除了插件的配置面板。 | ||
- 不再解析 `[[[(` `)]]]` 之类令人迷惑的标记。 | ||
|
||
## Usage | ||
|
||
下载最新版本的 [release](https://github.com/Skywt2003/AutoKaTeX/releases)(当然只有一个版本 QwQ),上传到 Typecho 插件目录并解压,重命名文件夹为 `AutoKaTeX`使用。 | ||
|
||
后台启用插件即可。 | ||
|
||
## Note | ||
|
||
本插件不支持编辑器内预览,所以建议配合 [KaTeXForDefaultEditor](https://github.com/ZigZagK/typecho-plugin-KaTeXForDefaultEditor) 使用。 | ||
|
||
顺便 % ZZK。 | ||
|
||
## License | ||
|
||
GPL-3.0 |