Skip to content

Commit

Permalink
Add handler for caption tag (#109)
Browse files Browse the repository at this point in the history
Co-authored-by: haszi <[email protected]>
  • Loading branch information
haszi and haszi authored Mar 17, 2024
1 parent efea045 commit 89216bc
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
4 changes: 4 additions & 0 deletions phpdotnet/phd/Package/Generic/XHTML.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ abstract class Package_Generic_XHTML extends Format_Abstract_XHTML {
'part' => 'format_chunk',
),
'book' => 'format_container_chunk_top',
'caption' => 'format_caption',
'chapter' => 'format_container_chunk_top',
'citetitle' => 'em',
'cmdsynopsis' => 'format_cmdsynopsis',
Expand Down Expand Up @@ -2280,4 +2281,7 @@ public function format_whitespace($whitespace, $elementStack, $currentDepth) {
return $whitespace;
}

public function format_caption($open, $name, $attrs, $props) {
return $open ? '<div class="caption">' : '</div>';
}
}
36 changes: 36 additions & 0 deletions tests/package/generic/caption_001.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
--TEST--
Whitespace formatting 001
--FILE--
<?php
namespace phpdotnet\phd;

require_once __DIR__ . "/../../setup.php";

$xml_file = __DIR__ . "/data/caption_001.xml";

Config::init(["xml_file" => $xml_file]);

$format = new TestGenericChunkedXHTML;
$format->postConstruct();
$render = new TestRender(new Reader, new Config, $format);

$render->run();
?>
--EXPECT--
Filename: caption_001.html
Content:
<div id="caption_001" class="chapter">

<div class="section">
<div class="mediaobject">
<div class="imageobject">
</div>
<div class="caption">
<p class="para">
Insightful caption
</p>
</div>
</div>
</div>

</div>
16 changes: 16 additions & 0 deletions tests/package/generic/data/caption_001.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<chapter xml:id="caption_001" xmlns="http://docbook.org/ns/docbook">

<section>
<mediaobject>
<imageobject>
</imageobject>
<caption>
<para>
Insightful caption
</para>
</caption>
</mediaobject>
</section>

</chapter>

0 comments on commit 89216bc

Please sign in to comment.