BugTrack/2283 より移動:
複数行の引数がここの例のような記述であった場合に、引数の中身に対しても見出しへのリンクを生成してしまい、結果としてアンカーの番号がずれてゆきます。
$anchor = PLUGIN_LS2_ANCHOR_ORIGIN; + $multi = 0; $matches = array(); foreach (get_source($page) as $line) { - if ($params['title'] && preg_match('/^(\*{1,3})/', $line, $matches)) { - $id = make_heading($line); - $level = strlen($matches[1]); - $id = PLUGIN_LS2_ANCHOR_PREFIX . $anchor++; - plugin_ls2_list_push($params, $level + strlen($level)); - array_push($params['result'], - '<li><a href="' . $href . $id . '">' . $line . '</a>'); - } else if ($params['include'] && - preg_match('/^#include\((.+)\)/', $line, $matches) && - is_page($matches[1])) - { - plugin_ls2_get_headings($matches[1], $params, $level + 1, TRUE); - } + if ($line == '') continue; + + if ($multi > 2) { + if (preg_match('/\}{' . $multi . '}/', $line)) { + $multi = 0; + } + continue; + } + + switch ($line{0}) + { + case '#': + if (! PKWKEXP_DISABLE_MULTILINE_PLUGIN_HACK && + preg_match('/^#[^{]+(\{\{+)\s*$/', $line, $matches)) + { + $multi = strlen($matches[1]); + } + + if ($params['include'] && + preg_match('/^#include\((.+)\)/', $line, $matches)) + { + $include_page = array_shift(csv_explode(',', $matches[1])); + $include_page = get_fullname($include_page, $page); + if (is_page($include_page)) { + page_list2_get_headings($include_page, $params, $h_level, TRUE); + } + } + break; + + case '*': + if ($params['title']) + { + preg_match('/^(\*{1,3})/', $line, $matches); + $id = make_heading($line); + $h_level = $level + strlen($matches[1]); + $id = _PLUGIN_LS2_ANCHOR_PREFIX . $anchor++; + page_list2_list_push($params, $h_level); + $params['result'][] = ' <li><a href="' . $params['read_href'] . $r_page . $id . + '">' . $line . '</a>'; + } + break; + } + } }