<?php
// PukiWiki - Yet another WikiWikiWeb clone
-// $Id: convert_html.php,v 1.17 2006/01/22 15:01:16 henoheno Exp $
+// $Id: convert_html.php,v 1.18 2006/05/13 07:29:58 henoheno Exp $
// Copyright (C)
// 2002-2005 PukiWiki Developers Team
// 2001-2002 Originally written by yu-ji
return $body->toString();
}
-// ¥Ö¥í¥Ã¥¯Í×ÁÇ
+// Block elements
class Element
{
- var $parent; // ¿ÆÍ×ÁÇ
- var $last; // ¼¡¤ËÍ×ÁǤòÁÞÆþ¤¹¤ëÀè
- var $elements; // Í×ÁǤÎÇÛÎó
+ var $parent;
+ var $elements; // References of childs
+ var $last; // Insert new one at the back of the $last
function Element()
{
}
}
+// Returns inline-related object
function & Factory_Inline($text)
{
+ // Check the first letter of the line
if (substr($text, 0, 1) == '~') {
- // ¹ÔƬ '~' ¡£¥Ñ¥é¥°¥é¥Õ³«»Ï
return new Paragraph(' ' . substr($text, 1));
} else {
return new Inline($text);
return new Paragraph($text);
}
-// ¥¤¥ó¥é¥¤¥óÍ×ÁÇ
+// Inline elements
class Inline extends Element
{
function Inline($text)
}
}
+// Lists (UL, OL, DL)
class ListContainer extends Element
{
var $tag;
{
parent::Element();
- //¥Þ¡¼¥¸¥ó¤ò¼èÆÀ
$var_margin = '_' . $tag . '_margin';
$var_left_margin = '_' . $tag . '_left_margin';
-
global $$var_margin, $$var_left_margin;
$this->margin = $$var_margin;
$this->left_margin = $$var_left_margin;
- //½é´ü²½
$this->tag = $tag;
$this->tag2 = $tag2;
$this->level = min(3, strspn($text, $head));
if (! is_a($obj, get_class($this)))
return $this->last = & $this->last->insert($obj);
- // ¹ÔƬʸ»ú¤Î¤ß¤Î»ØÄê»þ¤ÏUL/OL¥Ö¥í¥Ã¥¯¤òæ½Ð
- // BugTrack/524
+ // Break if no elements found (BugTrack/524)
if (count($obj->elements) == 1 && empty($obj->elements[0]->elements))
- return $this->last->parent; // up to ListElement.
+ return $this->last->parent; // up to ListElement
- // Move elements.
+ // Move elements
foreach(array_keys($obj->elements) as $key)
parent::insert($obj->elements[$key]);
}
if ($text != '' && $text{0} == '#') {
- // ¥»¥ëÆâÍƤ¬'#'¤Ç»Ï¤Þ¤ë¤È¤¤ÏDiv¥¯¥é¥¹¤òÄ̤·¤Æ¤ß¤ë
+ // Try using Div class for this $text
$obj = & Factory_Div($this, $text);
if (is_a($obj, 'Paragraph'))
$obj = & $obj->elements[0];
{
static $parts = array('h'=>'thead', 'f'=>'tfoot', ''=>'tbody');
- // rowspan¤òÀßÄê(²¼¤«¤é¾å¤Ø)
+ // Set rowspan (from bottom, to top)
for ($ncol = 0; $ncol < $this->col; $ncol++) {
$rowspan = 1;
foreach (array_reverse(array_keys($this->elements)) as $nrow) {
continue;
}
$row[$ncol]->rowspan = $rowspan;
- while (--$rowspan) // ¹Ô¼ïÊ̤ò·Ñ¾µ¤¹¤ë
+ // Inherits row type
+ while (--$rowspan)
$this->types[$nrow + $rowspan] = $this->types[$nrow];
$rowspan = 1;
}
}
- // colspan,style¤òÀßÄê
+ // Set colspan and style
$stylerow = NULL;
foreach (array_keys($this->elements) as $nrow) {
$row = & $this->elements[$nrow];
$row[$ncol]->colspan = $colspan;
if ($stylerow !== NULL) {
$row[$ncol]->setStyle($stylerow[$ncol]->style);
- while (--$colspan) // Îó¥¹¥¿¥¤¥ë¤ò·Ñ¾µ¤¹¤ë
+ // Inherits column style
+ while (--$colspan)
$row[$ncol - $colspan]->setStyle($stylerow[$ncol]->style);
}
$colspan = 1;
}
}
- // ¥Æ¥¥¹¥È²½
+ // toString
$string = '';
foreach ($parts as $type => $part)
{
{
function Contents_UList($text, $level, $id)
{
- // ¥Æ¥¥¹¥È¤Î¥ê¥Õ¥©¡¼¥à
- // ¹ÔƬ\n¤ÇÀ°·ÁºÑ¤ß¤òɽ¤¹ ... X(
+ // Reformatting $text
+ // A line started with "\n" means "preformatted" ... X(
make_heading($text);
$text = "\n" . '<a href="#' . $id . '">' . $text . '</a>' . "\n";
parent::ListContainer('ul', 'li', '-', str_repeat('-', $level));