PukiWiki改造/ネイティブエイリアス
をテンプレートにして作成
[
凌宮
|
初基
|
一覧
|
検索
|
最新
] [
ソース
]
開始行:
TITLE:ネイティブエイリアス
#indent
#contents
/////////////////////////////////////////////////////////...
*方針 [#h52cece1]
「##&';&';〜&';&';##」や「##&';&';&';〜&';&';&';##」のよ...
ネコヰキではこれをネイティブ書式と呼ぶ。
一方、PukiWikiでは「##&&;〜;##」や「##&#;〜;##」などのプ...
プラグイン書式の弱点は、開始記号と終了記号が「##&';&';〜&...
このため、良く使うプラグインはネイティブ書式にしたい。
ここで、プラグインのエイリアスとしてネイティブ書式を扱う...
ネコヰキの性質上、当面は数式とコードの2つのプラグインの...
書式は、2文字と3文字でインラインプラグインとブロックプラ...
引数の展開/保持は対応するプラグイン書式に準ずる。
* 仕様 [#q38acc3a]
書式文字を「##@##」、対応するプラグイン名を「##plugin##」...
:単一行インラインプラグイン|「##@@〜@@##」は「##&plugin(...
機能的違いは引数の展開/保持。どっちになるかはプラグイン...
:複数行インラインプラグイン|
^@@ …
^〜
^@@
は
^$plugin(…){{{{{{{{{{{{{{{{
^〜
^}}}}}}}}}}}}}}}};
と等価である。
:複数行ブロックプラグイン|
^@@@ …
^〜
^@@@
は
^#plugin(…){{{{{{{{{{{{{{{{
^〜
^}}}}}}}}}}}}}}}}
と等価である。
数式プラグインの場合、書式文字は「##$##」、プラグイン名は...
書式文字は TeX のインライン数式モード「##$〜$##」に由来。
用例は[[書式/数式]]を参照。
コードプラグインの場合、書式文字は「##&#;##」、プラグイン...
書式文字は、「#####」の形が等幅表示のための桝目からの連想。
また、C言語で、別言語であるプリプロセッサのコードを埋め込...
用例は[[書式/コード]]を参照。
* 実装 [#g668057c]
** 単一行インラインプラグイン [#y4dab69e]
- ##lib/make_link.php## の ##class InlineConverter## の #...
#code(diff){{{{
function InlineConverter($converters = NULL, $ex...
{
if ($converters === NULL) {
$converters = array(
'plugin', // Inline plugins
+ 'eq', // eq plugin
+ 'code', // code plugin
'escape', // Escapes
'note', // Footnotes
……
}}}}
- ##lib/make_link.php## の ##class Link_plugin## の後に以...
#code(php){{{{
// Native-alias Plugin
class Link_plugin_alias extends Link_plugin
{
var $name = 'echo'; // プラグイン名
var $pattern = ''; // 正規表現 Link_plug...
// $matches[1] = pla...
// $matches[2] = plu...
// $matches[3] = par...
// $matches[4] = bod...
function Link_eq($start)
{
parent::Link_plugin($start);
}
function get_pattern()
{
return $this->pattern;
}
function get_count()
{
return 4;
}
function set($arr, $page)
{
list(, $this->plain, , $this->param, $bod...
return parent::setParam($page, $this->nam...
}
}
// Native-alias for &eq plugin
class Link_eq extends Link_plugin_alias
{
var $name = 'eq';
var $pattern = '\$\$(()(.+?)())\$\$'; // no...
}
// Native-alias for &code plugin
class Link_code extends Link_plugin_alias
{
var $name = 'code';
var $pattern = '\#\#(()()(.+?))\#\#'; // no...
}
}}}}
-- Link_plugin_alias は基底クラス。直接生成されることはな...
-- ##eq## は引数保持、##code## は引数展開。
** 複数行インラインプラグイン [#ueecdb8a]
- ##lib/convert_html.php## の ##class Body## の ##functio...
#code(php){{{{{{{{{{{{{{{{{{{{
// Native-alias for $eq-Plugin
$pattern = '/^\s*\$\$\s*$/';
if (preg_match($pattern, $line)) {
$delimiter = "\r";
$line = '&eq{{{{{{{{{{{{{{{{'.$delimiter;
while (! empty($lines)) {
$next_line = rtrim(array_shift($lines...
if ($indent_format)
{
preg_match('/^(\s{'.$indent.'}?)?...
$next_line = $matches[2];
}
if (preg_match($pattern, $next_line)) {
$line .= ltrim('}}}}}}}}}}}}}}}};...
break;
} else {
$line .= $next_line . $delimiter;
}
}
}
}}}}}}}}}}}}}}}}}}}}
#code(diff){{{{{{{{{{{{{{{{{{{{
! // Native-alias for $code-Plugin
! $pattern = '/^\s*##\s*$/';
if (preg_match($pattern, $line)) {
$delimiter = "\r";
! $line = '$code{{{{{{{{{{{{{{{{'.$delimit...
while (! empty($lines)) {
$next_line = rtrim(array_shift($line...
if ($indent_format)
{
preg_match('/^(\s{'.$indent.'}?)...
$next_line = $matches[2];
}
if (preg_match($pattern, $next_line)...
$line .= ltrim('}}}}}}}}}}}}}}}}...
break;
} else {
$line .= $next_line . $delimiter;
}
}
}
}}}}}}}}}}}}}}}}}}}}
-- 「##!##」に行は、##eq##プラグイン に対する ##code## プ...
** 複数行ブロックプラグイン [#v78fcaaf]
- ##lib/convert_html.php## の ##class Body## の ##functio...
#code(diff){{{{{{{{{{{{{{{{{{{{
! // Native-alias for #eq-Plugin
! $pattern = '/^\s*\$\$\$\s*$/';
if (preg_match($pattern, $line)) {
$delimiter = "\r";
! $line = '#eq{{{{{{{{{{{{{{{{'.$delim...
while (! empty($lines)) {
$next_line = rtrim(array_shift($...
if ($indent_format)
{
preg_match('/^(\s{'.$indent....
$next_line = $matches[2];
}
if (preg_match($pattern, $next_l...
$line .= ltrim('}}}}}}}}}}}}...
break;
} else {
$line .= $next_line . $delim...
}
}
}
}}}}}}}}}}}}}}}}}}}}
#code(diff){{{{{{{{{{{{{{{{{{{{
! // Native-alias for #code-Plugin
! $pattern = '/^\s*###\s*(\w*)\s*$/';
! if (preg_match($pattern, $line, $matches...
$delimiter = "\r";
! $line = '#code('.$matches[1].'){{{{{...
while (! empty($lines)) {
$next_line = rtrim(array_shift($...
if ($indent_format)
{
preg_match('/^(\s{'.$indent....
$next_line = $matches[2];
}
if (preg_match($pattern, $next_l...
$line .= ltrim('}}}}}}}}}}}}...
break;
} else {
$line .= $next_line . $delim...
}
}
}
}}}}}}}}}}}}}}}}}}}}
-- 「##!##」に行は、それぞれの複数行インラインプラグイン...
/////////////////////////////////////////////////////////...
終了行:
TITLE:ネイティブエイリアス
#indent
#contents
/////////////////////////////////////////////////////////...
*方針 [#h52cece1]
「##&';&';〜&';&';##」や「##&';&';&';〜&';&';&';##」のよ...
ネコヰキではこれをネイティブ書式と呼ぶ。
一方、PukiWikiでは「##&&;〜;##」や「##&#;〜;##」などのプ...
プラグイン書式の弱点は、開始記号と終了記号が「##&';&';〜&...
このため、良く使うプラグインはネイティブ書式にしたい。
ここで、プラグインのエイリアスとしてネイティブ書式を扱う...
ネコヰキの性質上、当面は数式とコードの2つのプラグインの...
書式は、2文字と3文字でインラインプラグインとブロックプラ...
引数の展開/保持は対応するプラグイン書式に準ずる。
* 仕様 [#q38acc3a]
書式文字を「##@##」、対応するプラグイン名を「##plugin##」...
:単一行インラインプラグイン|「##@@〜@@##」は「##&plugin(...
機能的違いは引数の展開/保持。どっちになるかはプラグイン...
:複数行インラインプラグイン|
^@@ …
^〜
^@@
は
^$plugin(…){{{{{{{{{{{{{{{{
^〜
^}}}}}}}}}}}}}}}};
と等価である。
:複数行ブロックプラグイン|
^@@@ …
^〜
^@@@
は
^#plugin(…){{{{{{{{{{{{{{{{
^〜
^}}}}}}}}}}}}}}}}
と等価である。
数式プラグインの場合、書式文字は「##$##」、プラグイン名は...
書式文字は TeX のインライン数式モード「##$〜$##」に由来。
用例は[[書式/数式]]を参照。
コードプラグインの場合、書式文字は「##&#;##」、プラグイン...
書式文字は、「#####」の形が等幅表示のための桝目からの連想。
また、C言語で、別言語であるプリプロセッサのコードを埋め込...
用例は[[書式/コード]]を参照。
* 実装 [#g668057c]
** 単一行インラインプラグイン [#y4dab69e]
- ##lib/make_link.php## の ##class InlineConverter## の #...
#code(diff){{{{
function InlineConverter($converters = NULL, $ex...
{
if ($converters === NULL) {
$converters = array(
'plugin', // Inline plugins
+ 'eq', // eq plugin
+ 'code', // code plugin
'escape', // Escapes
'note', // Footnotes
……
}}}}
- ##lib/make_link.php## の ##class Link_plugin## の後に以...
#code(php){{{{
// Native-alias Plugin
class Link_plugin_alias extends Link_plugin
{
var $name = 'echo'; // プラグイン名
var $pattern = ''; // 正規表現 Link_plug...
// $matches[1] = pla...
// $matches[2] = plu...
// $matches[3] = par...
// $matches[4] = bod...
function Link_eq($start)
{
parent::Link_plugin($start);
}
function get_pattern()
{
return $this->pattern;
}
function get_count()
{
return 4;
}
function set($arr, $page)
{
list(, $this->plain, , $this->param, $bod...
return parent::setParam($page, $this->nam...
}
}
// Native-alias for &eq plugin
class Link_eq extends Link_plugin_alias
{
var $name = 'eq';
var $pattern = '\$\$(()(.+?)())\$\$'; // no...
}
// Native-alias for &code plugin
class Link_code extends Link_plugin_alias
{
var $name = 'code';
var $pattern = '\#\#(()()(.+?))\#\#'; // no...
}
}}}}
-- Link_plugin_alias は基底クラス。直接生成されることはな...
-- ##eq## は引数保持、##code## は引数展開。
** 複数行インラインプラグイン [#ueecdb8a]
- ##lib/convert_html.php## の ##class Body## の ##functio...
#code(php){{{{{{{{{{{{{{{{{{{{
// Native-alias for $eq-Plugin
$pattern = '/^\s*\$\$\s*$/';
if (preg_match($pattern, $line)) {
$delimiter = "\r";
$line = '&eq{{{{{{{{{{{{{{{{'.$delimiter;
while (! empty($lines)) {
$next_line = rtrim(array_shift($lines...
if ($indent_format)
{
preg_match('/^(\s{'.$indent.'}?)?...
$next_line = $matches[2];
}
if (preg_match($pattern, $next_line)) {
$line .= ltrim('}}}}}}}}}}}}}}}};...
break;
} else {
$line .= $next_line . $delimiter;
}
}
}
}}}}}}}}}}}}}}}}}}}}
#code(diff){{{{{{{{{{{{{{{{{{{{
! // Native-alias for $code-Plugin
! $pattern = '/^\s*##\s*$/';
if (preg_match($pattern, $line)) {
$delimiter = "\r";
! $line = '$code{{{{{{{{{{{{{{{{'.$delimit...
while (! empty($lines)) {
$next_line = rtrim(array_shift($line...
if ($indent_format)
{
preg_match('/^(\s{'.$indent.'}?)...
$next_line = $matches[2];
}
if (preg_match($pattern, $next_line)...
$line .= ltrim('}}}}}}}}}}}}}}}}...
break;
} else {
$line .= $next_line . $delimiter;
}
}
}
}}}}}}}}}}}}}}}}}}}}
-- 「##!##」に行は、##eq##プラグイン に対する ##code## プ...
** 複数行ブロックプラグイン [#v78fcaaf]
- ##lib/convert_html.php## の ##class Body## の ##functio...
#code(diff){{{{{{{{{{{{{{{{{{{{
! // Native-alias for #eq-Plugin
! $pattern = '/^\s*\$\$\$\s*$/';
if (preg_match($pattern, $line)) {
$delimiter = "\r";
! $line = '#eq{{{{{{{{{{{{{{{{'.$delim...
while (! empty($lines)) {
$next_line = rtrim(array_shift($...
if ($indent_format)
{
preg_match('/^(\s{'.$indent....
$next_line = $matches[2];
}
if (preg_match($pattern, $next_l...
$line .= ltrim('}}}}}}}}}}}}...
break;
} else {
$line .= $next_line . $delim...
}
}
}
}}}}}}}}}}}}}}}}}}}}
#code(diff){{{{{{{{{{{{{{{{{{{{
! // Native-alias for #code-Plugin
! $pattern = '/^\s*###\s*(\w*)\s*$/';
! if (preg_match($pattern, $line, $matches...
$delimiter = "\r";
! $line = '#code('.$matches[1].'){{{{{...
while (! empty($lines)) {
$next_line = rtrim(array_shift($...
if ($indent_format)
{
preg_match('/^(\s{'.$indent....
$next_line = $matches[2];
}
if (preg_match($pattern, $next_l...
$line .= ltrim('}}}}}}}}}}}}...
break;
} else {
$line .= $next_line . $delim...
}
}
}
}}}}}}}}}}}}}}}}}}}}
-- 「##!##」に行は、それぞれの複数行インラインプラグイン...
/////////////////////////////////////////////////////////...
ページ名:
Anatomy_of_the_Human_Ear_ja.svg
363件
[
詳細
]
line.pukiwiki.php
459件
[
詳細
]
line.diff.php
448件
[
詳細
]
inline.tex
437件
[
詳細
]
convert_html.php
470件
[
詳細
]
eq.inc.php
506件
[
詳細
]
convert.tex
422件
[
詳細
]
codehighlight.php
438件
[
詳細
]
code.inc.php
474件
[
詳細
]
ToHeader.png
234件
[
詳細
]
ToFooter_0.png
202件
[
詳細
]
ToFooter.png
239件
[
詳細
]
ParaEdit.png
245件
[
詳細
]
TexEqMiddleAlign.png
484件
[
詳細
]
[
凌宮
|
初基
|
一覧
|
検索
|
最新
] [
ソース
]