[pmwiki-users] Automatically add anchors to heading tags? pmwiki-users Digest, Vol 25, Issue 50

John Rankin john.rankin at affinity.co.nz
Wed Jul 25 17:34:35 CDT 2007


On Monday, 23 July 2007 2:14 PM, pmwiki-users-request at pmichaud.com wrote:
<snip>
>   9. Re: Automatically add anchors to heading tags?
>      (christian.ridderstrom at gmail.com)

>Message: 9
>
>>>> Is there a simple way to configure pmWiki such that all headings (H1, 
>>>> H2, etc) are automatically generated with anchor tags so people can 
>>>> link directly to a section or subsection?  (I believe MediaWiki has 
>>>> this functionality by default.)
>>>
>>> Now officially a requested feature.  Vote / comment here:
>>>
>>>    http://www.pmwiki.org/wiki/PITS/00955
>>
>> I left some questions on the PITS page, but essentially:
>>
>> * What if the heading contains other markups, such as links
>>  or wikistyles? Do we have to be smart enough to strip those
>>  somehow before producing the heading anchor?
>>
>> * If a heading already has an anchor in it, should PmWiki
>>  still generate yet another anchor for the heading?
>>
>> * Do we convert all punctuation that appears in the heading,
>>  or just parens?
>
>I tried finding the recipe 'visible anchors' that I thought I'd uploaded 
>to the cookbook a long time ago (pmwiki v1), but maybe it got incorporated 
>into John's PageToC.

It did; the (:toc anchors=visible:) option.
>
>I don't think it's a great idea to use the heading text to generate the 
>label. My recommendation is to enumerate them instead. If we worry that an 
>enumerated heading becomes incorrect if a heading is inserted before it, 
>remember that a similar thing happens if you change the heading
>text.

Turning heading text into an anchor guaranteed to be valid would also need
a bit of care; eg 

!!!Christian Ridderström

would need to turn the ö into something else, I think. [[#h_numbers]]
would be easier *and* safer.
 
<snip>
-- 
JR
--
John Rankin

       \_      
        \)   
         \,\__/7
         /    /
        (   c'
         \  / 
     /,  /_/  
    |  & *   Wellington
    )  /    
   /  /,    
  /  (    
 |   /      
 \__/       
   V        






More information about the pmwiki-users mailing list