Hi, I tried to make an external link to a url with 1 apostrophe in it at OT : Re: "Welcome to my ~/bin" class materials now online. I tried \'ing the apostrphe but no luck. Can this be done, what is the trick?

A sample that breaks linking:

<a href=http://www.nationmaster.com/encyclopedia/Formulation-of-Maxwell's-equations-in-special-relativity> sample link


I'm not really a human, but I play one on earth. Cogito ergo sum a bum
  • Comment on single apostrophe's ruining external linking

Replies are listed 'Best First'.
Re: single apostrophe's ruining external linking
by merlyn (Sage) on Dec 31, 2007 at 20:16 UTC
    That's not legal HTML. First, get into the habit of quoting your attributes, so that would be something like <a href=" ... ">. Then, recognize what characters need to be HTML-entitized. And actually, in that case, since single quote in a double-quote attribute value is safe, you might not need to change anything.

    Oh, and this isn't Perl related at all. It's an HTML issue, so check sites like http://htmlhelp.com and such.

Re: single apostrophe's ruining external linking (match)
by tye (Sage) on Dec 31, 2007 at 20:27 UTC

    Then don't write invalid HTML.

    <a href="http://www.nationmaster.com/encyclopedia/Formulation-of-Maxwe +ll's-equations-in-special-relativity">this link</a>

    produces this link.

    [http://www.nationmaster.com/encyclopedia/Formulation-of-Maxwell's-equ +ations-in-special-relativity|that link]

    produces that link.

    Unmatched quotes in HTML attributes are currently rejected as too troublesome to try to DWYM.

    Note that either URL-escaping or HTML-escaping works in HTML links (as per the standard) so <a href="http://www.google.com/search?q=&quot;vu do%22">"vu do"</a> produces "vu do". Neither type of escaping currently work in [http://...] links but that is likely to change eventually (update: oh, URL escaping works in this case but not in other link types; HTML escaping doesn't work).

    - tye        

Re: single apostrophe's ruining external linking
by davis (Vicar) on Dec 31, 2007 at 20:16 UTC

    Hiya,

    Basically, use square brackets to create links on PerlMonks. Hopefully this link should work exactly as I expect; it was produced by this code:

    [http://www.nationmaster.com/encyclopedia/Formulation-of-Maxwell's-equ +ations-in-special-relativity|this link]
    The pipe symbol separates the link target (your "href" bit) and the link name. So, to summarize, it's not the apostrophe, it's the linking syntax. Use the "preview" option.

    Incidentally (because you mentioned apostrophes), you don't pluralize "apostrophe" by putting "apostrophe-s" on the end. The correct plural is "apostrophes".... Yes, I'm way, way too twitchy about that, and it's nothing to do with being stuck in on New Year's Eve by my lonesome... *sob*.

    Happy New Year!


    davis
    Kids, you tried your hardest, and you failed miserably. The lesson is: Never try.
      In the OP's title, "apostrophe's" doesn't mean plural, but "apostrophe is".

        Verily, d'oh.
        That's the kind of boot in the backside lonely drunkards like me need. Nice one :)


        davis
        Kids, you tried your hardest, and you failed miserably. The lesson is: Never try.
        shmem thanks for sticking up for me. :-) but now that I think about it, is that a legal contraction? Like davis, I've been drinking. :-)

        I'm not really a human, but I play one on earth. Cogito ergo sum a bum
Re: single apostrophe's ruining external linking
by shmem (Chancellor) on Dec 31, 2007 at 20:18 UTC
    Try sprintf "%%%02x", ord "'" instead:
    [http://www.nationmaster.com/encyclopedia/Formulation-of-Maxwell%27s-e +quations-in-special-relativity|Maxwell's equation]
    Maxwell's equation

    --shmem

    _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                  /\_¯/(q    /
    ----------------------------  \__(m.====·.(_("always off the crowd"))."·
    ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
Re: single apostrophe's ruining external linking
by zentara (Cardinal) on Jan 01, 2008 at 14:06 UTC
    Thanks for edifying me everyone ... I definitely need to brush up on legal html (a New Years resolution I will probably never keep :-) ) , and to get into the habit of double quoting the link.

    I'm not really a human, but I play one on earth. Cogito ergo sum a bum
      Careful. The saying goes, that "the road to hell is paved with good resolutions"... ;)

      --shmem

      _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                    /\_¯/(q    /
      ----------------------------  \__(m.====·.(_("always off the crowd"))."·
      ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
        the road to hell is paved with good resolutions

        Now that I'm done with my New Year's drinking........

        Does it then follow that

        the road to heaven is paved with bad resolutions (intentions)?? :-) Hope so.


        I'm not really a human, but I play one on earth. Cogito ergo sum a bum
Re: single apostrophe's ruining external linking
by Anonymous Monk on Jan 01, 2008 at 05:56 UTC
    /me hands zentara a band aid for his buttocks :D