BugTrack/2148
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
* 自動で見出しを元にセクション分けして欲しい [#bc1ab883]
- ページ: [[BugTrack2]]
- 投稿者: [[kakin]]
- 優先順位: 低
- 状態: 保留
- カテゴリー: 本体新機能
- 投稿日: 2006-01-07 (土) 17:04:32
- バージョン:
** メッセージ [#ob355e72]
セクション毎に字下げを行いたくて調べていたら、
次のような質問/解答を見つけました。
[[official:続・質問箱/68]]
私もちょうどこのような出力が欲しかったのですが、
解決していないようだったので自分で改造を施してみました。
せっかくですのでパッチをお送りします。(「$Id: convert_htm...
--- convert_html.php.original 2006-01-07 00:46:55.000000...
+++ convert_html.php 2006-01-07 16:54:15.691970424 +0900
@@ -206,7 +206,7 @@
// *** Heading3
class Heading extends Element
{
- var $level;
+ var $level; //'*'の数
var $id;
var $msg_top;
@@ -217,7 +217,6 @@
$this->level = min(3, strspn($text, '*'));
list($text, $this->msg_top, $this->id) = $root->getAn...
$this->insert(Factory_Inline($text));
- $this->level++; // h2,h3,h4
}
function & insert(& $obj)
@@ -234,7 +233,7 @@
function toString()
{
return $this->msg_top . $this->wrap(parent::toString...
- 'h' . $this->level, ' id="' . $this->id . '"');
+ 'h' . ($this->level + 1), ' id="' . $this->id . '"');
}
}
@@ -294,6 +293,8 @@
function canContain(& $obj)
{
+ if (is_a($obj, 'Heading')) return FALSE;
+ if (is_a($obj, 'HRule')) return FALSE;
return (! is_a($obj, 'ListContainer')
|| ($this->tag == $obj->tag && $this->level == $obj-...
}
@@ -349,6 +350,8 @@
function canContain(& $obj)
{
+ if (is_a($obj, 'Heading')) return FALSE;
+ if (is_a($obj, 'HRule')) return FALSE;
return (! is_a($obj, 'ListContainer') || ($obj->level...
}
@@ -421,6 +424,8 @@
function canContain(& $obj)
{
+ if (is_a($obj, 'Heading')) return FALSE;
+ if (is_a($obj, 'HRule')) return FALSE;
return (! is_a($obj, get_class($this)) || $obj->level...
}
@@ -529,6 +534,13 @@
return $this->wrap(parent::toString(), $this->tag, $p...
}
+
+ function canContain(& $obj)
+ {
+ if (is_a($obj, 'Heading')) return FALSE;
+ if (is_a($obj, 'HRule')) return FALSE;
+ return TRUE;
+ }
}
// | title1 | title2 | title3 |
@@ -557,6 +569,8 @@
function canContain(& $obj)
{
+ if (is_a($obj, 'Heading')) return FALSE;
+ if (is_a($obj, 'HRule')) return FALSE;
return is_a($obj, 'Table') && ($obj->col == $this->co...
}
@@ -675,6 +689,8 @@
function canContain(& $obj)
{
+ if (is_a($obj, 'Heading')) return FALSE;
+ if (is_a($obj, 'HRule')) return FALSE;
return is_a($obj, 'YTable') && ($obj->col == $this->c...
}
@@ -817,13 +833,20 @@
// Empty
if ($line == '') {
- $this->last = & $this;
+ while (! is_null($this->last)
+ && ! is_a($this->last, 'Body')
+ && ! is_a($this->last, 'Section')){
+ $this->last = & $this->last->parent;
+ }
+ if (is_null($this->last)){
+ $this->last = & $this;
+ }
continue;
}
// Horizontal Rule
if (substr($line, 0, 4) == '----') {
- $this->insert(new HRule($this, $line));
+ $this->last = & $this->last->add(new HRule($this, $...
continue;
}
@@ -832,7 +855,7 @@
// Heading
if ($head == '*') {
- $this->insert(new Heading($this, $line));
+ $this->last = & $this->last->add(new Section(new He...
continue;
}
@@ -952,4 +975,41 @@
$this->style = sprintf($_list_pad_str, $this->level, ...
}
}
+
+
+
+
+//Section
+class Section extends Element
+{
+ var $level;
+
+ function Section(& $heading)
+ {
+ parent::Element();
+ $this->level = $heading->level;
+ $this->insert($heading);
+ }
+
+ function canContain($obj)
+ {
+ //上又は同じ階層のSectionは入れられない。
+ if( is_a($obj, 'Section') && $obj->level <= $this->le...
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ function & insert(& $obj)
+ {
+ if (is_a($obj, 'Inline')) $obj = & $obj->toPara();
+ return parent::insert($obj);
+ }
+
+ function toString()
+ {
+ return $this->wrap(parent::toString(), 'div', ' class...
+ }
+}
+
?>
デフォルトでこのような出力を行う事は、何らかの問題がある...
--------
#comment
終了行:
* 自動で見出しを元にセクション分けして欲しい [#bc1ab883]
- ページ: [[BugTrack2]]
- 投稿者: [[kakin]]
- 優先順位: 低
- 状態: 保留
- カテゴリー: 本体新機能
- 投稿日: 2006-01-07 (土) 17:04:32
- バージョン:
** メッセージ [#ob355e72]
セクション毎に字下げを行いたくて調べていたら、
次のような質問/解答を見つけました。
[[official:続・質問箱/68]]
私もちょうどこのような出力が欲しかったのですが、
解決していないようだったので自分で改造を施してみました。
せっかくですのでパッチをお送りします。(「$Id: convert_htm...
--- convert_html.php.original 2006-01-07 00:46:55.000000...
+++ convert_html.php 2006-01-07 16:54:15.691970424 +0900
@@ -206,7 +206,7 @@
// *** Heading3
class Heading extends Element
{
- var $level;
+ var $level; //'*'の数
var $id;
var $msg_top;
@@ -217,7 +217,6 @@
$this->level = min(3, strspn($text, '*'));
list($text, $this->msg_top, $this->id) = $root->getAn...
$this->insert(Factory_Inline($text));
- $this->level++; // h2,h3,h4
}
function & insert(& $obj)
@@ -234,7 +233,7 @@
function toString()
{
return $this->msg_top . $this->wrap(parent::toString...
- 'h' . $this->level, ' id="' . $this->id . '"');
+ 'h' . ($this->level + 1), ' id="' . $this->id . '"');
}
}
@@ -294,6 +293,8 @@
function canContain(& $obj)
{
+ if (is_a($obj, 'Heading')) return FALSE;
+ if (is_a($obj, 'HRule')) return FALSE;
return (! is_a($obj, 'ListContainer')
|| ($this->tag == $obj->tag && $this->level == $obj-...
}
@@ -349,6 +350,8 @@
function canContain(& $obj)
{
+ if (is_a($obj, 'Heading')) return FALSE;
+ if (is_a($obj, 'HRule')) return FALSE;
return (! is_a($obj, 'ListContainer') || ($obj->level...
}
@@ -421,6 +424,8 @@
function canContain(& $obj)
{
+ if (is_a($obj, 'Heading')) return FALSE;
+ if (is_a($obj, 'HRule')) return FALSE;
return (! is_a($obj, get_class($this)) || $obj->level...
}
@@ -529,6 +534,13 @@
return $this->wrap(parent::toString(), $this->tag, $p...
}
+
+ function canContain(& $obj)
+ {
+ if (is_a($obj, 'Heading')) return FALSE;
+ if (is_a($obj, 'HRule')) return FALSE;
+ return TRUE;
+ }
}
// | title1 | title2 | title3 |
@@ -557,6 +569,8 @@
function canContain(& $obj)
{
+ if (is_a($obj, 'Heading')) return FALSE;
+ if (is_a($obj, 'HRule')) return FALSE;
return is_a($obj, 'Table') && ($obj->col == $this->co...
}
@@ -675,6 +689,8 @@
function canContain(& $obj)
{
+ if (is_a($obj, 'Heading')) return FALSE;
+ if (is_a($obj, 'HRule')) return FALSE;
return is_a($obj, 'YTable') && ($obj->col == $this->c...
}
@@ -817,13 +833,20 @@
// Empty
if ($line == '') {
- $this->last = & $this;
+ while (! is_null($this->last)
+ && ! is_a($this->last, 'Body')
+ && ! is_a($this->last, 'Section')){
+ $this->last = & $this->last->parent;
+ }
+ if (is_null($this->last)){
+ $this->last = & $this;
+ }
continue;
}
// Horizontal Rule
if (substr($line, 0, 4) == '----') {
- $this->insert(new HRule($this, $line));
+ $this->last = & $this->last->add(new HRule($this, $...
continue;
}
@@ -832,7 +855,7 @@
// Heading
if ($head == '*') {
- $this->insert(new Heading($this, $line));
+ $this->last = & $this->last->add(new Section(new He...
continue;
}
@@ -952,4 +975,41 @@
$this->style = sprintf($_list_pad_str, $this->level, ...
}
}
+
+
+
+
+//Section
+class Section extends Element
+{
+ var $level;
+
+ function Section(& $heading)
+ {
+ parent::Element();
+ $this->level = $heading->level;
+ $this->insert($heading);
+ }
+
+ function canContain($obj)
+ {
+ //上又は同じ階層のSectionは入れられない。
+ if( is_a($obj, 'Section') && $obj->level <= $this->le...
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ function & insert(& $obj)
+ {
+ if (is_a($obj, 'Inline')) $obj = & $obj->toPara();
+ return parent::insert($obj);
+ }
+
+ function toString()
+ {
+ return $this->wrap(parent::toString(), 'div', ' class...
+ }
+}
+
?>
デフォルトでこのような出力を行う事は、何らかの問題がある...
--------
#comment
ページ名: