Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

html-format

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

html-format - npm Package Compare versions

Comparing version 1.1.5 to 1.1.6

45

index.js

@@ -93,16 +93,26 @@ const tagName = String.raw`[A-Za-z][^/\s>]*`;

const flushOutput = () => {
if (lastSpace && lastSpace != "\n") {
const newline = span.indexOf("\n");
const len = newline == -1 ? span.length : newline;
if (lineLength + lastSpace.length + len > width) lastSpace = "\n";
}
const ind = lastSpace == "\n" && span ? indent.repeat(spanLevel) : "";
const out = `${lastSpace}${ind}${span}`;
if (out) {
const pos = out.lastIndexOf("\n");
if (pos == -1) lineLength += out.length;
else lineLength = out.length - pos - 1;
output.push(out);
}
span = lastSpace = "";
};
const addOutput = (/** @type {string[]} */ ...args) => {
for (const s of args) {
let out = "";
if (!s || (!specialElement && /^\s+$/.test(s))) {
const newline = span.indexOf("\n");
const len = newline == -1 ? span.length : newline;
if (lastSpace) {
if (lineLength + lastSpace.length + len > width) lastSpace = "\n";
out += lastSpace;
if (lastSpace == "\n" && span) out += indent.repeat(spanLevel);
}
out += span;
span = "";
if (!specialElement && /^\s+$/.test(s)) {
flushOutput();
lastSpace = s;

@@ -113,9 +123,2 @@ } else {

}
if (out) {
const pos = out.lastIndexOf("\n");
if (pos == -1) lineLength += out.length;
else lineLength = out.length - pos - 1;
output.push(out);
}
}

@@ -205,3 +208,3 @@ };

if (hasClosingSlash || voidTags.has(tagName)) --level;
else if (["pre", "script", "style"].includes(tagName))
else if (["pre", "textarea", "script", "style"].includes(tagName))
specialElement = tagName;

@@ -213,3 +216,3 @@ }

// Flush remaining output
addOutput("");
flushOutput();

@@ -216,0 +219,0 @@ let newline = false;

{
"name": "html-format",
"version": "1.1.5",
"version": "1.1.6",
"description": "Format HTML strings.",

@@ -5,0 +5,0 @@ "main": "index.js",

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