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

irc-style-parser

v0.2.5

Published

Parser for IRC styles and colours in some IRC message

Downloads

18

Readme

IRC Style and Colour Parser License

IRC Style parsing is ridiculously tricky as I found writing this for qwebirc. Besides the numerous edge cases, the spec is semi-ambigous (e.g. will the second x have a background in the string "^C1,2x^C3x"?). This implementation follows the defacto implementations of mibbit and xchat -- however if you want options to handle particular cases cases differently make an issue.

This implementation should work consistently in near any environment (IE6+) [with an es5 array method shim] and is well tested

Handles:

  • Unlimitted nesting
  • Colours (^C): Default outputs as
<span class="irc-bg3"><span class="irc-fg3">message</span></span>
  • Underlines (^u): Default outputs as
<span class="irc-underline">message</span>
  • Italics (^i): Default outputs as
<span class="irc-italics">message</span>
  • Bold (^B): Default outputs as
<span class="irc-bold">message</span>
  • Normal (^o): Default outputs as
<span class="">message</span>
  • Escaping (^0): E.g.
ircStylize("^Bbolded part ^0 not bolded part");
// => "<span class="irc-bold">bolded part </span> not bolded part"

Note: the ^C/^u/etc isn't used internally - we only replace the UTF8 versions of the string see here

Usage

var ircStylize = require("irc-style-parser");
var Handlebars = require("Handlebars");
var jQuery 	   = require("jquery");

// Set template of ircStylize if desired called with {style: '', text: msg}
ircStylize.template = Handlebars.compile("<span class='{{style}}'>{{{text}}}</span>");

// Parse a message to HTML or whatever your template outputs
var $parsed = jQuery(ircStylize(msg));

Todo [ ] Make it easier to add/change a colour [ ] Remove ES5 dependency?