[pmwiki-devel] Using "!#anchor heading" markup
John Rankin
john.rankin at affinity.co.nz
Thu Jun 4 02:57:13 PDT 2026
On 04/06/2026 5:34 pm, Petko Yotov wrote:
> On 04/06/2026 03:21, John Rankin wrote:
>
>> 1. For duplicate and not duplicate visible anchors, pagetoc reveals
>> the anchor name through a title='#anchor' attribute. For duplicate
>> visible anchors, pagetoc produces:
>>
>>> "<span style='color: red;' title='#$id'>$DuplicateAnchor</span>"
>>
>> $VisibleAnchorLinks=true adds <a href='#$id'> … </a> to the <span>.
>>
>> I wonder of the core ought to produce a similar output, with the
>> default value of $DuplicateAnchor as ''. Those who prefer a visible
>> sign of a duplicate can set $DuplicateAnchor to a value of their
>> choice.
>
> Wouldn't it be better if the duplicate visible anchor linked to the
> existing anchor with the same identifier?
Yes it would. I wrote it the way it is for backwards compatibility and
consistency. The original user wanted Visible Anchors as Links to be a
true/false option. If true, all visible anchors are links to the named
anchor; if false, none is. I carried the logic into treatment of visible
duplicate idNames.
I agree the core can just link to the existing anchor.
>
> I changed it to render like this:
>
> <a title="#anchor Duplicate anchor" href="#anchor"
> class="visible-anchor">#</a>
>
> Instead of a separate global variable $DuplicateAnchor, duplicate
> anchors are styled in pmwiki-core.css, and can be overridden in
> pub/css/local.css:
>
> a.visible-anchor:not([id]) {
> background-color: var(--pmc-yellow2);
> }
>
> See/test: https://pmwiki.org/t/VisibleAnchors
That is quite subtle to my eyesight (the world gets yellower with age;
YMMV). A more flexible option could be to retain $VisibleAnchor and
$DuplicateAnchor, and SDV($DuplicateAnchor, $VisibleAnchor); in the
core. Those who wish to, can over-ride the default.
It's looking good. I may have to update the recipe again once the
changes to pmwiki are finalised, to avoid markup rule conflicts.
J
More information about the pmwiki-devel
mailing list