[pmwiki-devel] Update Re: Using "!#anchor heading" markup

John Rankin john.rankin at affinity.co.nz
Wed Jun 3 18:21:17 PDT 2026


Petko, thanks, that looks very good to me. I have a couple of comments 
for you to consider, and a question.

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.

2. The original user of pagetoc wanted visible anchors to be 
unobtrusive, leading to the choice of § (set in $VisibleAnchor; nitram's 
site uses ♦). Perhaps the core ought to let administrators choose 
between displaying #anchor or # with #anchor as a tool tip.

3. You wrote, "For including text sections like include Page#anchor, the 
same (ie !!##?name) will be replaced (ie with !![[##?name]]) in the 
TextSection function before extracting the section." Does this mean 
nitram's use of the diff2 recipe will work with !!##anchor as well as 
!![[##anchor]], or will the recipe need modifying?

Thanks again.

JR

On 03/06/2026 10:41 pm, Petko Yotov wrote:
> Thank you JR for your input.
>
> CamelCase words in WikiStyles produced WikiWord links if these were 
> enabled and broke the WikiStyle. This was an omission or a known 
> limitation, should be fixed for 2.6.1.
>
> Agreed with your points about a separate anchor tag for !!#anchor 
> rather than id attribute. An additional reason is for people to be 
> able to right-click on the visible anchor and select "Copy link", it 
> should link to itself.
>
> Consequently:
>
> - For rendering wiki pages, !!##?name will be replaced with 
> !![[##?name]] then left to the 2 other markup rules to handle (anchor, 
> heading).
>
> - For including text sections like include Page#anchor, the same will 
> be replaced in the TextSection function before extracting the section.
>
> I added to the core the [[##anchor]] markup to produce a visible anchor:
>
>   <a id="anchor" href="#anchor" class="visible-anchor">#anchor</a>
>
> You can override this either by inserting a markup rule before '[[#' 
> that consumes the visible anchor markups, or by redefining '[[#'.
>
> New variable $VisibleAnchorPrefix default '#'. This seems more 
> intuitive than '§' since the link is also #anchor, but can be 
> redefined in config.php if needed.
>
> New class name 'visible-anchor' for these, with some styles:
>
>   font-size: .8rem;
>   opacity: .67;
>
> People can override or complement the styles and the prefix character 
> in local configuration.
>
> Visible anchors are detected in the core table of contents and used in 
> the toc links, but are not visible in the toc links. That means if a 
> heading is written as:
>
> !!##anchor Heading
>
> - the heading text will contain "#anchor Heading"
> - the table of contents will link to Page#anchor, but the link text 
> will contain "Heading".
>
> Duplicate anchors are removed rather than appearing with a different 
> prefix character. The earliest instance among [[#anchor]], 
> [[##anchor]], !!#anchor, !!##anchor, is rendered, the others are removed.
>
> If a writer expects a visible anchor that does not show, this ought to 
> be a sufficient indication that the anchor was removed. :-)
>
> Petko
> <snip>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.pmichaud.com/pipermail/pmwiki-devel/attachments/20260604/4792576c/attachment.html>


More information about the pmwiki-devel mailing list