「Mediawiki 開發擴展」修訂間的差異
跳至導覽
跳至搜尋
| 第14行: | 第14行: | ||
修改代碼使 math 也能過濾到使用 mimetex 見:[http://wiki.klniu.com/zh-hant/MediaWiki/利用外链CGI添加数学公式支持 利用外鏈CGI為Mediawiki添加數學公式支援] | 修改代碼使 math 也能過濾到使用 mimetex 見:[http://wiki.klniu.com/zh-hant/MediaWiki/利用外链CGI添加数学公式支持 利用外鏈CGI為Mediawiki添加數學公式支援] | ||
| + | |||
| + | 第二種方法是修改 includes/Math.php 下的 renderMath 方法: | ||
| + | <pre> #public static function renderMath( $tex, $params=array() ) { | ||
| + | # global $wgUser; | ||
| + | # $math = new MathRenderer( $tex, $params ); | ||
| + | # $math->setOutputMode( $wgUser->getOption('math')); | ||
| + | # return $math->render(); | ||
| + | #} | ||
| + | public static function renderMath( $tex, $params=array() ) { | ||
| + | return '<img class="tex" src="http://www.forkosh.dreamhost.com/mathtex.cgi?' . rawurlencode($tex) . '" alt="LaTeX: ' . htmlspecialchars($tex) . '">'; | ||
| + | }</pre> | ||
於 2015年9月26日 (六) 15:12 的修訂
視覺化編輯器(visual editer)
- 需要 Parsoid
- 設 $wgVisualEditorParsoidPrefix = 'localhost';
- 設 $wgVisualEditorParsoidURL = 'http://localhost:8000'; // Debian,port是8142
- 設 $wgDefaultUserOptions['visualeditor-enable'] = 1;
- $wgHiddenPrefs[] = 'visualeditor-enable'; // 不許關閉,若要用 wiki 碼編,不用此行
- 設 require_once "$IP/extensions/VisualEditor/VisualEditor.php";
- MediaWiki 1.23,還需要額外的 PHP Parsoid 插件,之後的版本不用。
使用 Mimetex
這種方法實質上是利用外部的 cgi 鏈接來幫我們生成公式圖片,比較靈活,我們可以使用自定義的標籤或者修改代碼來實現。
自定義標籤方法見:Extension:Mimetex alternative
修改代碼使 math 也能過濾到使用 mimetex 見:利用外鏈CGI為Mediawiki添加數學公式支援
第二種方法是修改 includes/Math.php 下的 renderMath 方法:
#public static function renderMath( $tex, $params=array() ) {
# global $wgUser;
# $math = new MathRenderer( $tex, $params );
# $math->setOutputMode( $wgUser->getOption('math'));
# return $math->render();
#}
public static function renderMath( $tex, $params=array() ) {
return '<img class="tex" src="http://www.forkosh.dreamhost.com/mathtex.cgi?' . rawurlencode($tex) . '" alt="LaTeX: ' . htmlspecialchars($tex) . '">';
}