Skip to content

Commit

Permalink
Render elements in simplelist members correctly (#117)
Browse files Browse the repository at this point in the history
Co-authored-by: haszi <[email protected]>
  • Loading branch information
haszi and haszi authored Apr 25, 2024
1 parent ef13e91 commit e7a6c0c
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 6 deletions.
11 changes: 5 additions & 6 deletions phpdotnet/phd/Package/Generic/XHTML.php
Original file line number Diff line number Diff line change
Expand Up @@ -2166,6 +2166,11 @@ public function format_member($open, $name, $attrs, $props) {
if ($this->cchunk["simplelist"]["type"] === "inline"
|| $this->cchunk["simplelist"]["type"] === "vert"
|| $this->cchunk["simplelist"]["type"] === "horiz") {
$this->appendToBuffer = $open;
if (! $open) {
$this->cchunk["simplelist"]["members"][] = $this->buffer;
}
$this->buffer = '';
return '';
}
if ($open) {
Expand All @@ -2175,12 +2180,6 @@ public function format_member($open, $name, $attrs, $props) {
}

public function format_member_text($value, $tag) {
if ($this->cchunk["simplelist"]["type"] === "inline"
|| $this->cchunk["simplelist"]["type"] === "vert"
|| $this->cchunk["simplelist"]["type"] === "horiz") {
$this->cchunk["simplelist"]["members"][] = $value;
return '';
}
return $value;
}

Expand Down
26 changes: 26 additions & 0 deletions tests/package/generic/data/simplelist.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,30 @@
</simplelist>
</section>

<section>
<para>5. Simplelist with no type and various elements inside members</para>
<simplelist>
<member>1 <literal>First</literal></member>
<member>2 <constant>Second</constant></member>
<member>3 <code>Third</code></member>
<member>4 <literal>Fourth</literal></member>
<member>5 <constant>Fifth</constant></member>
<member>6 <code>Sixth</code></member>
<member>7 <literal>Seventh</literal></member>
</simplelist>
</section>

<section>
<para>6. Simplelist with "inline" type and various elements inside members</para>
<simplelist type="inline">
<member>1 <literal>First</literal></member>
<member>2 <constant>Second</constant></member>
<member>3 <code>Third</code></member>
<member>4 <literal>Fourth</literal></member>
<member>5 <constant>Fifth</constant></member>
<member>6 <code>Sixth</code></member>
<member>7 <literal>Seventh</literal></member>
</simplelist>
</section>

</chapter>
18 changes: 18 additions & 0 deletions tests/package/generic/simplelist_001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,22 @@ Content:
</table>
</div>

<div class="section">
<p class="para">5. Simplelist with no type and various elements inside members</p>
<ul class="simplelist">
<li>1 <code class="literal">First</code></li>
<li>2 <strong><code>Second</code></strong></li>
<li>3 <code class="code">Third</code></li>
<li>4 <code class="literal">Fourth</code></li>
<li>5 <strong><code>Fifth</code></strong></li>
<li>6 <code class="code">Sixth</code></li>
<li>7 <code class="literal">Seventh</code></li>
</ul>
</div>

<div class="section">
<p class="para">6. Simplelist with &quot;inline&quot; type and various elements inside members</p>
<span class="simplelist">1 <code class="literal">First</code>, 2 <strong><code>Second</code></strong>, 3 <code class="code">Third</code>, 4 <code class="literal">Fourth</code>, 5 <strong><code>Fifth</code></strong>, 6 <code class="code">Sixth</code>, 7 <code class="literal">Seventh</code></span>
</div>

</div>

0 comments on commit e7a6c0c

Please sign in to comment.