OK, I think I got trapped into some JS's regex voodoo or new security settings.

Anyway this seems to work in Chrome and FF , copy it into your Free Nodelet Settings and after clicking the link all modules after use or require are underlined and have an onclick event to call CPAN in a _blank window.

This is beta-code, no guaranties whatsover! =)

<!-- ================================================================= +===================== Auto-Linkify Modules in Code Sections Version 0.31.03 2022-07-23 https://perlmonks.org/?node_id=11145662 --> <script> // <!-- function show_module(module) { let url = 'https://perldoc.perl.org/' + module; window.open(url,'_blank'); } function link_modules() { let codes = document.getElementsByClassName('codetext'); let replacer = function (match, p1, p2, p3) { return p1 + '<u><span onclick="show_module(\'' + p3 +' \')">' ++ p3 + '</span></u>'; }; for (var i in codes) { if (!codes.hasOwnProperty(i)) continue; let text = codes[i]; let inner = text.innerHTML; inner = inner.replace(/((use|require)\s+)((\w+)(::\w+)*)/g, re +placer); // console.log(inner); text.innerHTML = inner; } } /* Automatic linking */ link_modules(); // comment out if you prefer button only // --> </script> <!-- Explict button in the Free Nodelet ... remove if automatic linkin +g is enough --> <button onclick='link_modules()'>link_modules() [id://11145662|v0.31.3 +]</button> <!-- END Auto-Linkify Modules in Code Sections ----------------------- +------------------ -->

to do

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

changes
updates

In reply to Re: Nodelet Hack to auto-linkify modules in code sections (works) by LanX
in thread Nodelet Hack to auto-linkify modules in code sections (well almost) by LanX

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.