Socket
Socket
Sign inDemoInstall

@bbob/html

Package Overview
Dependencies
Maintainers
1
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bbob/html - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0

11

CHANGELOG.md

@@ -6,2 +6,13 @@ # Change Log

<a name="2.1.0"></a>
# [2.1.0](https://github.com/JiLiZART/bbob/compare/@bbob/html@2.0.0...@bbob/html@2.1.0) (2018-09-23)
### Features
* base preset package '[@bbob](https://github.com/bbob)/preset' ([b63864c](https://github.com/JiLiZART/bbob/commit/b63864c))
<a name="1.1.0"></a>

@@ -8,0 +19,0 @@ # [1.1.0](https://github.com/JiLiZART/bbob/compare/@bbob/html@1.0.7...@bbob/html@1.1.0) (2018-08-09)

9

dist/index.js

@@ -22,2 +22,7 @@ (function (global, factory) {

var SELFCLOSE_END_TAG = '/>';
var CLOSE_START_TAG = '</';
var START_TAG = '<';
var END_TAG = '>';
var renderNode = function renderNode(node, _ref) {

@@ -41,7 +46,7 @@ var _ref$stripTags = _ref.stripTags,

if (node.content === null) {
return '<' + node.tag + attrs(node.attrs) + ' />';
return [START_TAG, node.tag, attrs(node.attrs), SELFCLOSE_END_TAG].join('');
}
// eslint-disable-next-line no-use-before-define
return '<' + node.tag + attrs(node.attrs) + '>' + renderNodes(node.content) + '</' + node.tag + '>';
return [START_TAG, node.tag, attrs(node.attrs), END_TAG, renderNodes(node.content), CLOSE_START_TAG, node.tag, END_TAG].join('');
}

@@ -48,0 +53,0 @@

@@ -1,72 +0,1 @@

(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(factory((global.BbobHtml = {})));
}(this, (function (exports) { 'use strict';
var _require = require('@bbob/plugin-helper'),
attrValue = _require.attrValue;
/**
* Transforms attrs to html params string
* @param values
*/
var attrs = function attrs(values) {
return Object.keys(values).reduce(function (arr, key) {
return [].concat(arr, [attrValue(key, values[key])]);
}, ['']).join(' ');
};
var renderNode = function renderNode(node, _ref) {
var _ref$stripTags = _ref.stripTags,
stripTags = _ref$stripTags === undefined ? false : _ref$stripTags;
if (!node) return '';
var type = typeof node;
if (type === 'string' || type === 'number') {
return node;
}
if (type === 'object') {
if (stripTags === true) {
// eslint-disable-next-line no-use-before-define
return renderNodes(node.content, { stripTags: stripTags });
}
if (node.content === null) {
return '<' + node.tag + attrs(node.attrs) + ' />';
}
// eslint-disable-next-line no-use-before-define
return '<' + node.tag + attrs(node.attrs) + '>' + renderNodes(node.content) + '</' + node.tag + '>';
}
if (Array.isArray(node)) {
// eslint-disable-next-line no-use-before-define
return renderNodes(node, { stripTags: stripTags });
}
return '';
};
var renderNodes = function renderNodes(nodes) {
var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
_ref2$stripTags = _ref2.stripTags,
stripTags = _ref2$stripTags === undefined ? false : _ref2$stripTags;
return [].concat(nodes).reduce(function (r, node) {
return r + renderNode(node, { stripTags: stripTags });
}, '');
};
var render = renderNodes;
exports.render = render;
exports.default = renderNodes;
Object.defineProperty(exports, '__esModule', { value: true });
})));
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.BbobHtml={})}(this,function(t){"use strict";var r=require("@bbob/plugin-helper").attrValue,i=function(n){return Object.keys(n).reduce(function(t,e){return[].concat(t,[r(e,n[e])])},[""]).join(" ")},u="/>",a="</",c="<",s=">",f=function(t){var e=(1<arguments.length&&void 0!==arguments[1]?arguments[1]:{}).stripTags,n=void 0!==e&&e;return[].concat(t).reduce(function(t,e){return t+function(t,e){var n=e.stripTags,r=void 0!==n&&n;if(!t)return"";var o=typeof t;return"string"===o||"number"===o?t:"object"===o?!0===r?f(t.content,{stripTags:r}):null===t.content?""+c+t.tag+i(t.attrs)+u:""+c+t.tag+i(t.attrs)+s+f(t.content)+a+t.tag+s:Array.isArray(t)?f(t,{stripTags:r}):""}(e,{stripTags:n})},"")};t.render=f,t.default=f,Object.defineProperty(t,"__esModule",{value:!0})});

@@ -16,2 +16,7 @@ var _require = require('@bbob/plugin-helper'),

var SELFCLOSE_END_TAG = '/>';
var CLOSE_START_TAG = '</';
var START_TAG = '<';
var END_TAG = '>';
var renderNode = function renderNode(node, _ref) {

@@ -35,7 +40,7 @@ var _ref$stripTags = _ref.stripTags,

if (node.content === null) {
return '<' + node.tag + attrs(node.attrs) + ' />';
return [START_TAG, node.tag, attrs(node.attrs), SELFCLOSE_END_TAG].join('');
}
// eslint-disable-next-line no-use-before-define
return '<' + node.tag + attrs(node.attrs) + '>' + renderNodes(node.content) + '</' + node.tag + '>';
return [START_TAG, node.tag, attrs(node.attrs), END_TAG, renderNodes(node.content), CLOSE_START_TAG, node.tag, END_TAG].join('');
}

@@ -42,0 +47,0 @@

@@ -20,2 +20,7 @@ 'use strict';

var SELFCLOSE_END_TAG = '/>';
var CLOSE_START_TAG = '</';
var START_TAG = '<';
var END_TAG = '>';
var renderNode = function renderNode(node, _ref) {

@@ -39,7 +44,7 @@ var _ref$stripTags = _ref.stripTags,

if (node.content === null) {
return '<' + node.tag + attrs(node.attrs) + ' />';
return [START_TAG, node.tag, attrs(node.attrs), SELFCLOSE_END_TAG].join('');
}
// eslint-disable-next-line no-use-before-define
return '<' + node.tag + attrs(node.attrs) + '>' + renderNodes(node.content) + '</' + node.tag + '>';
return [START_TAG, node.tag, attrs(node.attrs), END_TAG, renderNodes(node.content), CLOSE_START_TAG, node.tag, END_TAG].join('');
}

@@ -46,0 +51,0 @@

{
"name": "@bbob/html",
"version": "2.0.0",
"version": "2.1.0",
"description": "HTML renderer for BBCode pareser BBob",
"keywords": [],
"dependencies": {
"@bbob/plugin-helper": "^2.0.0"
"@bbob/plugin-helper": "^2.0.1"
},
"devDependencies": {
"@bbob/parser": "^2.0.0"
"@bbob/parser": "^2.1.0"
},

@@ -12,0 +12,0 @@ "main": "lib/index.js",

@@ -1,2 +0,2 @@

# bbob-html
> Converts bbob-parser AST tree to html
#@bbob/html
> Converts @bbob/parser AST tree to html

@@ -12,2 +12,7 @@ const { attrValue } = require('@bbob/plugin-helper');

const SELFCLOSE_END_TAG = '/>';
const CLOSE_START_TAG = '</';
const START_TAG = '<';
const END_TAG = '>';
const renderNode = (node, { stripTags = false }) => {

@@ -28,7 +33,7 @@ if (!node) return '';

if (node.content === null) {
return `<${node.tag}${attrs(node.attrs)} />`;
return [START_TAG, node.tag, attrs(node.attrs), SELFCLOSE_END_TAG].join('');
}
// eslint-disable-next-line no-use-before-define
return `<${node.tag}${attrs(node.attrs)}>${renderNodes(node.content)}</${node.tag}>`;
return [START_TAG, node.tag, attrs(node.attrs), END_TAG, renderNodes(node.content), CLOSE_START_TAG, node.tag, END_TAG].join('');
}

@@ -35,0 +40,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc