Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Bookmarklet to show deeplinks in perldoc.perl.org

by LanX (Archbishop)
on Jun 15, 2019 at 17:22 UTC ( #11101409=monkdiscuss: print w/replies, xml ) Need Help??

In a reaction to link to perl documentation

This works in the JS code works inside the console in FF and Chrome and will show hidden html-anchors ready to be cut&paste with PM markup

javascript:(function(){ var path = location.pathname.replace(/^\//,"").replace(/\.html$/," +"); var as =document.getElementsByTagName("a"); for (i in as) { var l = as[i]; if (l.id && l.classList.length == 0 ){ var dlink = path + "#" + l.id; l.innerHTML = "<b>" + path + "#[doc://"+dlink+"]</b><br>"; + l.href = "#" + l.id } } })()

The bold parts are generated by JS

perlintro#[doc://perlintro#Perl-variable-types]

Perl variable types

Perl has three main variable types: scalars, arrays, and hashes.

perlintro#[doc://perlintro#Scalars]

Scalars

A scalar represents a single value:

you can C&P the links then into a PM post, and they'll render as:

I still have problems putting it into a bookmark getting strange JS errors about keyword "var".

NB: This is far from being bug-free perldoc.perl.org and PM markup have their own idiosyncrasies! But it's a start.

Feel free to post better versions!!!

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery FootballPerl is like chess, only without the dice alert("LanX")

Replies are listed 'Best First'.
Re: Bookmarklet to show deeplinks in perldoc.perl.org
by choroba (Bishop) on Jun 15, 2019 at 17:36 UTC
    Have you tried expoiting perldoc.pl instead?

    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
      not sure what your point is, PM doesn't have a doc-markup for perldoc.pl yet

      you are free to adapt the BML to the format in perldoc.pl to show all hidden deeplinks.

      update

      OK I see that perldoc.pl is showing a # symbol left to every deeplink on mouse-over. Clicking on the # will jump to the deeplink and one can copy it from the url-bar

      example: https://perldoc.pl/perlfunc.html#open-FILEHANDLE,MODE,EXPR,LIST

      Nice!

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

      A year ago, we had some discussion about switching to perldoc.pl. It was left unresolved. I want to know what the arguments are on both sides. It was claimed that perldoc.perl.org was moribund, yet I don't see any evidence that that's true. If I can be convinced that perldoc.pl is a better choice for our (PM) needs, I'll switch it.

      I reckon we are the only monastery ever to have a dungeon stuffed with 16,000 zombies.
        See for example Reddit or GitHub for some discussions. It's probably too early to judge the new beta version of perldoc.org. perldoc.pl has been, on the other hand, mature for some time already.

        map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
        > If I can be convinced that perldoc.pl is a better choice for our (PM) needs, I'll switch it.

        some thoughts:

        • If switching means that old doc-links will refer to perldoc.pl I'm not sure if URL paths are consistent.
        • We used to have a [metacpan:://...] alternative to [cpan://..] . ( [docpl://..] might be an option but I'm not too convinced.)
        • you may add a user setting such that users like Choroba can choose jumping perldoc.pl for each ... link

        Personally I prefer direct auto-linking of bare http-URLs. My wikisyntax does this.

        > It was claimed that perldoc.perl.org was moribund,

        I only had minor issues with perldoc.perl.org. (like the need to scroll up after a deeplink, because the first lines where covered by the navbar.)

        And like already mentioned in the OP are possible deep-targets not easily accessible.

        What I have trouble to understand is why they suddenly replaced it with a worse beta-version of something else.

        Cheers Rolf
        (addicted to the Perl Programming Language :)
        Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

        At the time, the last evidence of maintenance was adding Perl 5.26 at the end of 2017, and there was no evidence of anyone fixing bugs since 2011 (several of which have yet to be fixed so far, and many new ones now added, but we'll see what the next iteration brings). The revamp work was entirely unknown aside from vague promises of "an update" until last week; so until then I would have agreed with "moribund", and indeed that was the motivation for perldoc.pl, but that is clearly no longer apt.
Re: Bookmarklet to show deeplinks in perldoc.perl.org
by LanX (Archbishop) on Jun 15, 2019 at 18:35 UTC
    > I still have problems putting it into a bookmark getting strange JS errors about keyword "var".

    Fixed, code works now in bookmark! :)

    Had to add a semicolon, which is optional in multi liners ...

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

Re: Bookmarklet to show deeplinks in perldoc.perl.org
by LanX (Archbishop) on Jun 24, 2019 at 12:43 UTC
    Improved version

    Just add it to your bookmarks. (by dragging or rightclick)

    Then try it on perldoc.perl.org (like perlintro)

    BML perldoc anchors

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: monkdiscuss [id://11101409]
Approved by Athanasius
Front-paged by Athanasius
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2019-09-21 02:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The room is dark, and your next move is ...












    Results (269 votes). Check out past polls.

    Notices?