質問箱/5373
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
**[[質問箱/5373]] [#fda0bb52]
|RIGHT:70|LEFT:410|c
|~カテゴリ|動作環境|
|~サマリ|行頭<pre>~行頭</pre>間を整形済みとする|
|~バージョン|1.5.3|
|~投稿者|[[p]]|
|~状態|質問|
|~投稿日|&new{2020-05-06 (水) 14:45:58};|
***質問 [#cf26aaac]
1.5.0で [[dev:PukiWiki/1.4/ちょっと便利に/整形済みブロッ...
1.5.3を新規に入れていつも通りカスタマイズしたのですが、<p...
(2行目以降は空白になります)
仮対応として以下の行を変更
- $this->last = &$this->last->add(new $class($this, $lin...
+ $this->last = &$this->last->add(new Pre($this, $line));
テキスト表示はできるようにしました。
しかし、このままでは<pre>中のhttp*がリンクにならないので...
***回答 [#c668993d]
- 少し改変してやってみましたが『1.5.3を新規に入れていつも...
$ git diff
diff --git a/lib/convert_html.php b/lib/convert_html.php
index 0f4c42b..887622d 100644
--- a/lib/convert_html.php
+++ b/lib/convert_html.php
@@ -808,6 +808,20 @@ class Pre extends Element
}
}
+class Pre_inline extends Pre
+{
+ function Pre_inline(&$root, $text)
+ {
+ $this->__construct($root, $text);
+ }
+
+ function __construct(&$root, $text)
+ {
+ parent::__construct($root, $text);
+ $this->elements[] = make_link($text);
+ }
+}
+
// Block plugin: #something (started with '#')
class Div extends Element
{
@@ -898,6 +912,8 @@ class Body extends Element
$matches = array();
while (! empty($lines)) {
+ $this->tagblock($lines, '<pre>',...
+ $this->tagblock($lines, '<pre2>'...
$line = array_shift($lines);
// Escape comments
@@ -1032,6 +1048,21 @@ class Body extends Element
'</div>' . "\n";
return $contents;
}
+
+ function tagblock(&$lines, $start, $end, $class)
+ {
+ if (rtrim($lines[0]) != $start) {
+ return;
+ }
+ array_shift($lines);
+ while (count($lines)) {
+ $line = preg_replace('/[?r?n]*$/...
+ if ($line == $end) {
+ return;
+ }
+ $this->last = &$this->last->add(...
+ }
+ }
}
class Contents_UList extends ListContainer
- 確認有難うございます。最初の1行しか表示されないのは「1....
- 失礼しました。ご提示のコードだと1行目が2回表示されます...
- 直りました。 ( pre と pre2 があるんですね ) -- [[umorig...
-- 修正箇所: (1)改行削除の \\r\\n がなぜか ?r?r に代わっ...
$ git diff
diff --git a/lib/convert_html.php b/lib/convert_html.php
index 0f4c42b..18619b0 100644
--- a/lib/convert_html.php
+++ b/lib/convert_html.php
@@ -808,6 +808,15 @@ class Pre extends Element
}
}
+class Pre_inline extends Pre
+{
+ function __construct(&$root, $text)
+ {
+ parent::__construct($root, $text);
+ $this->elements = array(make_link($text));
+ }
+}
+
// Block plugin: #something (started with '#')
class Div extends Element
{
@@ -898,6 +907,8 @@ class Body extends Element
$matches = array();
while (! empty($lines)) {
+ $this->tagblock($lines, '<pre>', '</pre>', 'Pre');
+ $this->tagblock($lines, '<pre2>', '</pre2>', 'Pre_in...
$line = array_shift($lines);
// Escape comments
@@ -1032,6 +1043,21 @@ class Body extends Element
'</div>' . "\n";
return $contents;
}
+
+ function tagblock(&$lines, $start, $end, $class)
+ {
+ if (rtrim($lines[0]) !== $start) {
+ return;
+ }
+ array_shift($lines);
+ while (count($lines)) {
+ $line = preg_replace('/[\\r\\n]*$/', '', array_shif...
+ if ($line === $end) {
+ return;
+ }
+ $this->last = &$this->last->add(new $class($this, $l...
+ }
+ }
}
class Contents_UList extends ListContainer
- [[dev:PukiWiki/1.4/ちょっと便利に/整形済みブロック]]も...
- umoriguさん、そういうことでしたか!こちらでも修正されま...
#comment
終了行:
**[[質問箱/5373]] [#fda0bb52]
|RIGHT:70|LEFT:410|c
|~カテゴリ|動作環境|
|~サマリ|行頭<pre>~行頭</pre>間を整形済みとする|
|~バージョン|1.5.3|
|~投稿者|[[p]]|
|~状態|質問|
|~投稿日|&new{2020-05-06 (水) 14:45:58};|
***質問 [#cf26aaac]
1.5.0で [[dev:PukiWiki/1.4/ちょっと便利に/整形済みブロッ...
1.5.3を新規に入れていつも通りカスタマイズしたのですが、<p...
(2行目以降は空白になります)
仮対応として以下の行を変更
- $this->last = &$this->last->add(new $class($this, $lin...
+ $this->last = &$this->last->add(new Pre($this, $line));
テキスト表示はできるようにしました。
しかし、このままでは<pre>中のhttp*がリンクにならないので...
***回答 [#c668993d]
- 少し改変してやってみましたが『1.5.3を新規に入れていつも...
$ git diff
diff --git a/lib/convert_html.php b/lib/convert_html.php
index 0f4c42b..887622d 100644
--- a/lib/convert_html.php
+++ b/lib/convert_html.php
@@ -808,6 +808,20 @@ class Pre extends Element
}
}
+class Pre_inline extends Pre
+{
+ function Pre_inline(&$root, $text)
+ {
+ $this->__construct($root, $text);
+ }
+
+ function __construct(&$root, $text)
+ {
+ parent::__construct($root, $text);
+ $this->elements[] = make_link($text);
+ }
+}
+
// Block plugin: #something (started with '#')
class Div extends Element
{
@@ -898,6 +912,8 @@ class Body extends Element
$matches = array();
while (! empty($lines)) {
+ $this->tagblock($lines, '<pre>',...
+ $this->tagblock($lines, '<pre2>'...
$line = array_shift($lines);
// Escape comments
@@ -1032,6 +1048,21 @@ class Body extends Element
'</div>' . "\n";
return $contents;
}
+
+ function tagblock(&$lines, $start, $end, $class)
+ {
+ if (rtrim($lines[0]) != $start) {
+ return;
+ }
+ array_shift($lines);
+ while (count($lines)) {
+ $line = preg_replace('/[?r?n]*$/...
+ if ($line == $end) {
+ return;
+ }
+ $this->last = &$this->last->add(...
+ }
+ }
}
class Contents_UList extends ListContainer
- 確認有難うございます。最初の1行しか表示されないのは「1....
- 失礼しました。ご提示のコードだと1行目が2回表示されます...
- 直りました。 ( pre と pre2 があるんですね ) -- [[umorig...
-- 修正箇所: (1)改行削除の \\r\\n がなぜか ?r?r に代わっ...
$ git diff
diff --git a/lib/convert_html.php b/lib/convert_html.php
index 0f4c42b..18619b0 100644
--- a/lib/convert_html.php
+++ b/lib/convert_html.php
@@ -808,6 +808,15 @@ class Pre extends Element
}
}
+class Pre_inline extends Pre
+{
+ function __construct(&$root, $text)
+ {
+ parent::__construct($root, $text);
+ $this->elements = array(make_link($text));
+ }
+}
+
// Block plugin: #something (started with '#')
class Div extends Element
{
@@ -898,6 +907,8 @@ class Body extends Element
$matches = array();
while (! empty($lines)) {
+ $this->tagblock($lines, '<pre>', '</pre>', 'Pre');
+ $this->tagblock($lines, '<pre2>', '</pre2>', 'Pre_in...
$line = array_shift($lines);
// Escape comments
@@ -1032,6 +1043,21 @@ class Body extends Element
'</div>' . "\n";
return $contents;
}
+
+ function tagblock(&$lines, $start, $end, $class)
+ {
+ if (rtrim($lines[0]) !== $start) {
+ return;
+ }
+ array_shift($lines);
+ while (count($lines)) {
+ $line = preg_replace('/[\\r\\n]*$/', '', array_shif...
+ if ($line === $end) {
+ return;
+ }
+ $this->last = &$this->last->add(new $class($this, $l...
+ }
+ }
}
class Contents_UList extends ListContainer
- [[dev:PukiWiki/1.4/ちょっと便利に/整形済みブロック]]も...
- umoriguさん、そういうことでしたか!こちらでも修正されま...
#comment
ページ名: