It occured to me 10 seconds ago, that there wasn't any simple way to include hyperlinks inside of <code> blocks.

In particular I was trying to make a line that said "use LWP::Simple;" look like: "use LWP::Simple", but instead i got: "use [cpan://LWP::Simpl]"

Then it occured to me, that it would seriously ROCK! if code blocks automaticly hyperlinked all "use" lines to the corrisponding "cpan://" url, or if built in functions got hyperlinked to their "perldoc -f" descriptions ... maybe even operators could be linked to their descriptions from perlop.

Obviously, some code could get hard to read and cluttered if this happened automaticly ... but what if it was implimented as optional attributes for the <code> tag -- soo you could specify what exactly you wanted hyperlinked (to feature the particular pieces of code you think the reader should read up on)? Something like these maybe...

Not sure how feasible this all is ... i'm kind of reaching with that "urls" attribute idea, but i thought i'd throw it out there.

Replies are listed 'Best First'.
Re: auto-hyperlinking code?
by elusion (Curate) on Feb 16, 2003 at 13:44 UTC
(jeffa) Re: auto-hyperlinking code?
by jeffa (Bishop) on Feb 16, 2003 at 16:02 UTC
    Remember that <code> tags are transformed into <tt><pre> tag pairs, so if you only need to link one line of 'code', use <tt> by itself:

    use LWP::Simple;

    Of course, this will not show up when you click the node's d/l code, which is why i just list which modules are used in the code that i post here with the [cpan://] 'tag' before i dump the code.

    jeffa

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    B--B--B--B--B--B--B--B--
    H---H---H---H---H---H---
    (the triplet paradiddle with high-hat)
    
Re: auto-hyperlinking code?
by Zero_Flop (Pilgrim) on Feb 17, 2003 at 06:48 UTC
    One other nice feature to consider would be to have any code posted, except Obfuscation, go through Perltidy with the -html option.
    This will turn the code into html with syntax high lighting and clean up the code for readability.

    For the poster it might highlight a missing } ect.
    For the rest of us, all code would be consistant in format making reading all the different snipits easier.

    ZF
Re: auto-hyperlinking code?
by Aristotle (Chancellor) on Feb 18, 2003 at 20:36 UTC
    Having code autocolourized and linkified would be neat indeed. Consider though that Perl source is hard to parse; to do this properly would require something of the complexity of Perltidy. Also take into account that nodes are rendered at view time, not at creation time. So if you've ever run Perltidy against a moderately large piece of code you'll know why I don't see it being feasible to implement here - it would be a really heavy CPU eater on the webservers, worse than any other performance killer on the site.

    Makeshifts last the longest.