Coder Social home page Coder Social logo

linkify's People

Contributors

maranomynet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

linkify's Issues

README, and comparison with competition

Parsing out URLs is a very old problem and there are quite a few solid solutions to it. Would love to know how this one compares.

A feature list (like Autolinker's) would be great! I'm researching autolinking libraries for a StackOverflow answer.

Spaces before and after the url are disappearing after linkifing

When the url is inline with the rest of the text it has no separating spaces after it get's linkified. It happens in your example html file with link number 4, which is inserted like this:
asdfd ftp://adfælkj asdfd
and instead of getting asdfd <created_link> asdfd it generates asdfd<created_link>asdfd.
I changed two lines and put spaces before and after <a> tags
...
linkifier = function ( html ) {
return html
.replace( noProtocolUrl, ' $1 ' ) // NOTE: we escape "http as "<``> to make sure httpOrMailtoUrl below doesn't find it as a false-positive
.replace( httpOrMailtoUrl, ' $1 ' )
.replace( /"<``>/g, '"http' ); // reinsert"http
}
...
and it kind of works but maybe there is something wrong with the regular expression.

Strange behaviour with mailto links and twitter plugin

I found some more bugs. One in the main script and the other in the twitter plugin.
The first one is that when you got two email adresses, without the mailto: prefix, inline with the text and separated by it like this:
some text [email protected] text [email protected] text
after linkifing it concatenates both email addresses and the text between in one link like this:
some text ... text
that doesn't apply when i put mailto: in front of the email address.

One in the plugin is with hashtags. It makes links to twitter search api's out of things like
# hashtag
even though the text is separated by a space from # which actually is not a twitter hashtag then.

The other one is that, when you got more than one twitter username or hashtags in the text, only the first ones got replaced by links. So if you have
text @user1 text @user2 text #hashtag1 @user3 #hashtag2
linkfing will return links only for @user1 and #hashtag1. Others will stay as they are.

Why not use jQuery.extend?

I noticed you had code like this:

if ( !$.isPlainObject( cfg ) ) {
    cfg = { <defaults> };
} 

Maybe what you’re doing is necessary for the kind of plugin you’ve written, but if not, check out jQuery.extend, because you can set defaults piecemeal that way.

A URL immediately following a linkified URL doesn't get linkified

If the text contains 2 consecutive URLS (separated by one space, or one newline), only the first URL gets linkified. This only occurs if the 2 URLs have the same format (eg, both with an http or ftp part, or both without).

Failing examples (only the first URL is linkified):
www.github.com www.google.com
http://www.github.com http://www.google.com
ftp://www.github.com http://www.google.com

But working examples:
http://www.github.com www.google.com
www.github.com ftp://www.google.com
www.github.com www.google.com (with 2 spaces in between)

Issue on Mozilla 6, IE8 and Chrome (didn't test other browsers).

[enhancement] Add missing bower.json.

Hey, maintainer(s) of maranomynet/linkify!

We at VersionEye are working hard to keep up the quality of the bower's registry.

We just finished our initial analysis of the quality of the Bower.io registry:

7530 - registered packages, 224 of them doesnt exists anymore;

We analysed 7306 existing packages and 1070 of them don't have bower.json on the master branch ( that's where a Bower client pulls a data ).

Sadly, your library maranomynet/linkify is one of them.

Can you spare 15 minutes to help us to make Bower better?

Just add a new file bower.json and change attributes.

{
  "name": "maranomynet/linkify",
  "version": "1.0.0",
  "main": "path/to/main.css",
  "description": "please add it",
  "license": "Eclipse",
  "ignore": [
    ".jshintrc",
    "**/*.txt"
  ],
  "dependencies": {
    "<dependency_name>": "<semantic_version>",
    "<dependency_name>": "<Local_folder>",
    "<dependency_name>": "<package>"
  },
  "devDependencies": {
    "<test-framework-name>": "<version>"
  }
}

Read more about bower.json on the official spefication and nodejs semver library has great examples of proper versioning.

NB! Please validate your bower.json with jsonlint before commiting your updates.

Thank you!

Timo,
twitter: @versioneye
email: [email protected]
VersionEye - no more legacy software!

Create tag for Bower

Bower uses tags to include packages, please create one so this plugin can be used with that manager.

Probably is a good idea to avoid the 1.0 folder too.

Enhanced replace

Thanks for a great script! Here's an addition that would make it even greater. First of all, I would want all...

http://www.
http://
mailto:

...to be gone in the displayed links. Long url like this...

http://www.somedomain/and/a/veeery/long/path/to/some-very-long-file-name.html

...I would even want to be converted to this...

somedomean>some-very-l...

Thus, all that remains were the "subdomain.domain.com", some delimiter (e.g. '>') and a given number of starting characters from the actual file... no folder paths.

Would something like that be rather difficult or simple enough?

I guess this woudl do good with a global params object, e.g.

params={
nohttp:true,
paths:no,
doclen:15,
delimiter:'>'
}

Unfortunately I am not the most literate with regex's, as then I would do it myself.

URLs with commas are partial

Based on RFC commas are allowed characters yet the following link get's partially detected up to the comma.
http://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&sensor=false

Looking at the regex /(^|["'(\s]|&lt;)((?:(?:https?|ftp):\/\/|mailto:).+?)((?:[:?]|\.+)?(?:\s|$)|&gt;|[)"',])/g, it appears that it's trying to be "smart" about ending the link based on surrounding content such as visit us at http://example.com/?contact_us, we're always there but it's breaking functionality and the comma detection should be removed to make the regex /(^|["'(\s]|&lt;)((?:(?:https?|ftp):\/\/|mailto:).+?)((?:[:?]|\.+)?(?:\s|$)|&gt;|[)"'])/g

Imageify

Linkify is awesome! I am hoping to modify the script to be able to do the same for images (imageify). I seem to have been able to make it work by only editing the regex, however, if the image is not retrieved my console shows a 404 and the rest of my javascript does not get applied. I am hoping you would be willing to take a look and help if possible. Here is the code:

https://github.com/athal7/linkify/blob/master/imageify.js.coffee

Thanks,
Andrew

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.