Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Skywt2003 committed Nov 15, 2019
0 parents commit bad01ce
Show file tree
Hide file tree
Showing 66 changed files with 821 additions and 0 deletions.
1 change: 1 addition & 0 deletions KaTeX/auto-render.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added KaTeX/fonts/KaTeX_AMS-Regular.ttf
Binary file not shown.
Binary file added KaTeX/fonts/KaTeX_AMS-Regular.woff
Binary file not shown.
Binary file added KaTeX/fonts/KaTeX_AMS-Regular.woff2
Binary file not shown.
Binary file added KaTeX/fonts/KaTeX_Caligraphic-Bold.ttf
Binary file not shown.
Binary file added KaTeX/fonts/KaTeX_Caligraphic-Bold.woff
Binary file not shown.
Binary file added KaTeX/fonts/KaTeX_Caligraphic-Bold.woff2
Binary file not shown.
Binary file added KaTeX/fonts/KaTeX_Caligraphic-Regular.ttf
Binary file not shown.
Binary file added KaTeX/fonts/KaTeX_Caligraphic-Regular.woff
Binary file not shown.
Binary file added KaTeX/fonts/KaTeX_Caligraphic-Regular.woff2
Binary file not shown.
Binary file added KaTeX/fonts/KaTeX_Fraktur-Bold.ttf
Binary file not shown.
Binary file added KaTeX/fonts/KaTeX_Fraktur-Bold.woff
Binary file not shown.
Binary file added KaTeX/fonts/KaTeX_Fraktur-Bold.woff2
Binary file not shown.
Binary file added KaTeX/fonts/KaTeX_Fraktur-Regular.ttf
Binary file not shown.
Binary file added KaTeX/fonts/KaTeX_Fraktur-Regular.woff
Binary file not shown.
Binary file added KaTeX/fonts/KaTeX_Fraktur-Regular.woff2
Binary file not shown.
Binary file added KaTeX/fonts/KaTeX_Main-Bold.ttf
Binary file not shown.
Binary file added KaTeX/fonts/KaTeX_Main-Bold.woff
Binary file not shown.
Binary file added KaTeX/fonts/KaTeX_Main-Bold.woff2
Binary file not shown.
Binary file added KaTeX/fonts/KaTeX_Main-BoldItalic.ttf
Binary file not shown.
Binary file added KaTeX/fonts/KaTeX_Main-BoldItalic.woff
Binary file not shown.
Binary file added KaTeX/fonts/KaTeX_Main-BoldItalic.woff2
Binary file not shown.
Binary file added KaTeX/fonts/KaTeX_Main-Italic.ttf
Binary file not shown.
Binary file added KaTeX/fonts/KaTeX_Main-Italic.woff
Binary file not shown.
Binary file added KaTeX/fonts/KaTeX_Main-Italic.woff2
Binary file not shown.
Binary file added KaTeX/fonts/KaTeX_Main-Regular.ttf
Binary file not shown.
Binary file added KaTeX/fonts/KaTeX_Main-Regular.woff
Binary file not shown.
Binary file added KaTeX/fonts/KaTeX_Main-Regular.woff2
Binary file not shown.
Binary file added KaTeX/fonts/KaTeX_Math-BoldItalic.ttf
Binary file not shown.
Binary file added KaTeX/fonts/KaTeX_Math-BoldItalic.woff
Binary file not shown.
Binary file added KaTeX/fonts/KaTeX_Math-BoldItalic.woff2
Binary file not shown.
Binary file added KaTeX/fonts/KaTeX_Math-Italic.ttf
Binary file not shown.
Binary file added KaTeX/fonts/KaTeX_Math-Italic.woff
Binary file not shown.
Binary file added KaTeX/fonts/KaTeX_Math-Italic.woff2
Binary file not shown.
Binary file added KaTeX/fonts/KaTeX_SansSerif-Bold.ttf
Binary file not shown.
Binary file added KaTeX/fonts/KaTeX_SansSerif-Bold.woff
Binary file not shown.
Binary file added KaTeX/fonts/KaTeX_SansSerif-Bold.woff2
Binary file not shown.
Binary file added KaTeX/fonts/KaTeX_SansSerif-Italic.ttf
Binary file not shown.
Binary file added KaTeX/fonts/KaTeX_SansSerif-Italic.woff
Binary file not shown.
Binary file added KaTeX/fonts/KaTeX_SansSerif-Italic.woff2
Binary file not shown.
Binary file added KaTeX/fonts/KaTeX_SansSerif-Regular.ttf
Binary file not shown.
Binary file added KaTeX/fonts/KaTeX_SansSerif-Regular.woff
Binary file not shown.
Binary file added KaTeX/fonts/KaTeX_SansSerif-Regular.woff2
Binary file not shown.
Binary file added KaTeX/fonts/KaTeX_Script-Regular.ttf
Binary file not shown.
Binary file added KaTeX/fonts/KaTeX_Script-Regular.woff
Binary file not shown.
Binary file added KaTeX/fonts/KaTeX_Script-Regular.woff2
Binary file not shown.
Binary file added KaTeX/fonts/KaTeX_Size1-Regular.ttf
Binary file not shown.
Binary file added KaTeX/fonts/KaTeX_Size1-Regular.woff
Binary file not shown.
Binary file added KaTeX/fonts/KaTeX_Size1-Regular.woff2
Binary file not shown.
Binary file added KaTeX/fonts/KaTeX_Size2-Regular.ttf
Binary file not shown.
Binary file added KaTeX/fonts/KaTeX_Size2-Regular.woff
Binary file not shown.
Binary file added KaTeX/fonts/KaTeX_Size2-Regular.woff2
Binary file not shown.
Binary file added KaTeX/fonts/KaTeX_Size3-Regular.ttf
Binary file not shown.
Binary file added KaTeX/fonts/KaTeX_Size3-Regular.woff
Binary file not shown.
Binary file added KaTeX/fonts/KaTeX_Size3-Regular.woff2
Binary file not shown.
Binary file added KaTeX/fonts/KaTeX_Size4-Regular.ttf
Binary file not shown.
Binary file added KaTeX/fonts/KaTeX_Size4-Regular.woff
Binary file not shown.
Binary file added KaTeX/fonts/KaTeX_Size4-Regular.woff2
Binary file not shown.
Binary file added KaTeX/fonts/KaTeX_Typewriter-Regular.ttf
Binary file not shown.
Binary file added KaTeX/fonts/KaTeX_Typewriter-Regular.woff
Binary file not shown.
Binary file added KaTeX/fonts/KaTeX_Typewriter-Regular.woff2
Binary file not shown.
1 change: 1 addition & 0 deletions KaTeX/katex.min.css

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions KaTeX/katex.min.js

Large diffs are not rendered by default.

674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

116 changes: 116 additions & 0 deletions Plugin.php
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;
}
}
28 changes: 28 additions & 0 deletions README.md
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

0 comments on commit bad01ce

Please sign in to comment.