「Mediawiki 開發擴展」修訂間的差異
跳至導覽
跳至搜尋
| 第8行: | 第8行: | ||
*設 require_once "$IP/extensions/VisualEditor/VisualEditor.php"; | *設 require_once "$IP/extensions/VisualEditor/VisualEditor.php"; | ||
* MediaWiki 1.23,還需要額外的 PHP Parsoid 插件,之後的版本不用。 | * MediaWiki 1.23,還需要額外的 PHP Parsoid 插件,之後的版本不用。 | ||
| − | === | + | ===texvc=== |
| + | *準備工作須先裝好以下軟件: | ||
| + | *#ocaml | ||
| + | *#imagemagick | ||
| + | *#gs | ||
| + | *#cjk-latex (now called latex-cjk-all) | ||
| + | *#tetex-extra | ||
| + | *#binutils (“/usr/bin/as” is needed by make job) | ||
| + | *#gcc | ||
| + | *cd 到 MediaWiki 安裝目錄下的 math/ 子目錄,執行 make 開始安裝 texvc。 | ||
| + | *在 LocalSettings.php 中設置 $wgUseTeX = true; | ||
| + | *生成圖片需要創建目錄和檔案,若伺服器權限不允許,會出現錯誤。 | ||
| + | ===使用外部的 Mimetex=== | ||
這種方法實質上是利用外部的 cgi 鏈接來幫我們生成公式圖片,比較靈活,我們可以使用自定義的標籤或者修改代碼來實現。 | 這種方法實質上是利用外部的 cgi 鏈接來幫我們生成公式圖片,比較靈活,我們可以使用自定義的標籤或者修改代碼來實現。 | ||
於 2015年9月26日 (六) 20:20 的修訂
視覺化編輯器(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 插件,之後的版本不用。
texvc
- 準備工作須先裝好以下軟件:
- ocaml
- imagemagick
- gs
- cjk-latex (now called latex-cjk-all)
- tetex-extra
- binutils (“/usr/bin/as” is needed by make job)
- gcc
- cd 到 MediaWiki 安裝目錄下的 math/ 子目錄,執行 make 開始安裝 texvc。
- 在 LocalSettings.php 中設置 $wgUseTeX = true;
- 生成圖片需要創建目錄和檔案,若伺服器權限不允許,會出現錯誤。
使用外部的 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();
return "<img class='tex' src='http://www.forkosh.dreamhost.com/mathtex.cgi?".rawurlencode($tex)."' alt='LaTeX:".htmlspecialchars($tex)."'>";
}