<?php
// PukiWiki - Yet another WikiWikiWeb clone
-// $Id: convert_html.php,v 1.12 2005/04/30 05:21:00 henoheno Exp $
+// $Id: convert_html.php,v 1.16 2005/07/19 15:38:35 henoheno Exp $
// Copyright (C)
// 2002-2005 PukiWiki Developers Team
// 2001-2002 Originally written by yu-ji
function & Factory_Div(& $root, $text)
{
- if (! preg_match('/^\#([^\(]+)(?:\((.*)\))?/', $text, $out) ||
- ! exist_plugin_convert($out[1])) {
- return new Paragraph($text);
+ $matches = array();
+
+ // Seems block plugin?
+ if (PKWKEXP_DISABLE_MULTILINE_PLUGIN_HACK) {
+ // Usual code
+ if (preg_match('/^\#([^\(]+)(?:\((.*)\))?/', $text, $matches) &&
+ exist_plugin_convert($matches[1])) {
+ return new Div($matches);
+ }
} else {
- return new Div($out);
+ // Hack code
+ if(preg_match('/^#([^\(\{]+)(?:\(([^\r]*)\))?(\{*)/', $text, $matches) &&
+ exist_plugin_convert($matches[1])) {
+ $len = strlen($matches[3]);
+ $body = array();
+ if ($len == 0) {
+ return new Div($matches); // Seems legacy block plugin
+ } else if (preg_match('/\{{' . $len . '}\s*\r(.*)\r\}{' . $len . '}/', $text, $body)) {
+ $matches[2] .= "\r" . $body[1] . "\r";
+ return new Div($matches); // Seems multiline-enabled block plugin
+ }
+ }
}
+
+ return new Paragraph($text);
}
// ¥¤¥ó¥é¥¤¥óÍ×ÁÇ
}
}
-// #something (started with '#')
+// Block plugin: #something (started with '#')
class Div extends Element
{
var $name;
function toString()
{
+ // Call #plugin
return do_plugin_convert($this->name, $this->param);
}
}
continue;
}
+ // Multiline-enabled block plugin
+ if (! PKWKEXP_DISABLE_MULTILINE_PLUGIN_HACK &&
+ preg_match('/^#[^{]+(\{\{+)\s*$/', $line, $matches)) {
+ $len = strlen($matches[1]);
+ $line .= "\r"; // Delimiter
+ while (! empty($lines)) {
+ $next_line = preg_replace("/[\r\n]*$/", '', array_shift($lines));
+ if (preg_match('/\}{' . $len . '}/', $next_line)) {
+ $line .= $next_line;
+ break;
+ } else {
+ $line .= $next_line .= "\r"; // Delimiter
+ }
+ }
+ }
+
// The first character
$head = $line{0};
{
global $top, $_symbol_anchor;
+ // Heading id (auto-generated)
+ $autoid = 'content_' . $this->id . '_' . $this->count;
+ $this->count++;
+
+ // Heading id (specified by users)
$id = make_heading($text, FALSE); // Cut fixed-anchor from $text
- $anchor = ($id == '') ? '' : ' &aname(' . $id . ',super,full){' . $_symbol_anchor . '};';
+ if ($id == '') {
+ // Not specified
+ $id = & $autoid;
+ $anchor = '';
+ } else {
+ $anchor = ' &aname(' . $id . ',super,full){' . $_symbol_anchor . '};';
+ }
$text = ' ' . $text;
- $id = 'content_' . $this->id . '_' . $this->count;
- $this->count++;
+
+ // Add 'page contents' link to its heading
$this->contents_last = & $this->contents_last->add(new Contents_UList($text, $level, $id));
- return array($text . $anchor, $this->count > 1 ? "\n" . $top : '', $id);
+ // Add heding
+ return array($text . $anchor, $this->count > 1 ? "\n" . $top : '', $autoid);
}
function & insert(& $obj)