[pmwiki-users] FAQs and anchors and TOC

Waylan Limberg waylan at gmail.com
Thu Nov 3 12:03:17 CST 2005

Wow, I'm gone for half a day and there's all sorts of stuff to sort
through. Thanks for all the tips everyone. Now to respond where

On 03 Nov 2005 12:21:52 +1300, John Rankin <john.rankin at affinity.co.nz> wrote:
> On Thursday, 3 November 2005 10:03 AM, Waylan Limberg <waylan at gmail.com> wrote:
> >
> >The list looks like this in the browser:
> >
> >1. 1 My first question
> >2. 2 My second question...
> >
> >A quick look at the source code reveals that the following is
> >generated:
> >
> ><ol class='toc'><li>1&ensp;<a href='#toc1'>My first
> >question</a></li>...
> >
> >Obviosly, this is a problem. If I set $NumberToc = false; (which I'd
> >probably use anyway) or use (:*toc:) the problem goes away.
> I'm not sure why this problem is happening, as there is an ol.toc with
> list-style: none; to turn the browser's automatic numbering off.

Why in the world would you do that? Just use the browsers numbering.
If your not going to, don't use <ol>.
> It works fine for me and others.
> Is there a link where I can view it, with $EnableDiag = 1; set?
> The only thing I can think of is that there is a $HTMLStylesFmt['toc']
> declared elsewhere, which is overriding the toc recipe's settings.
> Run an ?action=diag and check that $HTMLStylesFmt['toc'] does
> correctly contain the following settings:
> span.anchor {
>         float: left;
>         font-size: 10px;
>         margin-left: -10px;
>         width: 10px;
>     position:relative; top:-0.1em;
>         text-align: center;
> }
> span.anchor a { text-decoration: none; }
> span.anchor a:hover { text-decoration: underline; }
> ol.toc { text-indent:-20px; list-style: none; }
> ol.toc ol.toc { text-indent:-40px; }

Oh right. In this particular install, any css generated by PmWiki is
completely ignored. We use all our own css. You see, in our view, if
it doesn't look right in a text browser with no css, then its a
problem on your end. You should never have html that requires css to
be readable. That's just bad practice IMHO.

Anyway, it is a non-issue now as I'm using <ul> instead by setting
$NumberToc = false;. Btw, thanks for making that so easy to set. If
only everything was so simple.
> >
> >The other problem is that I don't like the anchor links: #toc1,
> >#toc2?? Yuck! Wouldn't "#My_first_question" work much better? Anyone
> >know of an easy way to change that for the recipe?
> If you insert your own anchors, the script will use them, eg
> Q:[[#my_first_question]]Which way is up?

Sorry, I can't expect my non-technical users to type it all that way
every time. That will never work.
> Or are you suggesting that the script should form its anchor from
> the text of the question, replacing spaces with underscores,
> removing disallowed characters and detecting duplicates?

Yes, that is exactly what I had in mind. Except for the duplicates, it
shouldn't be to hard (actually, I already have the code - minus the
duplicates part, I just need to pass it the text of the question. That
will take some hacking of the recipe though).

> What are the reasons for not using #toc1, #toc2, ... ?

Human readable links. "To find out which way is up, simply point your
browser to http://example.com/FAQ/General#which_way_is_up" sounds so
much better that "...#toc3" If we really have to use some general
anchors, wouldn't #faq1, #faq2 make more sense? I realize this does
more than faqs, so have #heading1.. for headings, or perhaps
#section1. After all, the anchor links to the faq/heading/section, not
to the table of contents. Shouldn't the link reflect that?

Now that I've thought about it, as a quick fix, I think I'll edit the
recipe to use faq instead of toc in the anchor (seeing I am only using
this for faqs - wouldn't work if I was useing it for heading too).
Maybe if I, or someone else, finds the time, we can actually get the
questions to become the anchors. Until then, #faq1 is certainly better
than #toc1. Thanks for triggering that thought process.

Waylan Limberg
waylan at gmail.com

More information about the pmwiki-users mailing list