Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

auto-simplify URLs

by princepawn (Parson)
on Oct 25, 2007 at 15:41 UTC ( #647210=monkdiscuss: print w/replies, xml ) Need Help??

Perlmonks tags have a unique syntax for abbreviating URLs. I get plenty of messages from people informing me that I should switch:
<a href=>here</a>
to something like :
but I cannot remember the right syntax. And I dont enjoy having to remember yet another HTML shorthand: I already have Markdown, Asciidoc, GoogleCode, MoinMoin, reStructuredText and more to confuse me.

So instead of telling us what to put there, it should be an easy parse to transform it.

Carter's compass: I know I'm on the right track when by deleting something, I'm adding functionality

Replies are listed 'Best First'.
Re: auto-simplify URLs
by ikegami (Pope) on Oct 25, 2007 at 16:01 UTC

    but I cannot remember the right syntax

    You have it spot on. They're all of the format [scheme://optional_identifier|optional_alt_text].

    Linking syntax is available in What shortcuts can I use for linking to other information? in the PerlMonks FAQ (accessed via the "Need Help??" in the top right corner).

    And I dont enjoy having to remember yet another HTML shorthand

    Then don't use it. All we ask is that you don't link to a PerlMonks specific domain. (e.g. <a href="/?node_id=646560">here</a> would be fine.) People use various domains to read this site (,,,,,, etc). Following a link to a different domain causes the user to get logged out.

    The advantage of [id://XXXXXX] is that it fetches the node title so you don't have to look it up yourself or use something lame like "here".

    By the way, what you posted was invalid HTML. It's only safe to omit the quotes around attribute values when the value matches /^[a-zA-Z0-9-._:]*\z/.

Re: auto-simplify URLs
by holli (Abbot) on Oct 25, 2007 at 16:32 UTC
Re: auto-simplify URLs
by eric256 (Parson) on Oct 25, 2007 at 16:00 UTC

    [id:alt] is pretty simple (simpler to me than remembering ?node_id=), but if you want such a change you should include the code that would do it.

    P.S. you put this entire post in your signature block so different peoples css will do different things to it. Mine makes it small pink and italic which makes it hard to read! lol

    Eric Hodges
Re: auto-simplify URLs
by SFLEX (Chaplain) on Oct 30, 2007 at 17:48 UTC
    just messing around hehe.
    but this could be usefull some day.
    my $string = '<a href=\'">here +</a>'; $string =~ s{<a href=(?:\"|\')*(?:\w+\://)*(?:www.)*perlmonks\.org/\?n +ode_id=(\d+)(?:\"|\')*>([a-zA-Z\d\s\:\.\/\_\-]+)</a>}{[id://$1|$2]}gs +;
A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: monkdiscuss [id://647210]
Approved by kyle
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2021-03-02 04:25 GMT
Find Nodes?
    Voting Booth?
    My favorite kind of desktop background is:

    Results (36 votes). Check out past polls.