npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

htmlsplit

v1.1.0

Published

Split an HTML document into a number of lines, based on the intent in the original markup.

Downloads

9

Readme

htmlsplit

wercker status

htmlsplit splits HTML documents into lines that hopefully reflect the intent of the author.

Introduction

A web page may have the following layout:

Term Starts: Wednesday 7 January 2015
Term Ends: Friday 27 March 2015

However, there is a wide range of markup that could achieve this layout. For example, we could have a <div> that contains lines with <br> tags:

<div>
  Term Starts: Wednesday 7 January 2015<br>
  Term Ends: Friday 27 March 2015<br>
</div>

Alternatively, each line could be its own <div>:

<div>Term Starts: Wednesday 7 January 2015</div>
<div>Term Ends: Friday 27 March 2015</div>

a line in a list:

<ul>
  <li>Term Starts: Wednesday 7 January 2015</li>
  <li>Term Ends: Friday 27 March 2015</li>
</ul>

or a row in a <table>:

<table>
  <tr><td>Term Starts: Wednesday 7 January 2015</td></tr>
  <tr><td>Term Ends: Friday 27 March 2015</td></tr>
</table>

And of course when using tables, each row could itself be split into columns:

<table>
  <tr>
    <td>Term Starts:</td>
    <td>Wednesday 7 January 2015</td>
  </tr>
  <tr>
    <td>Term Ends:</td>
    <td>Friday 27 March 2015</td>
  </tr>
</table>

Authors could also mark up different parts of each line with flow tags:

<b>Term Starts:</b> Wednesday 7 January 2015<br>
<b>Term Ends:</b> Friday 27 March 2015<br>

The key point is that whitespace in the markup does not give us any clues as to the intent of the page author. For example, whether the table example above has each table cell marked up a seperate line, or has each row (and all its cells) on the same line, makes no difference to how the markup is rendered.

The purpose of htmlsplit therefore is to try to capture this intent, when splitting an HTML document into lines for processing.

Usage

The module provides a single function, which does the splitting:

var htmlSplit = require('htmlsplit');

The function takes a string as input, and returns an array of lines

htmlSplit(
  [
    '<div>Term Starts: Wednesday 7 January 2015</div>',
    '<!-- This should not get through -->',
    '<div>Term Ends: Friday 27 March 2015</div>'
  ].join('')
).should.eql([
  'Term Starts: Wednesday 7 January 2015',
  'Term Ends: Friday 27 March 2015'
]);

The function can also take a second parameter which if true will add debug information to the output.

Changelog

2015-06-12 (v1.1.0)

Add a space between adjacent table cells. (Fixes #1)

Upgrade mocha, and replace should with chai.

2015-03-05 (v1.0.0)

Initial release.