linksoup

0.1.0 • Public • Published

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.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.1.0
    0
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.1.0
    0

Package Sidebar

Install

npm i linksoup

Weekly Downloads

0

Version

0.1.0

License

none

Last publish

Collaborators

  • el2iot2