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

Linkify 2.0 #51

Merged
merged 68 commits into from Jun 13, 2015
Merged

Linkify 2.0 #51

merged 68 commits into from Jun 13, 2015

Conversation

nfrasser
Copy link
Collaborator

@nfrasser nfrasser commented Jan 2, 2015

2.0 includes completely rewritten internals and a Node.js/io.js API. This PR supersedes #17 and fixes numerous additionally reported issues.

Work in Progress.

Overview

  • New link-detection technique based on lexicographical analysis via two-stage scanner
  • Node.js API via var linkify = require('linkifyjs');
  • Internal plugin system so you can require only features you need. e.g., require('linkifyjs-mentions')(linkify);
  • Multiple browser builds with various features Deferring these to a future release
    • Basic linkify for URLs with most available TLDs and email addresses
    • Slim linkify with only the most common TLDs
    • More builds with mentions and hashtags to come
  • Browser modules
    • Browserify (regular Node)
    • AMD
    • Browser build
  • Mocha Unit tests
  • Written in future-proof ES6 compiled to ES5
  • Updated documentation for all the new features

Fixes

APIs

  • find - Find links
  • test - Is the given string a link?
  • Plugin API - for adding mentions and hashtags (to be provided by the plugin)
  • String of plain text to string of HTML with .linkify anchor tags (can be used on the server-side)
    • Supports options and callbacks
  • Updated jQuery/DOM API
    • Supports options and callbacks

Deprecations

  • Bower package will be moved to linkifyjs (install with bower install linkifyjs)

Current API just includes the `find` method, which takes a string of
text and returns the kinds of links available in it. More methods to
come soon.

Also included are Mocha unit tests for the major lexical analysis
components.
As a way to demo the linkify plugin API - Totally works, but requires
classes to create new kinds of tokens. This may mean having to convert
the ES6 classes to regular JS classes somehow.
To check if the given string is a linkable value
Also added .travis.yml file
Brings back functionality of taking a string of text and outputting a
string of HTML with anchor tags.
@nfrasser
Copy link
Collaborator Author

nfrasser commented Jan 7, 2015

Should switch the current ES6 Transpiler to this one https://6to5.org

Seems much more robust and supports compiling to various modules

As well as 6to5 (instead of the ES6 transpiler)
Needs a few more but this should be good for now
Run `gulp build` or `gulp dist`
Let’s make a really good module system with flexible builds
@nfrasser
Copy link
Collaborator Author

Been doing a lot of mental labour trying to come up with a sophisticated build system. I have AMD modules working so far (should make building an Ember CLI plugin trivial!), and now I have to come up with the vanilla browser build.

Here's the game plan so far

  • Export to AMD modules with a complete linkify.amd.js file
    • AMD modules for Linkify plugins - e.g., defining the hashtag plugin, then immediately applying it to Linkify (so that it's active as soon as the file is loaded)
  • Browser build using the closure compiler - Can convert the generated CJS modules in lib/ - see this post
    • Would this provide a viable non-minified version? Look into the closure compiler options
  • Verify that Browserify modules do "just work"

* Basic linkify.js compiled with closure compiler
* Build steps for linkify interfaces including string - jQuery/DOM
interfaces soon to follow
* Build steps for linkify plugins
* AMD versions of all of the above

Also includes some updates to the core directory and file structure
for better compression/minification.
For a more filename-friendly browser shim. Also removed bower.json
(moved to shim repository)
@nfrasser
Copy link
Collaborator Author

Shim repo located at https://github.com/nfrasser/linkify-shim (to be transferred to https://github.com/SoapBox/linkify-shim )

Includes a few new options and ability to set some options to
functions. Also better HTML cleaning
Will try out running browser tests with Karma
Karma test runner fully working, cross-browser SauceLabs configuration
still in the works.
Had to rewrite all the test files to use expect assertions instead of
should to get this even working on IE8. Seems solid though!
It turns out that browsers really really like rearranging their
attributes. Should make a note to find a better way to do this
Contributing covers how linkify works, setting up, building,
testing, and plugin development (briefly)

Readme has been updated with links to the docs site, and all
previous API documentation has been taken out.
@nfrasser
Copy link
Collaborator Author

This is just about ready to merge. Next up, updating Bower to point to the shim repository.

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

Successfully merging this pull request may close these issues.

None yet

2 participants