Skip to content

Fix GH-80: Trim whitespace in tag content before link resolution#237

Open
lacatoire wants to merge 1 commit intophp:masterfrom
lacatoire:fix/gh-80-whitespace-in-tag-names
Open

Fix GH-80: Trim whitespace in tag content before link resolution#237
lacatoire wants to merge 1 commit intophp:masterfrom
lacatoire:fix/gh-80-whitespace-in-tag-names

Conversation

@lacatoire
Copy link
Contributor

Summary

  • Adds trim() to all text handler functions that resolve links (format_function_text, format_varname_text, format_classname_text, format_type_text, format_enumidentifier_text, and classsynopsis variants) in both PHP and PEAR XHTML packages
  • When <function>, <methodname>, <classname>, <varname>, <type>, or <enumidentifier> tags contain leading/trailing whitespace (e.g. from line breaks in translated documentation), link resolution was failing because the lookup key included the whitespace
  • Adds a test covering <function>, <methodname>, <classname>, and <varname> tags with whitespace

Fixes #80

When <function>, <methodname>, <classname>, <varname>, <type>, or
<enumidentifier> tags contain leading/trailing whitespace (e.g. from
line breaks in translated documentation), link resolution fails because
the lookup key includes the whitespace.

Add trim() to all text handler functions that resolve links, ensuring
whitespace does not break cross-reference linking.
<div class="section">
<p class="para">4. Varname with leading/trailing whitespace</p>
<p class="para">
<var class="varname"><a href="reserved.variables.server.html" class="classname">_SERVER</a></var>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a pre-existing issue, but this seems weird?

Suggested change
<var class="varname"><a href="reserved.variables.server.html" class="classname">_SERVER</a></var>
<var class="varname"><a href="reserved.variables.server.html" class="varname">_SERVER</a></var>


public function format_function_text($value)
{
$value = trim($value);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better if the XML source didn't contain those whitespaces.
So maybe add a global helper function that trims and checks if the trimmed and original value is the same, if not emit a rendering warning. So that in the long term we can fix the XML sources rather than handling this on the rendering side :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Be more lax in function/methodnames tag in regards to whitespace

2 participants