Skip to content
Snippets Groups Projects
Commit ff1f7b1c authored by Peter Rotich's avatar Peter Rotich
Browse files

Merge pull request #37 from greezybacon/issue/html-text-zero-size-cells


Provide a minimum width for table cells

Reviewed-By: default avatarPeter Rotich <peter@osticket.com>
parents 6e8033b6 afe48f99
No related branches found
No related tags found
No related merge requests found
......@@ -151,6 +151,7 @@ class HtmlInlineElement {
var $children = array();
var $style = false;
var $stylesheets = array();
var $footnotes = array();
var $ws = false;
function __construct($node, $parent) {
......@@ -200,6 +201,11 @@ class HtmlInlineElement {
elseif (is_string($more))
$output .= $more;
}
if ($this->footnotes) {
$output .= "\n\n" . str_repeat('-', $width/2) . "\n";
foreach ($this->footnotes as $name=>$content)
$output .= "[$name] ".$content."\n";
}
return $output;
}
......@@ -253,6 +259,10 @@ class HtmlInlineElement {
function addStylesheet(&$s) {
$this->stylesheets[] = $s;
}
function addFootNote($name, $content) {
$this->footnotes[$name] = $content;
}
}
class HtmlBlockElement extends HtmlInlineElement {
......@@ -397,7 +407,9 @@ class HtmlImgElement extends HtmlInlineElement {
$alt = $this->node->getAttribute("alt");
return "[image:$alt$title] ";
}
function getWeight() { return parent::getWeight() + 4; }
function getWeight() {
return strlen($this->node->getAttribute("alt")) + 8;
}
}
class HtmlAElement extends HtmlInlineElement {
......@@ -410,6 +422,10 @@ class HtmlAElement extends HtmlInlineElement {
if ($this->node->getAttribute("name") != null) {
$output = "[$output]";
}
} elseif (strlen($href) > $width / 2) {
$output = "[$output][]";
if ($href != $output)
$this->getRoot()->addFootnote($output, $href);
} else {
if ($href != $output) {
$output = "[$output]($href)";
......@@ -687,7 +703,7 @@ class HtmlTableCell extends HtmlBlockElement {
}
function getMinWidth() {
return parent::getMinWidth() / $this->cols;
return max(4, parent::getMinWidth() / $this->cols);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment