in reply to A Tagcloud For Cory Doctorow

minor suggestion, the # Parse notes file loop, I would write as
# Parse notes file { local $/ = "\n\n"; # Double-newline separates input records while (<>) { my $this_line = ""; # escape everything before @tags $this_line = HTML::Entities::encode("$1") . "$2" if /^([^@]*)(.*)/s; # url encode and html escape tags $this_line =~ s| \@( # capture to $1 [^\s@]+ # more flexible than \w+ )\b | push @{$lines{"$1"}}, \$this_line; # maybe rework following using URI my $oneEH = HTML::Entities::encode($1); my $oneE = CGI::escapeHTML(CGI::escape($1)); qq~<a href="$url$oneE">$oneEH</a>~; |gex; push @all_notes, $this_line; } }

Replies are listed 'Best First'.
Re^2: A Tagcloud For Cory Doctorow
by McD (Chaplain) on Aug 28, 2008 at 13:03 UTC
    Hmmm.
    # escape everything before @tags $this_line = HTML::Entities::encode("$1") . "$2" if /^([^@]*)(.*)/s;
    ...only works if you assume that '@'-signs are exclusively found in tags, not the body of the notes.

    I like the one-pass s///g for both building up %lines and linkifying tags. I used split and pop because everyone in the BoingBoing comments was saying "Use a regex! This is perfect for regexes!"

    I loves me a good regex as much as the next monk, but there's a tendency to want to use them for everything once you grasp the power of 'em. I decided to use something simpler in the note parsing deliberately to counter that.

    I still managed to have some regex fun in the search string highlighting code. :-)

Re^2: A Tagcloud For Cory Doctorow
by Anonymous Monk on Jun 18, 2009 at 22:51 UTC
    Hi, I'm an end user. I'm located near the very, very end. I do legal research (working on a JD) and this would be EXACTLY what I need. The problem is that I don't understand how I would use this code to do what I need. At the risk of sounding incompetent (which I am), how would I use this on a windows (XP) machine as an executable with a nice GUI interface?