Skip to content

Commit

Permalink
Add table formatting for constant lists
Browse files Browse the repository at this point in the history
  • Loading branch information
haszi committed Jan 29, 2024
1 parent bacc87c commit 21735f9
Showing 1 changed file with 31 additions and 11 deletions.
42 changes: 31 additions & 11 deletions phpdotnet/phd/Package/Generic/XHTML.php
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ abstract class Package_Generic_XHTML extends Format_Abstract_XHTML {
'sect4' => 'h5',
'segmentedlist' => 'format_table_title',
'table' => 'format_table_title',
'variablelist' => 'strong',
'variablelist' => 'format_variablelist_title',
'article' => 'format_container_chunk_top_title',
'appendix' => 'format_container_chunk_top_title',
'book' => 'format_container_chunk_top_title',
Expand Down Expand Up @@ -1478,14 +1478,25 @@ public function format_step($open, $name, $attrs) {
}
public function format_variablelist($open, $name, $attrs) {
if ($open) {
if (isset($attrs[Reader::XMLNS_DOCBOOK]["role"])) {
$this->role = $attrs[Reader::XMLNS_DOCBOOK]["role"];
}
$classStr = $headerStr = $idStr = '';
if (isset($attrs[Reader::XMLNS_XML]["id"])) {
$id = $attrs[Reader::XMLNS_XML]["id"];
return '<dl id="'.$id.'">';
$idStr = ' id="' . $attrs[Reader::XMLNS_XML]["id"] . '"';
}
if ($this->role === 'constant_list') {
$tagName = 'table';
$classStr = ' class="doctable table"';
$headerStr = "\n<tr>\n<th>Constants</th>\n<th>Description</th>\n</tr>";
} else {
return '<dl>';
$tagName = 'dl';
}
return '<' . $tagName . $idStr . $classStr . '>' . $headerStr;
}
return "</dl>\n";
$tagName = ($this->role === 'constant_list') ? 'table' : 'dl';
$this->role = false;
return "</" . $tagName . ">\n";
}
public function format_varlistentry($open, $name, $attrs) {
if ($open) {
Expand All @@ -1494,26 +1505,29 @@ public function format_varlistentry($open, $name, $attrs) {
} else {
unset($this->cchunk['varlistentry']['id']);
}
return ($this->role === 'constant_list') ? '<tr>' : '';
}
return '';
return ($this->role === 'constant_list') ? '</tr>' : '';
}
public function format_varlistentry_term($open, $name, $attrs, $props) {
$tagName = ($this->role === 'constant_list') ? 'td' : 'dt';
if ($open) {
if (isset($this->cchunk['varlistentry']['id'])) {
$id = $this->cchunk['varlistentry']['id'];
unset($this->cchunk['varlistentry']['id']);
return '<dt id="'.$id.'">';
return '<' . $tagName . ' id="' . $id . '">';
} else {
return "<dt>\n";
return "<" . $tagName . ">\n";
}
}
return "</dt>\n";
return "</" . $tagName . ">\n";
}
public function format_varlistentry_listitem($open, $name, $attrs) {
$tagName = ($this->role === 'constant_list') ? 'td' : 'dd';
if ($open) {
return "<dd>\n";
return "<" . $tagName . ">\n";
}
return "</dd>\n";
return "</" . $tagName . ">\n";
}
public function format_term($open, $name, $attrs, $props) {
if ($open) {
Expand Down Expand Up @@ -1653,6 +1667,12 @@ public function format_table_title($open, $name, $attrs, $props)
}
return "</strong></caption>";
}
public function format_variablelist_title($open, $name, $attrs, $props) {
if ($open) {
return ($this->role === 'constant_list') ? "<caption><strong>" : "<strong>";
}
return ($this->role === 'constant_list') ? "</strong></caption>" : "</strong>";
}

public function format_mediaobject($open, $name, $attrs) {
$this->cchunk["mediaobject"] = $this->dchunk["mediaobject"];
Expand Down

0 comments on commit 21735f9

Please sign in to comment.