Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

how to do perldoc links with special characters

by Lotus1 (Curate)
on Apr 20, 2013 at 16:32 UTC ( #1029658=monkdiscuss: print w/replies, xml ) Need Help??

When I use perlmonks shortcuts to the perldocs it goes to the page but not down to the anchor location on the page like the full link does. The apostrophe and the percent symbol are being replaced with things like '%27' and '%25'.

If I link with the full url like this it works. http://perldoc.perl.org/perlfaq5.html#How-can-I-use-Perl's--i-option-from-within-a-program%3f

However, this goes to the page but not the anchor. The text below shows what I have in the link at the word 'this'.

[doc://perlfaq5#How-can-I-use-Perl's--i-option-from-within-a-program%3f|this]

Update: Interesting; the full link doesn't go to the anchor with an actual question mark in it. http://perldoc.perl.org/perlfaq5.html#How-can-I-use-Perl's--i-option-from-within-a-program?

Replies are listed 'Best First'.
Re: how to do perldoc links with special characters
by LanX (Chancellor) on Apr 20, 2013 at 16:42 UTC
    This works cause I translated the '?' back.

    [doc://perlfaq5#How-can-I-use-Perl's--i-option-from-within-a-program?|this]

    Don't know if there is any ambiguity, otherwise I would pray to the gods humbly asking for a fix! =)

    Cheers Rolf

    ( addicted to the Perl Programming Language)

      This works cause I translated the '?' back.

      Actually it doesn't. It still goes to the page but not the anchor.

      Update: I am using IE8 but I went ahead and tested your link on Chrome. So the '?' part is solved but the question of the apostrophe remains.

        Well works for me in FF!

        Which browser do you use?

        Maybe it's a FF DWIM feature. I'm too lazy to look up the specs now...

        Cheers Rolf

        ( addicted to the Perl Programming Language)

        That link works for me using firefox 20 on Linux. Maybe a browser/OS thing ?

Re: how to do perldoc links with special characters (perlmonks faq2doclink.pl)
by Anonymous Monk on Apr 20, 2013 at 17:02 UTC
     [doc://perlfaq5#How-can-I-use-Perl's--i-option-from-within-a-program?] How can I use Perl's i option from within a program?
    die fudge(q{http://perldoc.perl.org/perlfaq5.html#How-can-I-use-Perl%2 +7s--i-option-from-within-a-program%3f}); sub fudge { local $_ = shift ; return $_ if not m{\Qhttp://perldoc.perl.org/\E|\Qdoc://\E}si; # d +on't deal return $_ if m{\Qhttp://perldoc.perl.org/5.\E}si; # don't deal s/^\[//; s/\]$//; my $right = ""; s{\|(.*)}{} and $right.= $1; s{^\Qhref://\E}{}si; s{^\Qhttp://perldoc.perl.org/\E}{}si; s{^\Qdoc://\E}{}si; s{\Q.html\E}{}si; my( $left, $anchor ) = split '#', $_, 2; $left =~ s{/}{::}g; if( m{%[a-zA-Z0-9]{2}}si ){ $_ = unescape( $anchor ) ; s/ /-/; $anchor = $_; } if( $anchor ){ $anchor =~ s{\[}{%5b}g; $anchor =~ s{\]}{%5d}g; $left .= '#' . $anchor ; } if( length $right ){ $right =~ s{\[}{[}g; $right =~ s{\]}{]}g; return "[doc://$left|$right]" ; } return "[doc://$left]"; } sub Main { for my $file ( ( glob 'perlfaq*.html' ), (glob 'perlpod*html' ), ( +'perlintro.html', 'perlop.html') ){ ( my $name = $file ) =~ s/\.html//; #~ dd [ $file => $name ]; my $tree = HTML::TreeBuilder->new; $tree->parse_file( $file ); $tree->look_down( _tag => "a", name => qr/./, sub { my $question = $_[0]->attr('name'); return if $question =~ m{ ^\s* (?: AUTHOR.AND.COPYRIGHT | NAME | DESCRIPTION | CREDITS | THE.QUESTIONS | TABLE.OF.CONTENTS ) \s*$}xs; print fudge("[doc://$name#$question]"), "\n"; 0; }, ); } }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: monkdiscuss [id://1029658]
Approved by LanX
help
Chatterbox?
[Corion]: I feel that there is a talk somewhere in there, either about the structure and parts, or how I used several parts to get a complete whole.
[Corion]: Maybe I can still find something that is compatible with handlebars.js (which has JS precompilation) but allows for two-way data binding (which is great for the UI)
[Corion]: Two-way data binding means that if you change something in a text box, the corresponding variable in your Javascript gets updated immediately as well, and if you then change the variable, the corresponding text box also gets updated
[Corion]: That is a horrible approach that was also taken by Access, but if you have hooks that prevent automatic saving to the database, it is incredibly handy

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2017-03-30 07:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (355 votes). Check out past polls.