Skip to content
Snippets Groups Projects
Commit afe48f99 authored by Jared Hancock's avatar Jared Hancock
Browse files

Provide a minimum width for table cells

Also, add footnotes to the bottom of the rendered document for links that
are longer than half the document width.
parent 0fc28101
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.
Please register or to comment