linksoup
v0.1.0
Published
a javascript library that parses and exposes links found in string data
Downloads
5
Readme
#linksoup
With a name inspired by the arcane art of tag soup parsing, linksoup seeks to handle links embedded into text in a robust and safe way.
When given a string:
var text = "Visit [my site](http://automatonic.net ""automanual"") (or http://twitter.com/automatonically)";
linksoup returns structured data as "spans":
var spans = [{
text: "Visit "
},{
text: "my site",
title: "automanual",
href: "http://automatonic.net"
},{
text: " (or "
},{
href: "http://twitter.com/automatonically"
},{
text: ")"
}];
that allows you to represent the "link soup" in a templating system (with appropriate escaping) and rendering to HTML.
##Status
This project is in an "alpha" status, and not yet suitable for casual use.
###To Do
- Port twitter-text
- ~~make routines lint friend(lier)~~
- ~~remove unused/irrelevant routines~~
- ~~adapt url test cases~~
- ~~Support markdown style links~~
- Ensure multi-use code
- browser wrapper
- node.js
- Create simple demo/docs
##Getting Started
###Node.js
Install the module with: npm install linksoup
var linksoup = require('linksoup');
var text = "...";
var spans = linksoup.parseSpans(text);
###Browser / Client side
(Coming soon)
Documentation
(Coming soon)
Examples
(Coming soon)
Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using grunt.
Building
linksoup uses grunt.js...
Tests
Tests are defined as Jasmine specs and launched via jasmine-node
. Like the code itself, some test cases are adapted from the twitter-text
project.
####Initial setup:
The Jasmine harness for node is installed globally (to facilitate command-line execution):
npm install jasmine-node -g
####Running tests:
From the root project directory (along side grunt.js
), run:
jasmine-node spec
Release History
(Nothing yet)
##Acknowledgments
License
Copyright (c) 2012 Elliott B. Edwards
Licensed under the MIT license.