Skip to content
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
12 changes: 12 additions & 0 deletions phpdotnet/phd/Package/PHP/XHTML.php
Original file line number Diff line number Diff line change
Expand Up @@ -827,12 +827,24 @@ public function format_classsynopsis_methodsynopsis_methodname_text($value, $tag

public function format_function($open, $tag, $attrs, $props) {
if ($open) {
if (str_contains($props["innerXml"], '<replaceable')) {
$this->pushRole("function_replaceable");
}
return '<span class="' . $tag . '">';
}

if ($this->getRole() === "function_replaceable") {
$this->popRole();
}

return "</span>";
}

public function format_function_text($value, $tag, $display_value = null) {
if ($this->getRole() === "function_replaceable") {
return $this->TEXT($value);
}

static $non_functions = array(
"echo" => true, "print" => true,
"include" => true, "include_once" => true,
Expand Down
2 changes: 1 addition & 1 deletion phpdotnet/phd/Render.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function execute(Reader $r) { /* {{{ */
$r->name === "type" ||
$r->name === "classsynopsis" ||
$r->name === "qandaset" ||
in_array($r->name, ["methodsynopsis", "constructorsynopsis", "destructorsynopsis", "constant"], true)
in_array($r->name, ["methodsynopsis", "constructorsynopsis", "destructorsynopsis", "constant", "function"], true)
)
) {
$innerXml = $r->readInnerXml();
Expand Down
18 changes: 18 additions & 0 deletions tests/package/php/data/function_replaceable_rendering.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<chapter xml:id="function_replaceable_rendering" xmlns="http://docbook.org/ns/docbook">

<section>
<para>1. Function with replaceable</para>
<para>
<function>xml_set_<replaceable>*</replaceable></function>
</para>
</section>

<section>
<para>2. Normal function (no replaceable)</para>
<para>
<function>strlen</function>
</para>
</section>

</chapter>
38 changes: 38 additions & 0 deletions tests/package/php/function_replaceable_rendering.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
--TEST--
Function with replaceable rendering
--FILE--
<?php
namespace phpdotnet\phd;

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

$xmlFile = __DIR__ . "/data/function_replaceable_rendering.xml";

$config->xmlFile = $xmlFile;

$format = new TestPHPChunkedXHTML($config, $outputHandler);

$render = new TestRender(new Reader($outputHandler), $config, $format);

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

<div class="section">
<p class="para">1. Function with replaceable</p>
<p class="para">
<span class="function">xml_set_<span class="replaceable">*</span></span>
</p>
</div>

<div class="section">
<p class="para">2. Normal function (no replaceable)</p>
<p class="para">
<span class="function"><strong>strlen()</strong></span>
</p>
</div>

</div>