includeしたページの<h1~h3>横の↑リンクの飛び先が存在しない

メッセージ

includeしたページ内にある<h*>の横の↑の飛び先がcontents_数字になっているため、飛び先が存在しないことになる。

対策としては、↑の飛び先をページ上部のメニューにすればよい。 上部のメニュー部分は<div id="navigator">になっているので、↑の飛び先を<a href="#navigator">にしておけば、includeされたページ記事からでも問題なくページ先頭に飛ぶことができる。

↑(&uarr;)ですが、現在はdefault.ini.phpの$topで設定しているが、全角の↑や▲も使えるようにja.lng、en.lngで設定するほうがいい。

リンクの位置が<h*>の横にあるが、<h*>の直前行に、<span>ではなく<div class="jumpmenu">で囲んで出力したほうがわかりやすい。このとき、先頭の<h*>の直前にだけは出力しないほうが美しい。

$top = '<div class="jumpmenu"><a href="#navigator">▲</a></div>'

CSSファイルのほうで

.jumpmenu{
   font-size:60%;
   text-align:right;
}

1.3ではhtml.phpのheadingの部分を次のような感じに書き換えればいい。

 } else if ($line_head == '*') { // Heading
   if (preg_match("/^(\*{1,3})\s*(.*)/",$line,$out)) {
     end_block($result,$saved,$flag); //見出しはいかなるブロック要素にも食われない
     $str = inline($out[2]);
     $level = strlen($out[1]);
     $h = $level + 1;
     if($content_count == 0 && $content_id == 1){ //先頭の<h*>の場合
       array_push($result, "<h$h><a id=\"content_{$content_id_local}_$content_count\"></a>$str</h$h>");
     } else { //先頭以外の<h*>
       array_push($result, $top."\n<h$h><a id=\"content_{$content_id_local}_$content_count\"></a>$str</h$h>");
     }
     if($content_count == 0)
       $tmp_lvl = $level;
     $arycontents[] = str_repeat("-",$level-$tmp_lvl+1)."<a href=\"#content_{$content_id_local}_$content_count\">".strip_htmltag(make_user_rules(inline($out[2],TRUE)))."</a>\n";
     $content_count++;
     continue;
   }

上記では、<h1>がなく<h2>や<h3>だけ存在するページのcontentsの出力の字下げが深くなりすぎる対策もしてあります。

1.4ではconvert_html.phpのclass headingを変更すればいいんだろうけど、よくわからなかった(^^;;



トップ   編集 凍結 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2008-05-08 (木) 21:29:36
Site admin: PukiWiki Development Team

PukiWiki 1.5.4+ © 2001-2022 PukiWiki Development Team. Powered by PHP 8.2.12. HTML convert time: 0.192 sec.

SourceForge