- 追加された行はこの色です。
- 削除された行はこの色です。
[[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]
lib/convert_html.php 中に 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タグで囲うがインラインプラグイン、リンク展開をする
$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));
+ }
+ }
}
なお、PRE タグの大文字小文字を区別しないなら、上記 tagblock 中の
if (rtrim($lines[0]) != $start) {
行を
if (strcasecmp(rtrim($lines[0]), $start) != 0) {
に、
if ($line == $end) {
行を
if (strcasecmp($line, $end) == 0) {
に変更すればよい。
** 1.4.6 [#l81e3a5e]
1.4.6以降では [[PukiWiki/1.4/ちょっと便利に/複数行のプラグイン引数を可能に]] の機能が組み込まれている(デフォルトでは無効)ので、
[[org:自作プラグイン/codehighlight.inc.php]] 梱包の [[pre.inc.php>http://www.sys.tutkie.tut.ac.jp/~sasaki/pukiwiki/index.php?Pre]] を使用すればよいだろう((vervatim は verbatimのスペルミスと思われる))。
[[org:自作プラグイン/codehighlight.inc.php]] 梱包の [[pre.inc.php>http://www.sys.tutkie.tut.ac.jp/~sasaki/pukiwiki/index.php?Pre]] を使用すればよいだろう。
//((vervatim は verbatimのスペルミスと思われる))。 御指摘ありがとうございます
#pre{{
hoge
}}
#pre(novervatim){{
#pre(soft){{
&size(20){hoge};
}}
-preのオプションの verbatim / noverbatim はオプション名と機能が一致しないのでYukiWikiのバーベイタムに合わせて hard / soft に変更しました。 -- [[sky]]