Skip to content

Commit

Permalink
feat(tools): strip HTML and wrap long text
Browse files Browse the repository at this point in the history
  • Loading branch information
drawnepicenter committed Sep 20, 2016
1 parent d35156a commit 9341117
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
13 changes: 12 additions & 1 deletion bin/tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
/* eslint max-len: 0 */
var chalk = require('chalk');
var fs = require('fs-extra');
var moment = require('moment');
var noon = require('noon');
var wrap = require('wrap-ansi');
var xml2js = require('xml2js');

var CFILE = process.env.HOME + '/.iloa.noon';
Expand Down Expand Up @@ -81,6 +81,17 @@ exports.stripHTML = function (string) {
return stripped;
};

/**
* Wraps blocks of text
* @param {string} str Long string
* @param {number} col Number of columns
* @param {boolean} hard true, soft false
* @return {string} ANSI-wrapped string
*/
exports.wrapStr = function (str, col, hard) {
return wrap(str, col, hard);
};

/**
* Handles data export to file. Supports cson, json, noon, plist, xml, yaml.
* @public
Expand Down
13 changes: 11 additions & 2 deletions src/tools.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* eslint max-len: 0 */
const chalk = require('chalk')
const fs = require('fs-extra')
const moment = require('moment')
const noon = require('noon')
const wrap = require('wrap-ansi')
const xml2js = require('xml2js')

const CFILE = `${process.env.HOME}/.iloa.noon`
Expand Down Expand Up @@ -75,10 +75,19 @@ exports.arrToStr = (obj) => {
* @return {string} Plaint text string
*/
exports.stripHTML = (string) => {
let stripped = string.replace(/(<([^>]+)>)/ig,'')
const stripped = string.replace(/(<([^>]+)>)/ig, '')
return stripped
}

/**
* Wraps blocks of text
* @param {string} str Long string
* @param {number} col Number of columns
* @param {boolean} hard true, soft false
* @return {string} ANSI-wrapped string
*/
exports.wrapStr = (str, col, hard) => wrap(str, col, hard)

/**
* Handles data export to file. Supports cson, json, noon, plist, xml, yaml.
* @public
Expand Down

0 comments on commit 9341117

Please sign in to comment.