PukiWiki改造/字下げ書式
をテンプレートにして作成
[
凌宮
|
初基
|
一覧
|
検索
|
最新
] [
ソース
]
開始行:
TITLE:字下げ書式の導入
%indent
#contents
//-- convert_html L977 L981 L986
/////////////////////////////////////////////////////////...
* 方針 [#fbf6bd7e]
- Wikiは行指向のため、コードの見通しが悪くなりがち。
特にリストでの改行とか、複数行プラグインとか。
- 字下げを導入でコード可読性を改善可能。
/////////////////////////////////////////////////////////...
* 仕様 [#m9bc6a64]
- 字下げ書式モードでは、行頭の空白は無視。
-- ただし、複数行プラグインの引数に対しては、プラグインの...
例:
^ #plugin(){{
^ arg
^ arg
^ }}
は、
^#plugin(){{
^ arg
^ arg
^}}
と等価。
- 疑似プラグイン ##&#;indent## で字下げ書式モードに切り替...
- 疑似プラグイン ##&#;noindent## で天突き書式モードに切り...
- デフォルトは天突き書式。
- 字下げ書式では、行頭が空白の整形済みテキストは無効。
/////////////////////////////////////////////////////////...
* 改造 [#cfaf32ae]
- ##pukiwiki.ini.php## の適当な場所にて、
#code(diff){{
+ $indent_format = 0;
}}
-- ##$indent_format## は天突きと字下げを表すフラグ。
--- ##$indent_format = 0## ⇔ 天突き書式。(デフォルト)
--- ##$indent_format = 1## ⇔ 字下げ書式。
//
- ##lib/convert_html.php## の ##function parse## 入り口直...
#code(diff){{
function parse(& $lines)
{
+ global $indent_format;
$this->last = & $this;
$matches = array();
+ $indent = "";
}}
-- ##$indent = "";## は字下げした深さを格納する変数。複数...
//
- 同ファイルの ##function parse## の ##while (!empty($lin...
#code(diff){{{{
while (! empty($lines)) {
$line = array_shift($lines);
+ // Indent extension
+ if ($indent_format)
+ {
+ preg_match('/^(\s*)(.*)$/', $line, $...
+ $indent = strlen($matches[1]);
+ $line = $matches[2] ;
+ }
+
+ if (rtrim($line) == '#indent') {
+ $indent_format = 1;
+ continue;
+ }
+ if (rtrim($line) == '#noindent') {
+ $indent_format = 0;
+ continue;
+ }
// Escape comments
if (substr($line, 0, 2) == '//') continue;
}}}}
-- ##$line = array_shift($lines);## でラインを切り出す...
-- ##Escape comments##など全てが字下げの影響を受けるため...
-- ##if (rtrim($line) == '#indent') {...}## は字下げ書式...
-- ##if (rtrim($line) == '#noindent') {...}## は天突き書...
//
- 同ループの中ほど、複数行ブロックプラグインにて、
#code(diff){{{{
! // Multiline-enabled Argment-keeping Blo...
if (! PKWKEXP_DISABLE_MULTILINE_PLUGIN_H...
preg_match('/^#[^{]+(\{\{+)\s*$/', $...
+ $delimiter = "\r";
$len = strlen($matches[1]);
- $line .= "\r"; // Delimiter
+ $line .= $delimiter;
while (! empty($lines)) {
$next_line = rtrim(array_shift($...
+ if ($indent_format)
+ {
+ preg_match('/^(\s{'.$indent....
+ $next_line = $matches[2];
+ }
- if (preg_match('/\}{' . $len . '...
- $line .= $next_line;
- break;
- } else {
- $line .= $next_line .= "\r";...
- }
+ if (preg_match('/\s*\}{' . $len ...
+ $line .= ltrim($next_line);
+ break;
+ } else {
+ $line .= $next_line . $delim...
+ }
}
}
}}}}
-- 10〜14行目は字下げ処理。##$indent## が保持しているプラ...
-- 21〜24行目は波引数の終了括弧の処理。##}## の前に空白を...
/////////////////////////////////////////////////////////...
* 課題 [#o0fd377a]
- 「##&#;indent##」と「##&#;noindent##」による文脈の切り...
-- 互換性を捨て、字下げ書式に限定すべきかも。
/////////////////////////////////////////////////////////...
終了行:
TITLE:字下げ書式の導入
%indent
#contents
//-- convert_html L977 L981 L986
/////////////////////////////////////////////////////////...
* 方針 [#fbf6bd7e]
- Wikiは行指向のため、コードの見通しが悪くなりがち。
特にリストでの改行とか、複数行プラグインとか。
- 字下げを導入でコード可読性を改善可能。
/////////////////////////////////////////////////////////...
* 仕様 [#m9bc6a64]
- 字下げ書式モードでは、行頭の空白は無視。
-- ただし、複数行プラグインの引数に対しては、プラグインの...
例:
^ #plugin(){{
^ arg
^ arg
^ }}
は、
^#plugin(){{
^ arg
^ arg
^}}
と等価。
- 疑似プラグイン ##&#;indent## で字下げ書式モードに切り替...
- 疑似プラグイン ##&#;noindent## で天突き書式モードに切り...
- デフォルトは天突き書式。
- 字下げ書式では、行頭が空白の整形済みテキストは無効。
/////////////////////////////////////////////////////////...
* 改造 [#cfaf32ae]
- ##pukiwiki.ini.php## の適当な場所にて、
#code(diff){{
+ $indent_format = 0;
}}
-- ##$indent_format## は天突きと字下げを表すフラグ。
--- ##$indent_format = 0## ⇔ 天突き書式。(デフォルト)
--- ##$indent_format = 1## ⇔ 字下げ書式。
//
- ##lib/convert_html.php## の ##function parse## 入り口直...
#code(diff){{
function parse(& $lines)
{
+ global $indent_format;
$this->last = & $this;
$matches = array();
+ $indent = "";
}}
-- ##$indent = "";## は字下げした深さを格納する変数。複数...
//
- 同ファイルの ##function parse## の ##while (!empty($lin...
#code(diff){{{{
while (! empty($lines)) {
$line = array_shift($lines);
+ // Indent extension
+ if ($indent_format)
+ {
+ preg_match('/^(\s*)(.*)$/', $line, $...
+ $indent = strlen($matches[1]);
+ $line = $matches[2] ;
+ }
+
+ if (rtrim($line) == '#indent') {
+ $indent_format = 1;
+ continue;
+ }
+ if (rtrim($line) == '#noindent') {
+ $indent_format = 0;
+ continue;
+ }
// Escape comments
if (substr($line, 0, 2) == '//') continue;
}}}}
-- ##$line = array_shift($lines);## でラインを切り出す...
-- ##Escape comments##など全てが字下げの影響を受けるため...
-- ##if (rtrim($line) == '#indent') {...}## は字下げ書式...
-- ##if (rtrim($line) == '#noindent') {...}## は天突き書...
//
- 同ループの中ほど、複数行ブロックプラグインにて、
#code(diff){{{{
! // Multiline-enabled Argment-keeping Blo...
if (! PKWKEXP_DISABLE_MULTILINE_PLUGIN_H...
preg_match('/^#[^{]+(\{\{+)\s*$/', $...
+ $delimiter = "\r";
$len = strlen($matches[1]);
- $line .= "\r"; // Delimiter
+ $line .= $delimiter;
while (! empty($lines)) {
$next_line = rtrim(array_shift($...
+ if ($indent_format)
+ {
+ preg_match('/^(\s{'.$indent....
+ $next_line = $matches[2];
+ }
- if (preg_match('/\}{' . $len . '...
- $line .= $next_line;
- break;
- } else {
- $line .= $next_line .= "\r";...
- }
+ if (preg_match('/\s*\}{' . $len ...
+ $line .= ltrim($next_line);
+ break;
+ } else {
+ $line .= $next_line . $delim...
+ }
}
}
}}}}
-- 10〜14行目は字下げ処理。##$indent## が保持しているプラ...
-- 21〜24行目は波引数の終了括弧の処理。##}## の前に空白を...
/////////////////////////////////////////////////////////...
* 課題 [#o0fd377a]
- 「##&#;indent##」と「##&#;noindent##」による文脈の切り...
-- 互換性を捨て、字下げ書式に限定すべきかも。
/////////////////////////////////////////////////////////...
ページ名:
Anatomy_of_the_Human_Ear_ja.svg
363件
[
詳細
]
line.pukiwiki.php
460件
[
詳細
]
line.diff.php
449件
[
詳細
]
inline.tex
438件
[
詳細
]
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件
[
詳細
]
[
凌宮
|
初基
|
一覧
|
検索
|
最新
] [
ソース
]