[[PukiWiki/1.4/ちょっと便利に]]

* 見出しを5段まで、リスト階層を無制限に [#v1eb8ee5]

水平線は「-を4つ以上並べ、行末まで空白以外の文字が現れない」にルール変更

 --- 3段目
 ---- 4段目
 ----- 5段目

#ref(list_unlimit.diff); 

※↑ver 1.4.7でパッチがうまく当たらなかったので、1.4.7用のパッチを作りました。下に張り付けてあります。by TOBY

#contents

**コメント [#iae22bc8]
-上記の差分だけではなく、ls2プラグインなど見出しをpreg_match('/^(\*{1,3})/',~という形で参照している部分も変更したほうがいいかも。 -- [[reimy]] &new{2003-12-26 (金) 18:30:09};
--たとえば、ls2プラグインの187行目あたり
 if ($params['title'] and preg_match('/^(\*{1,3})/',$line,$matches))
~このほかにもいくつかのプラグインで、preg_match('/^(\*{1,3})/',~という形で参照してるので、どこまで反映させるか、個々の判断ってとこかな。-- [[reimy]] &new{2003-12-26 (金) 23:07:42};
-それと、第4階層以下は「リストからの脱出技」が使えないので要注意。 -- [[reimy]] &new{2004-01-14 (水) 10:59:56};

-これは取り込んで欲しいですね。現状の見出し3つだと足らないときがありますので。 --  &new{2005-06-12 (日) 23:13:26};
-- 既存のルール体系で書いたコンテンツに簡単に非互換が生じるので、そうはいかないです -- [[henoheno]] &new{2005-06-12 (日) 23:45:43};
-- 深いネストには欠点もあるので、お好みでお使いください。 -- [[henoheno]] &new{2005-06-12 (日) 23:46:39};

- このDiffの後半に、pcommentプラグインの編集が含まれていますが、この編集を行うと、どのように変わるのでしょうか? --  &new{2007-11-12 (月) 17:55:39};
-- それと、Diffでの変更点を見ながら、3→5→7に変えてみたのですが、6以降には見出しの帯が付かなくなっています。これを付くようにするには、どうすると良いのでしょうか? --  &new{2007-11-12 (月) 17:58:30};
--- それから、UPされているdiffのconvert_htmlの書き換え後の記述なのですが、たくさん抜けがあるような気がするのですが…。&br;これは、そのまま適用しても機能するのでしょうか?(手作業で書き換えたので、未確認…。) --  &new{2007-11-12 (月) 18:33:59};
- 見出しのレベル+1 をタグの基準に使っているので、見出しレベル5 でh6 になってしまいます(デフォルト)。h7 は無いハズなので、そのままでは見出しレベル6以降は使えないと思います。下に挙げた行をうまく変えないといけないかと。 --  &new{2007-11-13 (火) 20:00:42};
		$this->level++; // h2,h3,h4

- 1.4.7用のパッチはありませんでしょうか? -- [[TOBY]] &new{2008-05-19 (月) 13:34:11};
-- 手動でパッチを当てたらうまくいきました。パッチを上げたいのですが、どうしたらよいでしょう -- [[TOBY]] &new{2008-05-19 (月) 13:49:26};
-- 添付できなかったので貼り付けてみました。Pukiwiki 1.4.7用です。 -- [[TOBY]] &new{2008-05-19 (月) 14:33:42};

#comment

----
**Pukiwiki 1.4.7用パッチ [#w5ad6bc7]
- 添付できなかったので貼り付けてみました。Pukiwiki 1.4.7用です。 -- [[TOBY]] &new{2008-05-19 (月) 14:33:42};
 diff -u -r pukiwiki-1.4.7_notb/lib/convert_html.php list_unlimit_pukiwiki-1.4.7_notb/lib/convert_html.php
 --- pukiwiki-1.4.7_notb/lib/convert_html.php	2006-05-13 16:29:58.000000000 +0900
 +++ list_unlimit_pukiwiki-1.4.7_notb/lib/convert_html.php	2008-05-19 14:30:20.062500000 +0900
 @@ -238,7 +238,7 @@
  	{
  		parent::Element();
  
 -		$this->level = min(3, strspn($text, '*'));
 +		$this->level = min(5, strspn($text, '*'));
  		list($text, $this->msg_top, $this->id) = $root->getAnchor($text, $this->level);
  		$this->insert(Factory_Inline($text));
  		$this->level++; // h2,h3,h4
 @@ -306,7 +306,7 @@
  
  		$this->tag   = $tag;
  		$this->tag2  = $tag2;
 -		$this->level = min(3, strspn($text, $head));
 +		$this->level = strspn($text, $head);
  		$text = ltrim(substr($text, $this->level));
  
  		parent::insert(new ListElement($this->level, $tag2));
 @@ -426,7 +426,7 @@
  		parent::Element();
  
  		$head = substr($text, 0, 1);
 -		$this->level = min(3, strspn($text, $head));
 +		$this->level = strspn($text, $head);
  		$text = ltrim(substr($text, $this->level));
  
  		if ($head == '<') { // Blockquote close
 @@ -846,7 +846,7 @@
  			}
  
  			// Horizontal Rule
 -			if (substr($line, 0, 4) == '----') {
 +			if (preg_match('/^-{4,}\s*$/', $line)) {
  				$this->insert(new HRule($this, $line));
  				continue;
  			}
 diff -u -r pukiwiki-1.4.7_notb/lib/html.php list_unlimit_pukiwiki-1.4.7_notb/lib/html.php
 --- pukiwiki-1.4.7_notb/lib/html.php	2006-04-16 02:33:35.000000000 +0900
 +++ list_unlimit_pukiwiki-1.4.7_notb/lib/html.php	2008-05-19 14:30:20.078125000 +0900
 @@ -382,11 +382,11 @@
  	// Cut fixed-heading anchors
  	$id = '';
  	$matches = array();
 -	if (preg_match('/^(\*{0,3})(.*?)\[#([A-Za-z][\w-]+)\](.*?)$/m', $str, $matches)) {
 +	if (preg_match('/^(\*{0,5})(.*?)\[#([A-Za-z][\w-]+)\](.*?)$/m', $str, $matches)) {
  		$str = $matches[2] . $matches[4];
  		$id  = & $matches[3];
  	} else {
 -		$str = preg_replace('/^\*{0,3}/', '', $str);
 +		$str = preg_replace('/^\*{0,5}/', '', $str);
  	}
  
  	// Cut footnotes and tags
 diff -u -r pukiwiki-1.4.7_notb/plugin/pcomment.inc.php  list_unlimit_pukiwiki-1.4.7_notb/plugin/pcomment.inc.php
 --- pukiwiki-1.4.7_notb/plugin/pcomment.inc.php	2005-10-04 23:31:22.000000000 +0900
 +++ list_unlimit_pukiwiki-1.4.7_notb/plugin/pcomment.inc.php	2008-05-19 14:30:20.093750000 +0900
 @@ -234,14 +234,14 @@
  		if ($reply_hash != '') {
  			while ($end_position < $count) {
  				$matches = array();
 -				if (preg_match('/^(\-{1,2})(?!\-)(.*)$/', $postdata[$end_position++], $matches)
 +				if (preg_match('/^(\-+)(.*)$/', $postdata[$end_position++], $matches)
  					&& md5($matches[2]) == $reply_hash)
  				{
  					$b_reply = TRUE;
  					$level   = strlen($matches[1]) + 1;
  
  					while ($end_position < $count) {
 -						if (preg_match('/^(\-{1,3})(?!\-)/', $postdata[$end_position], $matches)
 +						if (preg_match('/^(\-+)/', $postdata[$end_position], $matches)
  							&& strlen($matches[1]) < $level) break;
  						++$end_position;
  					}
 @@ -341,7 +341,7 @@
  	foreach ($data as $line) {
  		if ($count > 0 && $dir && $cnt == $count) break;
  
 -		if (preg_match('/^(\-{1,2})(?!\-)(.+)$/', $line, $matches)) {
 +		if (preg_match('/^(\-+)(.+)$/', $line, $matches)) {
  			if ($count > 0 && strlen($matches[1]) == 1 && ++$cnt > $count) break;
  
  			// Ready for radio-buttons

トップ   編集 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Site admin: PukiWiki Development Team

PukiWiki 1.5.4+ © 2001-2022 PukiWiki Development Team. Powered by PHP 5.6.40-0+deb8u12. HTML convert time: 0.043 sec.

OSDN