[[PukiWiki/1.4/ちょっと便利に]] * 行頭<pre>~行頭</pre>間を整形済みとする [#vad944fd] <pre> 整形済み A quick red fox jumped over the lazy brown dogs. </pre> #ref(block_pre.diff); -[[pukiwiki-1.4.3用>org:自作プラグイン/pre.inc.php]] ** 1.4.4 [#va19fc65] 少し場所を考えれば1.4.4でも上記パッチは使えます。具体的にはlib/convert.html.phpの @@ -792,6 +800,8 @@ while (count($lines)) { + $this->tagblock($lines, '<pre>', '</pre>', 'Pre_inline'); + $line = array_shift($lines); if (substr($line,0,2) == '//') //コメントは処理しない ~の代わりに、867行目あたりに以下を追加 function parse(& $lines) { $this->last = & $this; $matches = array(); while (! empty($lines)) { + $this->tagblock($lines, '<pre>', '</pre>', 'Pre_inline'); $line = array_shift($lines); ** 1.4.5 [#vfbb2591] - 1.4.4と同様に、少し場所(行)を考えれば上記パッチは使える。 ** 1.4.4_php5, 1.4.6 [#d9915645] Pre_inline クラス、Body#tagblock 関数がなくなっているので付け足す必要がある 好きなところで良いが、Pre クラスの下あたりが理にかなっているだろう。 +class Pre_inline extends Pre +{ + function Pre_inline(&$root,$text) + { + parent::Element(); + $this->elements[] = make_link($text); + } +} class Body extends Element { ..... function parse(& $lines) { $this->last = & $this; $matches = array(); while (! empty($lines)) { + $this->tagblock($lines, '<pre>', '</pre>', 'Pre'); //通常整形済みテキスト + $this->tagblock($lines, '<pre2>', '</pre2>', 'Pre_inline'); //preタグで囲うがpukiwiki文法を展開する $line = array_shift($lines); ..... + + function tagblock(&$lines, $start, $end, $class) + { + if (rtrim($lines[0]) != $start) { + return; + } + array_shift($lines); + while (count($lines)) { + $line = preg_replace('/[\r\n]*$/', '', array_shift($lines)); + if ($line == $end) { + return; + } + $this->last = &$this->last->add(new $class($this, $line)); + } + } }