From 89216bc29ab1915dc406568580d3880d4fa8ffc9 Mon Sep 17 00:00:00 2001 From: haszi Date: Sun, 17 Mar 2024 19:15:40 +0100 Subject: [PATCH] Add handler for caption tag (#109) Co-authored-by: haszi --- phpdotnet/phd/Package/Generic/XHTML.php | 4 +++ tests/package/generic/caption_001.phpt | 36 ++++++++++++++++++++++ tests/package/generic/data/caption_001.xml | 16 ++++++++++ 3 files changed, 56 insertions(+) create mode 100644 tests/package/generic/caption_001.phpt create mode 100644 tests/package/generic/data/caption_001.xml diff --git a/phpdotnet/phd/Package/Generic/XHTML.php b/phpdotnet/phd/Package/Generic/XHTML.php index 99223026..284858bc 100644 --- a/phpdotnet/phd/Package/Generic/XHTML.php +++ b/phpdotnet/phd/Package/Generic/XHTML.php @@ -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', @@ -2280,4 +2281,7 @@ public function format_whitespace($whitespace, $elementStack, $currentDepth) { return $whitespace; } + public function format_caption($open, $name, $attrs, $props) { + return $open ? '
' : '
'; + } } diff --git a/tests/package/generic/caption_001.phpt b/tests/package/generic/caption_001.phpt new file mode 100644 index 00000000..24846a46 --- /dev/null +++ b/tests/package/generic/caption_001.phpt @@ -0,0 +1,36 @@ +--TEST-- +Whitespace formatting 001 +--FILE-- + $xml_file]); + +$format = new TestGenericChunkedXHTML; +$format->postConstruct(); +$render = new TestRender(new Reader, new Config, $format); + +$render->run(); +?> +--EXPECT-- +Filename: caption_001.html +Content: +
+ +
+
+
+
+
+

+ Insightful caption +

+
+
+
+ +
diff --git a/tests/package/generic/data/caption_001.xml b/tests/package/generic/data/caption_001.xml new file mode 100644 index 00000000..a8df7505 --- /dev/null +++ b/tests/package/generic/data/caption_001.xml @@ -0,0 +1,16 @@ + + + +
+ + + + + + Insightful caption + + + +
+ +