Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add handler for caption tag #109

Merged
merged 1 commit into from
Mar 17, 2024
Merged
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
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>';
haszi marked this conversation as resolved.
Show resolved Hide resolved
}
}
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>
Loading