Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

auto-simplify URLs

by princepawn (Parson)
on Oct 25, 2007 at 15:41 UTC ( [id://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=http://perlmonks.org/?node_id=646560>here</a>
to something like :
[id://646560|here]
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 (Patriarch) 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 (www.perlmonk.org, perlmonk.org, www.perlmonks.com, perlmonks.com, www.perlmonks.net, perlmonks.net, 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=\'http://www.perlmonks.org/?node_id=646560">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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (3)
As of 2024-04-20 11:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found