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.2 to 1.1.3

49

index.js

@@ -88,29 +88,33 @@ const tagName = String.raw`[A-Za-z][^/\s>]*`;

let pendingIndent = false;
let lineLength = 0;
let span = "";
let spanLevel = 0;
let lastSpace = "";
const addOutput = (/** @type {string[]} */ ...args) => {
for (const s of args) {
if (!specialElement) {
if (s == "\n") pendingIndent = true;
else {
const newline = s.indexOf("\n");
const len = newline == -1 ? s.length : newline;
if (
lineLength + len > width &&
/^[ \t]+$/.test(output[output.length - 1])
) {
output.pop();
addOutput("\n");
}
if (pendingIndent) {
pendingIndent = false;
addOutput(indent.repeat(level));
}
let out = "";
if (!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 = "";
lastSpace = s;
} else {
if (!span) spanLevel = level;
span += s;
}
const pos = s.lastIndexOf("\n");
if (pos == -1) lineLength += s.length;
else lineLength = s.length - pos - 1;
output.push(s);
if (out) {
const pos = out.lastIndexOf("\n");
if (pos == -1) lineLength += out.length;
else lineLength = out.length - pos - 1;
output.push(out);
}
}

@@ -206,2 +210,5 @@ };

// Flush remaining output
addOutput("");
let newline = false;

@@ -208,0 +215,0 @@ while (/^\s+$/.test(output[output.length - 1])) {

{
"name": "html-format",
"version": "1.1.2",
"version": "1.1.3",
"description": "Format HTML strings.",

@@ -11,3 +11,3 @@ "main": "index.js",

"devDependencies": {
"typescript": "^5.0.4"
"typescript": "^5.3.3"
},

@@ -14,0 +14,0 @@ "scripts": {

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