diff --git a/phpdotnet/phd/Format/Abstract/XHTML.php b/phpdotnet/phd/Format/Abstract/XHTML.php index 12f57171..4d67268f 100644 --- a/phpdotnet/phd/Format/Abstract/XHTML.php +++ b/phpdotnet/phd/Format/Abstract/XHTML.php @@ -31,7 +31,10 @@ public function transformFromMap($open, $tag, $name, $attrs, $props) { $id = $attrs[Reader::XMLNS_XML]["id"]; $idstr = ' id="' .$id. '"'; } - return '<' .$tag. ' class="' .$name. '"' . $idstr . ($props["empty"] ? '/' : "") . '>'; + if ($props["empty"]) { + return '<' .$tag. ' class="' .$name. '"' . $idstr . '>'; + } + return '<' .$tag. ' class="' .$name. '"' . $idstr . '>'; } return ''; } diff --git a/tests/package/generic/data/empty_title_001.xml b/tests/package/generic/data/empty_title_001.xml new file mode 100644 index 00000000..56c13c1c --- /dev/null +++ b/tests/package/generic/data/empty_title_001.xml @@ -0,0 +1,7 @@ + +
+
+ + <simpara>Some content after empty title</simpara> + </section> +</article> diff --git a/tests/package/generic/empty_title_001.phpt b/tests/package/generic/empty_title_001.phpt new file mode 100644 index 00000000..76dfd1b1 --- /dev/null +++ b/tests/package/generic/empty_title_001.phpt @@ -0,0 +1,29 @@ +--TEST-- +GH-181 Empty title should not swallow sibling content +--FILE-- +<?php +namespace phpdotnet\phd; + +require_once __DIR__ . "/../../setup.php"; + +$xmlFile = __DIR__ . "/data/empty_title_001.xml"; + +$config->xmlFile = $xmlFile; + +$format = new TestGenericChunkedXHTML($config, $outputHandler); +$render = new TestRender(new Reader($outputHandler), $config, $format); + +$render->run(); +?> +--EXPECTF-- +Filename: empty-title-section.html +Content: +<div id="empty-title-section" class="section"> + <h2 class="title"></h2> + <p class="simpara">Some content after empty title</p> + </div> +Filename: empty_title_test.html +Content: +<div id="empty_title_test" class="article"> +%A +</div>