Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

URLs get processed too #1

Closed
akx opened this issue Apr 4, 2015 · 4 comments · Fixed by #3
Closed

URLs get processed too #1

akx opened this issue Apr 4, 2015 · 4 comments · Fixed by #3

Comments

@akx
Copy link

akx commented Apr 4, 2015

The :/ pattern is matched in "http://foo", so the output is something like "http 😦 /foo".

Would there be an easy way to fix this?

@banyan
Copy link
Owner

banyan commented Apr 4, 2015

Hi @akx!

I use with react-autolink in my case, so first convert url to link, then convert if it matches with emoji annotation or emoticon.

  mixins: [
    ReactAutolink,
    ReactEmoji
  ],

  renderMessage: function(contents) {
    return _.flatten(
      this.autolink(contents, {target: "_blank"}).map(function(content) {
        if (React.isValidElement(content)) {
          return content;
        } else {
          return this.emojify(content);
        }
      }.bind(this))
    );
  },

  render: function() {
    return this.renderMessage(this.props.text)); 
  }

Aside from this solution, I feel I may remove :/ from dictionary, https://github.com/banyan/emoji-emoticon-to-unicode/blob/master/emoji-emoticon-to-unicode.js#L94

What do you think?

@akx
Copy link
Author

akx commented Apr 4, 2015

For the time being, I ended up just disabling emoticons altogether, which is fine for my use case -- I really only need support for annotations anyway.
Also, hey, react-autolink looks neat! I was looking for something like that, but ended up just writing my own, actually the other way around wrt react-emoji:

function formatText(text) {
    var content = [];
    if(!_.isString(text)) return [];
    _.each(text.split("\n"), function(line, index) {
        line = _.trim(line);
        if(line && line.length) {
            content.push(_.map(ReactEmoji.emojify(line, {useEmoticon: false}), function(bit, index) {
                if(_.isString(bit)) {
                    if(urlRegexp.test(bit)) {
                        bit = <a href={bit} target="_blank" key={"u" + index}>{ellipsize(bit, 40)}</a>;
                    }
                }
                return bit;
            }));
            content.push(<br key={index}/>);
        }
    });
    return content;
}

And thanks for your work on react-emoji!

@warpech
Copy link

warpech commented Apr 24, 2015

is there a way to remove :/ from dictionary in config/runtime?

@banyan
Copy link
Owner

banyan commented Apr 24, 2015

@akx
Sorry for the late reply! Thank you, too! 😄

@warpech
My friend told me an good idea to use negated lookahead for :/. I'll apply soon (sorry I'm a bit busy today).

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants