
Security News
New CNAPulse Dashboard Tracks CNA Activity and Disclosure Trends
Open source dashboard CNAPulse tracks CVE Numbering Authorities’ publishing activity, highlighting trends and transparency across the CVE ecosystem.
irc-formatting
Advanced tools
Turns IRC formatted text into easy to use blocks. This library is meant to parse and facilitate compiling to and from the irc caret notation. If you're looking for a means to style messages that your bot sends out, or merely strip the formatting, I'd suggest you check out irc-colors instead.
npm install irc-formatting --save
> var ircf = require('irc-formatting');
> s = "Hello, \x02World\x0304,07!\x03\x02";
> b = ircf.parse(s);
[ Block {
text: 'Hello, ',
bold: false,
italic: false,
underline: false,
reverse: false,
color: -1,
highlight: -1 },
Block {
text: 'World',
bold: true,
italic: false,
underline: false,
reverse: false,
color: -1,
highlight: -1 },
Block {
text: '!',
bold: true,
italic: false,
underline: false,
reverse: false,
color: 4,
highlight: 7 } ]
> ircf.renderIrc(b);
'Hello, \u0002World\u000304,07!\u000f'
> ircf.renderHtml(b);
'Hello, <b>World</b><span class="ircf-fg-4 ircf-bg-7"><b>!</b></span>'
Block[]Â .parse(string text): Parse text into blocksstring .renderIrc(Block[] blocks): Turn blocks back into irc-formatted text.string .renderHtml(Block[] blocks): Convert blocks into html (see below)string .renderHtml(string text): Convert text into html (see below)string .strip(Block[] blocks): Same as compile, but leaving out all formatting caretsstring .strip(string text): Parse text and turn result into unformatted textBlock[] .removeStyle(Block[] blocks): Remove all non-color formatting from blocksBlock[] .removeColor(Block[] blocks): Remove all color from blocksBlock[] .compress(Block[] blocks): Merges adjacent blocks that have equal color and style, which can happen after the two first functions or when this library is used to render.string .swigFilter(string input, bool inline): Convert irc-formatted text into html. If inline is set, it will concaterate each line instead of wrapping them in <p> tags.Note: .removeStyle, .compress and .removeColor does not clone the block array. .strip does not alter the blocks, however.
Block ClassBlock(Block prev, string text): Constructs a block. If prev is not null, the block will inherit style and color from it..equals(Block other): Returns true if block's style and color equals the other's. It does not check for text equality..isPlain(): Return true if the block has no style or color..hasSameColor(Block other, bool reversed): Returns true if the blocks has the same color. If reversed argument is true and the current block has .reverse set, it will only return true if the colors are reversed..getColorString(): Returns XX or XX,YY formatted string where XX is .color and YY is .highlight. Both numbers are padded to 2 length..U: Underline.B: Bold.I: Italic.C: Color.R: Reverse.O: Reset (CTRL + O on mIRC).U, .B and .I will use <u>, <b> and <i> tags respectively, while the others will use <span>-tags with the following classes.
ircf-reverse: Reversing is applied (color and higliht are swapped)ircf-no-color: The above class is set, but neither of the below are.ircf-fg-X: Foreground color (X = block.color)ircf-bg-X: Background color (X = block.highlight)The output of .renderHtml is a string of tags without a tag wrapping all of it. .swigFilter will use the class ircf-line on its <p> tags.
In the initialization phase of your swig instance, you can add custom filters to swig like this. Make note of the first parameter.
swig.setFilter('ircf', require('irc-formatting').swigFilter);
Then you can use it in your templates like this.
<!-- ... -->
<h1>Log file</h1>
{{logcontent|ircf}}
<!-- ... -->
Copyright (c) 2016, Gisle Aune
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE
FAQs
IRC formatting parser
The npm package irc-formatting receives a total of 85 weekly downloads. As such, irc-formatting popularity was classified as not popular.
We found that irc-formatting demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Open source dashboard CNAPulse tracks CVE Numbering Authorities’ publishing activity, highlighting trends and transparency across the CVE ecosystem.

Product
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.

Product
Add real-time Socket webhook events to your workflows to automatically receive pull request scan results and security alerts in real time.