Files
med-notes/.pnpm-store/v10/files/c3/54c98e1fc232b86151278d76208cb05bac8d2efa5fa411e3f6a5fdbfa62668da568d8398f3078a29d96a765717f66bce59e8d7bd34c7a77da0ff36f69d3d6f
2025-05-09 05:30:08 +02:00

41 lines
1.1 KiB
Plaintext

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = cleanJSXElementLiteralChild;
var _index = require("../../builders/generated/index.js");
var _index2 = require("../../index.js");
function cleanJSXElementLiteralChild(child, args) {
const lines = child.value.split(/\r\n|\n|\r/);
let lastNonEmptyLine = 0;
for (let i = 0; i < lines.length; i++) {
if (/[^ \t]/.exec(lines[i])) {
lastNonEmptyLine = i;
}
}
let str = "";
for (let i = 0; i < lines.length; i++) {
const line = lines[i];
const isFirstLine = i === 0;
const isLastLine = i === lines.length - 1;
const isLastNonEmptyLine = i === lastNonEmptyLine;
let trimmedLine = line.replace(/\t/g, " ");
if (!isFirstLine) {
trimmedLine = trimmedLine.replace(/^ +/, "");
}
if (!isLastLine) {
trimmedLine = trimmedLine.replace(/ +$/, "");
}
if (trimmedLine) {
if (!isLastNonEmptyLine) {
trimmedLine += " ";
}
str += trimmedLine;
}
}
if (str) args.push((0, _index2.inherits)((0, _index.stringLiteral)(str), child));
}
//# sourceMappingURL=cleanJSXElementLiteralChild.js.map