Skip Menu |

This queue is for tickets about the Parse-BBCode CPAN distribution.

Maintainer(s)' notes

If you have any wishes, feel free to create a ticket.

Plans:

I would like to add callbacks to the parser so that you can gather some information about specific tags and ideally can manipulate them during parsing.

But there are already enough informations to create a download link for code tags, for example. See example/code_download.pl.

Parse::BBCode is now hosted on github, so for bug reports also check https://github.com/perlpunk/Parse-BBCode

Report information
The Basics
Id: 67897
Status: resolved
Priority: 0/
Queue: Parse-BBCode

People
Owner: Nobody in particular
Requestors: lozier [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 0.11
Fixed in: 0.12_004



Subject: request to support smilies
I wish this module would support smilies. Now I have a post-processor for smilies but it does them in bad places, for example, inside [code] tags.
Hi, Am Mo 02. Mai 2011, 10:59:12, LOZIER schrieb: Show quoted text
> I wish this module would support smilies. Now I have a post-processor > for smilies but it does them in bad places, for example, inside
[code] tags. You can put the smiley post processor into the '' tag. typically looks like this: my $p = Parse::BBCode->new({ tags => { '' => sub { my $content = $_[2]; # parse smileys from $content here # ... $content = Parse::BBCode::escape_html($content); $e =~ s/\r?\n|\r/<br>\n/g; $e }, ... }, }); I use this to find URIs with URI::Find at this place. This code will only be applied to text which is outside of tags or inside of parseable tags, so not inside of code tags. regards, tina
Subject: Re: [rt.cpan.org #67897] request to support smilies
Date: Tue, 10 May 2011 17:03:38 -0700
To: bug-Parse-BBCode [...] rt.cpan.org
From: "Brian E. Lozier" <brian [...] massassi.com>
I think I don't understand how this is supposed to work. If I specify the argument to new() it causes everything else to not get parsed. For example, the code tags stay there. The smiles code I added to the top of your example gets applied to the entire string, not just things outside of code tags. Is this because the tags => {} specification requires me to declare every single possible tag? Meaning, I can't only override '', I have to override all of them? On Sat, May 7, 2011 at 12:55 PM, Tina Muller via RT <bug-Parse-BBCode@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=67897 > > > Hi, > > Am Mo 02. Mai 2011, 10:59:12, LOZIER schrieb:
>> I wish this module would support smilies.  Now I have a post-processor >> for smilies but it does them in bad places, for example, inside
> [code] tags. > > You can put the smiley post processor into the '' tag. > typically looks like this: > > my $p = Parse::BBCode->new({ >    tags => { >        '' => sub { >            my $content = $_[2]; >            # parse smileys from $content here >            # ... >            $content = Parse::BBCode::escape_html($content); >            $e =~ s/\r?\n|\r/<br>\n/g; >            $e >        }, >        ... >    }, > }); > > I use this to find URIs with URI::Find at this place. > This code will only be applied to text which is outside of tags or > inside of parseable tags, so not inside of code tags. > > regards, > tina >
Am Di 10. Mai 2011, 20:04:08, LOZIER schrieb: Show quoted text
> I think I don't understand how this is supposed to work. If I specify > the argument to new() it causes everything else to not get parsed. > For example, the code tags stay there. The smiles code I added to the > top of your example gets applied to the entire string, not just things > outside of code tags. Is this because the tags => {} specification > requires me to declare every single possible tag? Meaning, I can't > only override '', I have to override all of them?
my $p = Parse::BBCode->new({ tags => { # load the default tags Parse::BBCode::HTML->defaults, # add/override tags '' => sub {smiley parsing and HTML escaping here} }, }); So with an empty new() the default tags are loaded, but if you define one or more tag yourself, you have to load the default tags explicitly. Be sure to do HTML escaping in your smiley parsing routine. I am now thinking of adding a kind of plugin for smileys, though, since it is cumbersome to write and to actually get it right so that HTML is escaped correctly.
Subject: Re: [rt.cpan.org #67897] request to support smilies
Date: Wed, 11 May 2011 07:28:07 -0700
To: bug-Parse-BBCode [...] rt.cpan.org
From: "Brian E. Lozier" <brian [...] massassi.com>
On Wed, May 11, 2011 at 4:55 AM, Tina Muller via RT <bug-Parse-BBCode@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=67897 > > > Am Di 10. Mai 2011, 20:04:08, LOZIER schrieb:
>> I think I don't understand how this is supposed to work.  If I specify >> the argument to new() it causes everything else to not get parsed. >> For example, the code tags stay there.  The smiles code I added to the >> top of your example gets applied to the entire string, not just things >> outside of code tags.  Is this because the tags => {} specification >> requires me to declare every single possible tag?  Meaning, I can't >> only override '', I have to override all of them?
> > my $p = Parse::BBCode->new({ >        tags => { >            # load the default tags >            Parse::BBCode::HTML->defaults, > >            # add/override tags >            '' => sub {smiley parsing and HTML escaping here} >        }, >    }); > > So with an empty new() the default tags are loaded, but if you define > one or more tag yourself, you have to load the default tags explicitly. > > Be sure to do HTML escaping in your smiley parsing routine. > > I am now thinking of adding a kind of plugin for smileys, though, since > it is cumbersome to write and to actually get it right so that HTML is > escaped correctly. >
Thanks for the tip about loading the default tags explicitly, this solved my problem and my smilies are working properly now. Thanks for releasing this module and thanks for the prompt support.
Am Mo 02. Mai 2011, 10:59:12, LOZIER schrieb: Show quoted text
> I wish this module would support smilies.
In version 0.12_004 I added a smileys option. Parse::BBcode->new({ smileys => { base_url => '/icons/', # sprintf syntax format => '<img src="%s" alt="%s">', icons => { qw/ :-) smile.png :-( sad.png / }, }, tags => ... (See documentation also) Can you check if this works for you? Maybe you have additional wishes? I'm open to any suggestions.
Am Mo 16. Mai 2011, 12:15:47, TINITA schrieb: Show quoted text
> Am Mo 02. Mai 2011, 10:59:12, LOZIER schrieb:
> > I wish this module would support smilies.
> > In version 0.12_004 I added a smileys option.
And if you use it, you must drop the special '' tag definition I showed you above (since this would override the smiley option).