Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^2: TOCs and deeplinks for our house rules

by RonW (Parson)
on Nov 09, 2017 at 01:01 UTC ( #1202990=note: print w/replies, xml ) Need Help??


in reply to Re: TOCs and deeplinks for our house rules
in thread TOCs and deeplinks for our house rules

Also, when I created "Markup" originally, the various <Hn> tags were for formatting only, without due regard to nesting

That was the problem I ran into. I chose to index any <Hn> with out nesting, using the contained text for the TOC entries. I also provided options to exclude any level of <Hn> (the default being to index all). The results were acceptable to those who used my program. (It also encouraged some to go back and improve their "section titles".)

For a more general solution (for new pages or significantly re-worked pages), perhaps PM markup could include a toc attribute to indicate elements to be in the TOC with an option value to specify nesting level and/or TOC text.

Examples:

<div toc>This text will appear in the TOC at $current_nesting level</div>

<div toc="++">This text will appear in the TOC at $current_nesting++ level</div>

<div toc="--">Likewise, this at at $current_nesting-- level</div>

<h3 toc="2">This text will be at TOC level 2 despite being in an H3 element</h3>

<p toc="4,This text, after first comma, will appear in the TOC at level 4">Text not appearing in the TOC</p>

Replies are listed 'Best First'.
Re^3: TOCs and deeplinks for our house rules
by LanX (Archbishop) on Nov 09, 2017 at 13:12 UTC
    Adding new markup is complicated*, I'd rather prefer a KISS approach, not least because of backwards compatibility.

    The only possible targets in PM is <a name="anchor-name"> so adding a parser for a magic href #toc or #notoc would already do, i.e.

    <a href="#toc" name="anchor-name">

    A new markup <toc> should have a reasonable default behaviour

    • nesting all H tags, unless excluded by linebreak
    • adding all <a name=""> tags under the last H level
    Any "filtering" features should be discussed after implementing and testing the first phase.

    In a side note: There is a tendency to mangle the concept of "keywords" into this discussion.

    IMHO that's mostly unrelated, first things first.

    FWIW PM has already a keyword nodelet, but lacks a search engine for it...

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Je suis Charlie!

    *) actually I can't even locate the corresponding code, I'm volunteering to implement it if possible.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1202990]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2019-05-22 16:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you enjoy 3D movies?



    Results (140 votes). Check out past polls.

    Notices?
    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!