01388: The Link to the TrailIndexPage#start#end in a trail is marked as not allowed by W3C-Validator
Description: The TrailIndexPage#start#end-part of the trail-markup appears in a Link to the TrailIndexPage. But such a link with two anchors in it is marked as not allowed by the W3C-Validator. If one omits the #end-part, the trail is broken. That happens for example in the trail in the documentation index of PmWiki.
Is it possible to cut off any second anchor from $trailname if present, before $trailname is inserted in the return-value in functions MakeTrailStop, MakeTrailStopB and MakeTrailPath in trails.php? It then looks like TrailIndexPage#start or TrailIndexPage#. Both is ok for the validator.
The following seems to work fine:
if (preg_match('/(#[^#]*)(#[^|\])+]*)/',$trailname, $m) && $m != '') $trailname = str_replace($m,'',$trailname);
Maybe, there is a more elegant way. I assumed, that there are always two anchors, unless the author made a mistake. So the replacement takes place only when a second anchor was found.
Because the anchors #trailstart and #trailend are positioned in a paragraph near the top of the page in the output (why?), where I didn't set them in the markup, it doesn't seem to be necessary to bother about the first anchor :-|
If so, any anchor could be removed so the pure pagename is left over (probably the easiest way)
, though the link then points to the top of the page, what might not be intended in some cases.
June 04, 2016, at 08:05 AM
I guessed, there is a better place to handle it. Thank you, Petko. ~mfwolff