milesj / decoda

A lightweight lexical string parser for BBCode styled markup.
MIT License
196 stars 52 forks source link

Cannot parse emoticons at start. #98

Closed JavoByte closed 9 years ago

JavoByte commented 9 years ago

I'm trying to parse a text like this: " :) Hello text text text :) :D :( "

The last three emoticons are being parsed correctly but the first one isn't. I don't know if it's my configuration

I figured out that emoticons require whitespaces surrounding. Is there any workaround? I want to use this plugin with sceditor. I also want to smileys like :):):) being parsed. I could avoid using smileys like that and limit my users to just use smileys with colons.

alquerci commented 9 years ago

Hi @javier-lavida

What Decoda version are you running?

I cannot make a failing test with the current.

JavoByte commented 9 years ago

Hi @alquerci I'm running version 6.6.2. Here's a screenshot of the output.

captura de pantalla 2015-04-09 a las 18 20 30

milesj commented 9 years ago

That's odd since they are covered by the unit tests: https://github.com/milesj/decoda/blob/master/tests/Decoda/Hook/EmoticonHookTest.php#L55

JavoByte commented 9 years ago

I created another post and this happened: captura de pantalla 2015-04-09 a las 18 40 44

I checked the HTML output and the first one has this:

:) Emoticons

And the next one has:

<img src=....> Emoticons

where does the nbsp; comes from? In my database it's only a space. And also this is weird because both of the texts are being parsed with the same configuration.

JavoByte commented 9 years ago

I solved it. It's not the plugin. It's the wysiwyg editor in the browser. It sends the &nbsp; . Guess I have to fix it in the browser side. However, my only question left is, is the any way to allow emoticons without surrounding whitespaces??

milesj commented 9 years ago

Glad you figured it out!

Also regarding the other point, I don't believe it's possible. We need a word boundary or else we have problems with words like "http://google.com" where :/ would be matched.

alquerci commented 9 years ago

Using the PCRE word boundary \b like on the CensorHook does not help. The problem is that all characters can be used (except whitespaces) to form an emoticon.