Thanks so much for sharing this back with the list, Balazs. On Fri, Oct 23, 2009 at 2:19 AM, Balazs Koren <[email protected]>wrote:
> > Hi all, > > I just googled a bit because links ending with /another dir etc. were > not really recognized with the simple regexp. > I found the following, but thanks again to pointing me for looking for > a regexp: http://codesnippets.joyent.com/posts/show/2104 > > So the function in my theme.php is now: > > public function filter_comment_content_out($content){ > $pattern = > "@\b(https?://)?(([0-9a-zA-Z_!~*'().&=+$%-]+:)?[0-9a-zA-Z_!~*'().&=+$%-]+\@)?(([0-9]{1,3}\.){3}[0-9]{1,3}|([0-9a-zA-Z_!~*'()-]+\.)*([0-9a-zA-Z][0-9a-zA-Z-]{0,61})?[0-9a-zA-Z]\.[a-zA-Z]{2,6})(:[0-9]{1,4})?((/[0-9a-zA-Z_!~*'().;?:\@&=+$,%#-]+)*/?)@"; > return preg_replace($pattern, '<a rel="external" href="\0">\0</a>', > $content); > > It converts any url to html link. Maybe someone else can use it too. > > Balazs > > On Thu, Oct 8, 2009 at 9:41 PM, Balazs Koren <[email protected]> > wrote: > > Thank you both for your help. It works. > > > > Balazs > > > > On Wed, Oct 7, 2009 at 11:48 AM, Ali B. <[email protected]> wrote: > >> Indeed. Using the square brackets is what messes things up as it will > match > >> any of the enclosed characters. I apologize. > >> Use what drzax suggest. Thanks Simon. > >> > >> > >> On Wed, Oct 7, 2009 at 9:31 AM, drzax <[email protected]> wrote: > >>> > >>> The regex just isn't quite right. Try this: > >>> > >>> public function filter_comment_content_out($co ntent){ > >>> return preg_replace( '(https?:\/\/\S*)', '<a href="$0" title="Visit > >>> $0">$0</a>', $content ); > >>> > >>> I've also added a little something so it will recognise http:// > >>> > >>> S. > >>> > >>> > >>> On Oct 7, 7:47 am, Balazs Koren <[email protected]> wrote: > >>> > Hey Ali, > >>> > > >>> > thanks, but it does something creepy. I understand it should work, > but > >>> > not really that hapends: > >>> > > >>> > http://screen.kobak.org/8d2c910f.png - original > >>> > commentshttp://screen.kobak.org/af046ce3.png - same with the filter > >>> > activatedhttp://screen.kobak.org/fe6387e9.png - original > >>> > sourcehttp://screen.kobak.org/e7e637c8.png - source with the filter. > >>> > > >>> > The filter is somehow activated even if there is no http:// . Is > there > >>> > a failure in my side? > >>> > > >>> > My theme.php :http://pastie.org/642080 > >>> > > >>> > I pasted the code after line 53. > >>> > > >>> > Thanks for an further advice. > >>> > > >>> > Balazs > >>> > > >>> > > >>> > > >>> > On Tue, Oct 6, 2009 at 1:34 PM, Ali B. <[email protected]> wrote: > >>> > > Hey Balazs, > >>> > > >>> > > Add the following to your active theme's theme.php, within the > theme > >>> > > class > >>> > > definition > >>> > > >>> > > public function filter_comment_content_out($content){ > >>> > > return preg_replace( '([http:\/\/]\S*)', '<a href="$0" > >>> > > title="Visit > >>> > > $0">$0</a>', $content ); > >>> > > } > >>> > > >>> > > URLs that start with "http://" will be converted to an anchor > pointing > >>> > > to > >>> > > that URL. I hope it's what you need. > >>> > > >>> > > -- > >>> > > Ali > >>> > >http://awhitebox.com > >>> > > >>> > > On Tue, Oct 6, 2009 at 8:07 PM, Balazs Koren < > [email protected]> > >>> > > wrote: > >>> > > >>> > >> Thanks Markdown is cool, but the problem isn't myself, but the > >>> > >> commenters, who post a link, and it won't display clickable, what > >>> > >> they > >>> > >> are used to. It's not a great problem, but would be nice, if there > is > >>> > >> a solution for it. > >>> > > >>> > >> Balazs > >>> > > >>> > >> On Tue, Oct 6, 2009 at 2:16 AM, Caius Durling <[email protected]> > >>> > >> wrote: > >>> > >> > On 5 Oct 2009, at 11:59, Balazs Koren wrote: > >>> > > >>> > >> > For example I type in my comment http://habariproject.org it > will > >>> > >> > be > >>> > >> > displayed as <a > >>> > >> > href="http://habariproject.org">http://habariproject.org</a> > and I > >>> > >> > don't have to add the anchors myself. Is there a plugin > somewhere > >>> > >> > to > >>> > >> > support this functionality? Thanks. > >>> > > >>> > >> > It adds a lot more than just auto-linking, but if you install > the > >>> > >> > markdown > >>> > >> > plugin you can write <http://foo.com> and it'll autolink it for > >>> > >> > you. > >>> > >> > I'm pretty lazy when it comes to penning things like blog posts, > so > >>> > >> > I > >>> > >> > love > >>> > >> > writing them in markdown[1], makes writing stuff *really* easy, > and > >>> > >> > then > >>> > >> > it > >>> > >> > all displays nicely when you hit publish :) > >>> > >> > [1]:http://daringfireball.net/projects/markdown > >>> > >> > C > >>> > >> > --- > >>> > >> > Caius Durling > >>> > >> > [email protected] > >>> > >> > +44 (0) 7960 268 100 > >>> > >> >http://caius.name/ > >>> > > >>> > >> -- > >>> > >>http://kobak.org > >>> > >>http://fotolog.hu > >>> > > >>> > --http://kobak.orghttp://fotolog.hu > >>> > >> > >> > >> > >> -- > >> Ali > >> http://awhitebox.com > >> > >> >> > >> > > > > > > > > -- > > http://kobak.org > > http://fotolog.hu > > > > > > -- > http://kobak.org > http://fotolog.hu > > > > -- Ali http://awhitebox.com --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/habari-users -~----------~----~----~----~------~----~------~--~---
