PukiWiki改造/複数行インラインプラグイン
をテンプレートにして作成
[
凌宮
|
初基
|
一覧
|
検索
|
最新
] [
ソース
]
開始行:
TITLE:複数行インラインプラグイン
#indent
#contents
// convert_html / function & Factory_span L164 L246 L466 ...
// v v v v ...
/////////////////////////////////////////////////////////...
* 方針 [#d6cbd2b4]
- インラインプラグインの引数が長くなると改行が必要になる。
-- 特に TeX を利用している ##eq## とか。
- 複数行ブロックプラグインを真似て同じ構文で複数行インラ...
- 引数展開もブロックプラグインに準じて非展開。
-- 技術上、従来のインラインプラグインのように引数を展開す...
-- TeX などの場合、引数非展開の方が好都合。
/////////////////////////////////////////////////////////...
* 仕様 [#e768ed92]
>##$##'''plugin''' ##(##'''arg''' ##){{&br; ##'''body'''...
<で、
>##&##'''plugin''' ##(##'''arg'''##,##'''body''' ##)##
<と同等の振る舞い。
- 引数の処理は複数行ブロックプラグインに準ずる。
-- '''arg''' と'''body''' は引数非展開。
-- '''body''' の前、各行末は ##"\r" ##を挿入。
/////////////////////////////////////////////////////////...
* 実装 [#c9482637]
- ##lib/convert_html.php## にて、##function & Factory_Div...
-- 「##!##」の行は ##function Factory_Div## からの差分。
--- ##&#;## の正規表現を ##\$## に、##new Div## を ##new ...
-
#code(diff){{{{
!function & Factory_Span(& $root, $text)
{
$matches = array();
// Seems block plugin?
if (PKWKEXP_DISABLE_MULTILINE_PLUGIN_HACK) {
// Usual code
! if (preg_match('/^\$([^\(]+)(?:\((.*)\))?/',...
exist_plugin_convert($matches[1])) {
! return new Inline($matches);
}
} else {
// Hack code
! if(preg_match('/^\$([^\(\{]+)(?:\(([^\r]*)\)...
exist_plugin_inline($matches[1])) {
$len = strlen($matches[3]);
$body = array();
if ($len == 0) {
return new Span($matches); // Seems ...
} else if (preg_match('/\{{' . $len . '}...
$matches[2] .= $body[1];
return new Span($matches); // Seems ...
}
}
}
return new Inline($text);
}
}}}}
//
-
- 同ファイルの ##class Div## をコピーし、##class Span## ...
-- 「##!##」の行は ##class Div## からの差分。
-- 「##+##」の行は ##class Inline## からのコピー。
--- これらは、インラインプラグインで始まる文を、後に段落...
-
#code(diff){{{{
!// $something (started with '$') for Multiline-enabl...
!class Span extends Element
{
var $name;
var $param;
! function Span($out)
{
parent::Element();
list(, $this->name, $this->param) = array_pa...
}
function canContain(& $obj)
{
return FALSE;
}
+ function & insert(& $obj)
+ {
+ $this->elements[] = $obj->elements[0];
+ return $this;
+ }
function toString()
{
// Call $plugin
! return do_plugin_inline($this->name, $this->...
}
+ function & toPara($class = '')
+ {
+ $obj = & new Paragraph('', $class);
+ $obj->insert($this);
+ return $obj;
+ }
}
}}}}
//
- 同ファイル、##class Body##の##var $factories##に対し、
-
#code(diff){{{{
var $factories = array(
':' => 'DList',
'|' => 'Table',
',' => 'YTable',
- '#' => 'Div');
+ '#' => 'Div',
+ '$' => 'Span');
}}}}
//
- 同クラス ##class Body## の ##function parse##の複数行ブ...
-- 「##!##」はコピー元に対する変更。
-- 丸引数の有無をチェックし、波引数との間の「##,##」の有...
-
#code(diff){{{{
! // Multiline-enabled Argment-keeping Inl...
if (! PKWKEXP_DISABLE_MULTILINE_PLUGIN_H...
! preg_match('/^\$[^({]*(\((.*)\))?(\{...
$delimiter = "\r";
! $len = strlen($matches[3]);
! $line .= ($matches[2] == '') ? $deli...
while (! empty($lines)) {
$next_line = rtrim(array_shift($...
if ($indent_format)
{
preg_match('/^(\s{'.$indent....
$next_line = $matches[2];
}
if (preg_match('/\s*\}{' . $len ...
$line .= ltrim($next_line);
break;
} else {
$line .= $next_line . $delim...
}
}
}
}}}}
//
- 複数行インラインプラグインをインライン要素と同じ振る舞...
同ファイル中の「##is_a($obj, 'Inline')##」を「##is_a($o...
-- ただし、##class Inline## の ##function canContain## だ...
-- 同ファイル、##class Paragraph## と ##class Align## の...
--
#code(diff){{{{
function canContain($obj)
{
- return is_a($obj, 'Inline');
+ return is_a($obj, 'Inline') || is_a($obj, 'S...
}
}}}}
//
-- 同クラス ##class Body## の ##function & insert##にて、
--
#code(diff){{{{
function & insert(& $obj)
{
- if (is_a($obj, 'Inline')) $obj = & $obj->toPa...
+ if (is_a($obj, 'Inline') || is_a($obj, 'Span'...
return parent::insert($obj);
}
}}}}
//
-- 同ファイル、##class BQuote## の ##function & insert## ...
--
#code(diff){{{{
function & insert(& $obj)
{
// BugTrack/521, BugTrack/545
- if (is_a($obj, 'inline'))
+ if (is_a($obj, 'inline') || is_a($obj, 'Span'))
return parent::insert($obj->toPara(' clas...
}}}}
/////////////////////////////////////////////////////////...
* 課題 [#jf808bb1]
- プラグインの書式
-- 第1案:先頭1字で書式決定
--- 既存の「##&#;##」と「##&&;##」の間を日本語キーボード...
--
|* |*引数非展開 |< ...
|^ |*ブロック |*インライン ...
|*単一行|###〜(〜){〜}; ## |##$〜(〜){〜}; ## ...
|*複数行|###〜(〜){{&br;〜&br;}}##|##$〜(〜){{&br;〜&...
//
-- 第2案:先頭1字でブロック/インラインを決定、第2字で...
--- 既存の「##&#;##」と「##&&;##」のみで解決。
--- 「##&#;##」と「##&&;##」はそれぞれ「##&#;&#;##」と「#...
--
|* |*ブロック |< ...
|^ |*引数非展開 |*引数展開 ...
|*単一行|##&#;#〜(〜){〜};## |###&〜(〜){〜};...
|*複数行|##&#;#〜(〜){{&br;〜&br;}}##|###&〜(〜){{&br...
/////////////////////////////////////////////////////////...
終了行:
TITLE:複数行インラインプラグイン
#indent
#contents
// convert_html / function & Factory_span L164 L246 L466 ...
// v v v v ...
/////////////////////////////////////////////////////////...
* 方針 [#d6cbd2b4]
- インラインプラグインの引数が長くなると改行が必要になる。
-- 特に TeX を利用している ##eq## とか。
- 複数行ブロックプラグインを真似て同じ構文で複数行インラ...
- 引数展開もブロックプラグインに準じて非展開。
-- 技術上、従来のインラインプラグインのように引数を展開す...
-- TeX などの場合、引数非展開の方が好都合。
/////////////////////////////////////////////////////////...
* 仕様 [#e768ed92]
>##$##'''plugin''' ##(##'''arg''' ##){{&br; ##'''body'''...
<で、
>##&##'''plugin''' ##(##'''arg'''##,##'''body''' ##)##
<と同等の振る舞い。
- 引数の処理は複数行ブロックプラグインに準ずる。
-- '''arg''' と'''body''' は引数非展開。
-- '''body''' の前、各行末は ##"\r" ##を挿入。
/////////////////////////////////////////////////////////...
* 実装 [#c9482637]
- ##lib/convert_html.php## にて、##function & Factory_Div...
-- 「##!##」の行は ##function Factory_Div## からの差分。
--- ##&#;## の正規表現を ##\$## に、##new Div## を ##new ...
-
#code(diff){{{{
!function & Factory_Span(& $root, $text)
{
$matches = array();
// Seems block plugin?
if (PKWKEXP_DISABLE_MULTILINE_PLUGIN_HACK) {
// Usual code
! if (preg_match('/^\$([^\(]+)(?:\((.*)\))?/',...
exist_plugin_convert($matches[1])) {
! return new Inline($matches);
}
} else {
// Hack code
! if(preg_match('/^\$([^\(\{]+)(?:\(([^\r]*)\)...
exist_plugin_inline($matches[1])) {
$len = strlen($matches[3]);
$body = array();
if ($len == 0) {
return new Span($matches); // Seems ...
} else if (preg_match('/\{{' . $len . '}...
$matches[2] .= $body[1];
return new Span($matches); // Seems ...
}
}
}
return new Inline($text);
}
}}}}
//
-
- 同ファイルの ##class Div## をコピーし、##class Span## ...
-- 「##!##」の行は ##class Div## からの差分。
-- 「##+##」の行は ##class Inline## からのコピー。
--- これらは、インラインプラグインで始まる文を、後に段落...
-
#code(diff){{{{
!// $something (started with '$') for Multiline-enabl...
!class Span extends Element
{
var $name;
var $param;
! function Span($out)
{
parent::Element();
list(, $this->name, $this->param) = array_pa...
}
function canContain(& $obj)
{
return FALSE;
}
+ function & insert(& $obj)
+ {
+ $this->elements[] = $obj->elements[0];
+ return $this;
+ }
function toString()
{
// Call $plugin
! return do_plugin_inline($this->name, $this->...
}
+ function & toPara($class = '')
+ {
+ $obj = & new Paragraph('', $class);
+ $obj->insert($this);
+ return $obj;
+ }
}
}}}}
//
- 同ファイル、##class Body##の##var $factories##に対し、
-
#code(diff){{{{
var $factories = array(
':' => 'DList',
'|' => 'Table',
',' => 'YTable',
- '#' => 'Div');
+ '#' => 'Div',
+ '$' => 'Span');
}}}}
//
- 同クラス ##class Body## の ##function parse##の複数行ブ...
-- 「##!##」はコピー元に対する変更。
-- 丸引数の有無をチェックし、波引数との間の「##,##」の有...
-
#code(diff){{{{
! // Multiline-enabled Argment-keeping Inl...
if (! PKWKEXP_DISABLE_MULTILINE_PLUGIN_H...
! preg_match('/^\$[^({]*(\((.*)\))?(\{...
$delimiter = "\r";
! $len = strlen($matches[3]);
! $line .= ($matches[2] == '') ? $deli...
while (! empty($lines)) {
$next_line = rtrim(array_shift($...
if ($indent_format)
{
preg_match('/^(\s{'.$indent....
$next_line = $matches[2];
}
if (preg_match('/\s*\}{' . $len ...
$line .= ltrim($next_line);
break;
} else {
$line .= $next_line . $delim...
}
}
}
}}}}
//
- 複数行インラインプラグインをインライン要素と同じ振る舞...
同ファイル中の「##is_a($obj, 'Inline')##」を「##is_a($o...
-- ただし、##class Inline## の ##function canContain## だ...
-- 同ファイル、##class Paragraph## と ##class Align## の...
--
#code(diff){{{{
function canContain($obj)
{
- return is_a($obj, 'Inline');
+ return is_a($obj, 'Inline') || is_a($obj, 'S...
}
}}}}
//
-- 同クラス ##class Body## の ##function & insert##にて、
--
#code(diff){{{{
function & insert(& $obj)
{
- if (is_a($obj, 'Inline')) $obj = & $obj->toPa...
+ if (is_a($obj, 'Inline') || is_a($obj, 'Span'...
return parent::insert($obj);
}
}}}}
//
-- 同ファイル、##class BQuote## の ##function & insert## ...
--
#code(diff){{{{
function & insert(& $obj)
{
// BugTrack/521, BugTrack/545
- if (is_a($obj, 'inline'))
+ if (is_a($obj, 'inline') || is_a($obj, 'Span'))
return parent::insert($obj->toPara(' clas...
}}}}
/////////////////////////////////////////////////////////...
* 課題 [#jf808bb1]
- プラグインの書式
-- 第1案:先頭1字で書式決定
--- 既存の「##&#;##」と「##&&;##」の間を日本語キーボード...
--
|* |*引数非展開 |< ...
|^ |*ブロック |*インライン ...
|*単一行|###〜(〜){〜}; ## |##$〜(〜){〜}; ## ...
|*複数行|###〜(〜){{&br;〜&br;}}##|##$〜(〜){{&br;〜&...
//
-- 第2案:先頭1字でブロック/インラインを決定、第2字で...
--- 既存の「##&#;##」と「##&&;##」のみで解決。
--- 「##&#;##」と「##&&;##」はそれぞれ「##&#;&#;##」と「#...
--
|* |*ブロック |< ...
|^ |*引数非展開 |*引数展開 ...
|*単一行|##&#;#〜(〜){〜};## |###&〜(〜){〜};...
|*複数行|##&#;#〜(〜){{&br;〜&br;}}##|###&〜(〜){{&br...
/////////////////////////////////////////////////////////...
ページ名:
Anatomy_of_the_Human_Ear_ja.svg
358件
[
詳細
]
line.pukiwiki.php
458件
[
詳細
]
line.diff.php
445件
[
詳細
]
inline.tex
433件
[
詳細
]
convert_html.php
469件
[
詳細
]
eq.inc.php
503件
[
詳細
]
convert.tex
419件
[
詳細
]
codehighlight.php
437件
[
詳細
]
code.inc.php
472件
[
詳細
]
ToHeader.png
230件
[
詳細
]
ToFooter_0.png
200件
[
詳細
]
ToFooter.png
236件
[
詳細
]
ParaEdit.png
242件
[
詳細
]
TexEqMiddleAlign.png
479件
[
詳細
]
[
凌宮
|
初基
|
一覧
|
検索
|
最新
] [
ソース
]