Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion phpdotnet/phd/Format/Abstract/XHTML.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 . '></' .$tag. '>';
}
return '<' .$tag. ' class="' .$name. '"' . $idstr . '>';
}
return '</' .$tag. '>';
}
Expand Down
7 changes: 7 additions & 0 deletions tests/package/generic/data/empty_title_001.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<article xmlns="http://docbook.org/ns/docbook" xml:id="empty_title_test">
<section xml:id="empty-title-section">
<title/>
<simpara>Some content after empty title</simpara>
</section>
</article>
29 changes: 29 additions & 0 deletions tests/package/generic/empty_title_001.phpt
Original file line number Diff line number Diff line change
@@ -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>