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 ----------------------- +------------------ -->
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |