2022-02-21 16:44:56 +08:00
|
|
|
import { ParseSourceSpan } from "angular-html-parser/lib/compiler/src/parse_util.js";
|
2023-02-24 15:41:20 +08:00
|
|
|
import htmlWhitespaceUtils from "../utils/html-whitespace-utils.js";
|
2022-02-21 16:44:56 +08:00
|
|
|
import {
|
2018-11-04 23:03:07 +08:00
|
|
|
canHaveInterpolation,
|
2023-12-17 19:34:12 +00:00
|
|
|
getLeadingAndTrailingHtmlWhitespace,
|
2018-10-13 13:55:38 +08:00
|
|
|
getNodeCssStyleDisplay,
|
|
|
|
|
isDanglingSpaceSensitiveNode,
|
2018-11-04 23:03:07 +08:00
|
|
|
isIndentationSensitiveNode,
|
2018-10-13 13:55:38 +08:00
|
|
|
isLeadingSpaceSensitiveNode,
|
|
|
|
|
isTrailingSpaceSensitiveNode,
|
2018-11-04 23:03:07 +08:00
|
|
|
isWhitespaceSensitiveNode,
|
2022-02-21 16:44:56 +08:00
|
|
|
} from "./utils/index.js";
|
2018-10-13 13:55:38 +08:00
|
|
|
|
|
|
|
|
const PREPROCESS_PIPELINE = [
|
2018-11-04 23:03:07 +08:00
|
|
|
removeIgnorableFirstLf,
|
2022-01-09 08:15:06 -03:00
|
|
|
mergeIfConditionalStartEndCommentIntoElementOpeningTag,
|
2018-11-04 23:03:07 +08:00
|
|
|
mergeCdataIntoText,
|
|
|
|
|
extractInterpolation,
|
2018-10-13 13:55:38 +08:00
|
|
|
extractWhitespaces,
|
|
|
|
|
addCssDisplay,
|
2018-11-04 23:03:07 +08:00
|
|
|
addIsSelfClosing,
|
2018-11-29 11:03:22 +08:00
|
|
|
addHasHtmComponentClosingTag,
|
2018-10-13 13:55:38 +08:00
|
|
|
addIsSpaceSensitive,
|
2018-11-04 23:03:07 +08:00
|
|
|
mergeSimpleElementIntoText,
|
2018-10-13 13:55:38 +08:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
function preprocess(ast, options) {
|
|
|
|
|
for (const fn of PREPROCESS_PIPELINE) {
|
2022-01-11 22:06:46 +09:00
|
|
|
fn(ast, options);
|
2018-10-13 13:55:38 +08:00
|
|
|
}
|
2025-01-09 20:08:05 +08:00
|
|
|
|
2022-01-11 22:06:46 +09:00
|
|
|
return ast;
|
2018-10-13 13:55:38 +08:00
|
|
|
}
|
|
|
|
|
|
2018-11-04 23:03:07 +08:00
|
|
|
function removeIgnorableFirstLf(ast /*, options */) {
|
2021-07-01 19:46:24 +09:00
|
|
|
ast.walk((node) => {
|
2018-10-13 13:55:38 +08:00
|
|
|
if (
|
2018-11-04 23:03:07 +08:00
|
|
|
node.type === "element" &&
|
|
|
|
|
node.tagDefinition.ignoreFirstLf &&
|
2021-01-04 10:11:57 +08:00
|
|
|
node.children.length > 0 &&
|
2018-11-04 23:03:07 +08:00
|
|
|
node.children[0].type === "text" &&
|
|
|
|
|
node.children[0].value[0] === "\n"
|
2018-10-13 13:55:38 +08:00
|
|
|
) {
|
2022-01-11 22:06:46 +09:00
|
|
|
const text = node.children[0];
|
|
|
|
|
if (text.value.length === 1) {
|
|
|
|
|
node.removeChild(text);
|
|
|
|
|
} else {
|
|
|
|
|
text.value = text.value.slice(1);
|
|
|
|
|
}
|
2018-10-13 13:55:38 +08:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-09 08:15:06 -03:00
|
|
|
function mergeIfConditionalStartEndCommentIntoElementOpeningTag(
|
2018-11-15 12:35:28 +08:00
|
|
|
ast /*, options */,
|
|
|
|
|
) {
|
|
|
|
|
/**
|
|
|
|
|
* <!--[if ...]><!--><target><!--<![endif]-->
|
|
|
|
|
*/
|
|
|
|
|
const isTarget = (node) =>
|
|
|
|
|
node.type === "element" &&
|
2022-11-03 14:23:07 +08:00
|
|
|
node.prev?.type === "ieConditionalStartComment" &&
|
2018-11-15 12:35:28 +08:00
|
|
|
node.prev.sourceSpan.end.offset === node.startSourceSpan.start.offset &&
|
2022-11-03 14:23:07 +08:00
|
|
|
node.firstChild?.type === "ieConditionalEndComment" &&
|
2018-11-15 12:35:28 +08:00
|
|
|
node.firstChild.sourceSpan.start.offset === node.startSourceSpan.end.offset;
|
2021-07-01 19:46:24 +09:00
|
|
|
ast.walk((node) => {
|
2018-11-15 12:35:28 +08:00
|
|
|
if (node.children) {
|
2022-01-11 22:06:46 +09:00
|
|
|
for (let i = 0; i < node.children.length; i++) {
|
|
|
|
|
const child = node.children[i];
|
|
|
|
|
if (!isTarget(child)) {
|
|
|
|
|
continue;
|
2018-11-15 12:35:28 +08:00
|
|
|
}
|
|
|
|
|
|
2022-01-11 22:06:46 +09:00
|
|
|
const ieConditionalStartComment = child.prev;
|
|
|
|
|
const ieConditionalEndComment = child.firstChild;
|
|
|
|
|
|
|
|
|
|
// ieConditionalStartComment
|
|
|
|
|
node.removeChild(ieConditionalStartComment);
|
|
|
|
|
i--; // because a node was removed
|
|
|
|
|
|
|
|
|
|
const startSourceSpan = new ParseSourceSpan(
|
|
|
|
|
ieConditionalStartComment.sourceSpan.start,
|
|
|
|
|
ieConditionalEndComment.sourceSpan.end,
|
|
|
|
|
);
|
|
|
|
|
const sourceSpan = new ParseSourceSpan(
|
|
|
|
|
startSourceSpan.start,
|
|
|
|
|
child.sourceSpan.end,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
child.condition = ieConditionalStartComment.condition;
|
|
|
|
|
child.sourceSpan = sourceSpan;
|
|
|
|
|
child.startSourceSpan = startSourceSpan;
|
|
|
|
|
child.removeChild(ieConditionalEndComment);
|
2018-11-15 12:35:28 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-04 23:03:07 +08:00
|
|
|
function mergeNodeIntoText(ast, shouldMerge, getValue) {
|
2021-07-01 19:46:24 +09:00
|
|
|
ast.walk((node) => {
|
2018-11-04 23:03:07 +08:00
|
|
|
if (node.children) {
|
2022-01-11 22:06:46 +09:00
|
|
|
for (let i = 0; i < node.children.length; i++) {
|
|
|
|
|
const child = node.children[i];
|
2018-11-04 23:03:07 +08:00
|
|
|
|
2022-01-11 22:06:46 +09:00
|
|
|
if (child.type !== "text" && !shouldMerge(child)) {
|
|
|
|
|
continue;
|
2018-11-04 23:03:07 +08:00
|
|
|
}
|
2022-01-11 22:06:46 +09:00
|
|
|
|
|
|
|
|
if (child.type !== "text") {
|
|
|
|
|
child.type = "text";
|
|
|
|
|
child.value = getValue(child);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const prevChild = child.prev;
|
|
|
|
|
if (!prevChild || prevChild.type !== "text") {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
prevChild.value += child.value;
|
|
|
|
|
prevChild.sourceSpan = new ParseSourceSpan(
|
|
|
|
|
prevChild.sourceSpan.start,
|
|
|
|
|
child.sourceSpan.end,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
node.removeChild(child);
|
|
|
|
|
i--; // because a node was removed
|
2018-11-04 23:03:07 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function mergeCdataIntoText(ast /*, options */) {
|
|
|
|
|
return mergeNodeIntoText(
|
|
|
|
|
ast,
|
|
|
|
|
(node) => node.type === "cdata",
|
|
|
|
|
(node) => `<![CDATA[${node.value}]]>`,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function mergeSimpleElementIntoText(ast /*, options */) {
|
|
|
|
|
const isSimpleElement = (node) =>
|
|
|
|
|
node.type === "element" &&
|
|
|
|
|
node.attrs.length === 0 &&
|
|
|
|
|
node.children.length === 1 &&
|
|
|
|
|
node.firstChild.type === "text" &&
|
2023-02-24 15:41:20 +08:00
|
|
|
!htmlWhitespaceUtils.hasWhitespaceCharacter(node.children[0].value) &&
|
2018-11-04 23:03:07 +08:00
|
|
|
!node.firstChild.hasLeadingSpaces &&
|
|
|
|
|
!node.firstChild.hasTrailingSpaces &&
|
|
|
|
|
node.isLeadingSpaceSensitive &&
|
|
|
|
|
!node.hasLeadingSpaces &&
|
|
|
|
|
node.isTrailingSpaceSensitive &&
|
|
|
|
|
!node.hasTrailingSpaces &&
|
2022-11-03 14:23:07 +08:00
|
|
|
node.prev?.type === "text" &&
|
|
|
|
|
node.next?.type === "text";
|
2021-07-01 19:46:24 +09:00
|
|
|
ast.walk((node) => {
|
2018-11-04 23:03:07 +08:00
|
|
|
if (node.children) {
|
2022-01-11 22:06:46 +09:00
|
|
|
for (let i = 0; i < node.children.length; i++) {
|
|
|
|
|
const child = node.children[i];
|
|
|
|
|
if (!isSimpleElement(child)) {
|
|
|
|
|
continue;
|
2018-11-04 23:03:07 +08:00
|
|
|
}
|
2022-01-11 22:06:46 +09:00
|
|
|
|
|
|
|
|
const prevChild = child.prev;
|
|
|
|
|
const nextChild = child.next;
|
|
|
|
|
prevChild.value +=
|
|
|
|
|
`<${child.rawName}>` +
|
|
|
|
|
child.firstChild.value +
|
|
|
|
|
`</${child.rawName}>` +
|
|
|
|
|
nextChild.value;
|
|
|
|
|
prevChild.sourceSpan = new ParseSourceSpan(
|
|
|
|
|
prevChild.sourceSpan.start,
|
|
|
|
|
nextChild.sourceSpan.end,
|
|
|
|
|
);
|
|
|
|
|
prevChild.isTrailingSpaceSensitive = nextChild.isTrailingSpaceSensitive;
|
|
|
|
|
prevChild.hasTrailingSpaces = nextChild.hasTrailingSpaces;
|
|
|
|
|
|
|
|
|
|
node.removeChild(child);
|
|
|
|
|
i--; // because a node was removed
|
|
|
|
|
node.removeChild(nextChild);
|
2018-11-04 23:03:07 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function extractInterpolation(ast, options) {
|
|
|
|
|
if (options.parser === "html") {
|
2021-07-01 19:46:24 +09:00
|
|
|
return;
|
2018-11-04 23:03:07 +08:00
|
|
|
}
|
|
|
|
|
|
2024-06-18 06:52:54 +08:00
|
|
|
const interpolationRegex = /\{\{(.+?)\}\}/su;
|
2021-07-01 19:46:24 +09:00
|
|
|
ast.walk((node) => {
|
2018-11-04 23:03:07 +08:00
|
|
|
if (!canHaveInterpolation(node)) {
|
2021-07-01 19:46:24 +09:00
|
|
|
return;
|
2018-10-13 13:55:38 +08:00
|
|
|
}
|
|
|
|
|
|
2018-11-04 23:03:07 +08:00
|
|
|
for (const child of node.children) {
|
|
|
|
|
if (child.type !== "text") {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let startSourceSpan = child.sourceSpan.start;
|
|
|
|
|
let endSourceSpan = null;
|
|
|
|
|
const components = child.value.split(interpolationRegex);
|
|
|
|
|
for (
|
|
|
|
|
let i = 0;
|
|
|
|
|
i < components.length;
|
|
|
|
|
i++, startSourceSpan = endSourceSpan
|
|
|
|
|
) {
|
|
|
|
|
const value = components[i];
|
|
|
|
|
|
|
|
|
|
if (i % 2 === 0) {
|
|
|
|
|
endSourceSpan = startSourceSpan.moveBy(value.length);
|
2021-01-04 10:11:57 +08:00
|
|
|
if (value.length > 0) {
|
2022-01-11 22:06:46 +09:00
|
|
|
node.insertChildBefore(child, {
|
2018-11-04 23:03:07 +08:00
|
|
|
type: "text",
|
|
|
|
|
value,
|
|
|
|
|
sourceSpan: new ParseSourceSpan(startSourceSpan, endSourceSpan),
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
endSourceSpan = startSourceSpan.moveBy(value.length + 4); // `{{` + `}}`
|
2022-01-11 22:06:46 +09:00
|
|
|
node.insertChildBefore(child, {
|
2018-11-04 23:03:07 +08:00
|
|
|
type: "interpolation",
|
|
|
|
|
sourceSpan: new ParseSourceSpan(startSourceSpan, endSourceSpan),
|
|
|
|
|
children:
|
|
|
|
|
value.length === 0
|
|
|
|
|
? []
|
|
|
|
|
: [
|
|
|
|
|
{
|
|
|
|
|
type: "text",
|
|
|
|
|
value,
|
|
|
|
|
sourceSpan: new ParseSourceSpan(
|
|
|
|
|
startSourceSpan.moveBy(2),
|
|
|
|
|
endSourceSpan.moveBy(-2),
|
|
|
|
|
),
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-11 22:06:46 +09:00
|
|
|
node.removeChild(child);
|
|
|
|
|
}
|
2018-10-13 13:55:38 +08:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* - add `hasLeadingSpaces` field
|
|
|
|
|
* - add `hasTrailingSpaces` field
|
|
|
|
|
* - add `hasDanglingSpaces` field for parent nodes
|
2018-11-04 23:03:07 +08:00
|
|
|
* - add `isWhitespaceSensitive`, `isIndentationSensitive` field for text nodes
|
2018-10-13 13:55:38 +08:00
|
|
|
* - remove insensitive whitespaces
|
|
|
|
|
*/
|
|
|
|
|
function extractWhitespaces(ast /*, options*/) {
|
2021-07-01 19:46:24 +09:00
|
|
|
ast.walk((node) => {
|
2025-01-09 20:08:05 +08:00
|
|
|
const children = node.$children;
|
|
|
|
|
|
|
|
|
|
if (!children) {
|
2021-07-01 19:46:24 +09:00
|
|
|
return;
|
2018-10-13 13:55:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (
|
2025-01-09 20:08:05 +08:00
|
|
|
children.length === 0 ||
|
|
|
|
|
(children.length === 1 &&
|
|
|
|
|
children[0].type === "text" &&
|
|
|
|
|
htmlWhitespaceUtils.trim(children[0].value).length === 0)
|
2018-10-13 13:55:38 +08:00
|
|
|
) {
|
2025-01-09 20:08:05 +08:00
|
|
|
node.hasDanglingSpaces = children.length > 0;
|
|
|
|
|
node.$children = [];
|
2021-07-01 19:46:24 +09:00
|
|
|
return;
|
2018-10-13 13:55:38 +08:00
|
|
|
}
|
|
|
|
|
|
2018-11-04 23:03:07 +08:00
|
|
|
const isWhitespaceSensitive = isWhitespaceSensitiveNode(node);
|
|
|
|
|
const isIndentationSensitive = isIndentationSensitiveNode(node);
|
2018-10-13 13:55:38 +08:00
|
|
|
|
2022-01-11 22:06:46 +09:00
|
|
|
if (!isWhitespaceSensitive) {
|
2025-01-09 20:08:05 +08:00
|
|
|
for (let i = 0; i < children.length; i++) {
|
|
|
|
|
const child = children[i];
|
2022-01-11 22:06:46 +09:00
|
|
|
if (child.type !== "text") {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const { leadingWhitespace, text, trailingWhitespace } =
|
|
|
|
|
getLeadingAndTrailingHtmlWhitespace(child.value);
|
|
|
|
|
|
|
|
|
|
const prevChild = child.prev;
|
|
|
|
|
const nextChild = child.next;
|
|
|
|
|
|
|
|
|
|
if (!text) {
|
|
|
|
|
node.removeChild(child);
|
|
|
|
|
i--; // because a node was removed
|
|
|
|
|
|
|
|
|
|
if (leadingWhitespace || trailingWhitespace) {
|
|
|
|
|
if (prevChild) {
|
|
|
|
|
prevChild.hasTrailingSpaces = true;
|
|
|
|
|
}
|
|
|
|
|
if (nextChild) {
|
|
|
|
|
nextChild.hasLeadingSpaces = true;
|
|
|
|
|
}
|
2018-10-13 13:55:38 +08:00
|
|
|
}
|
2022-01-11 22:06:46 +09:00
|
|
|
} else {
|
|
|
|
|
child.value = text;
|
|
|
|
|
child.sourceSpan = new ParseSourceSpan(
|
|
|
|
|
child.sourceSpan.start.moveBy(leadingWhitespace.length),
|
|
|
|
|
child.sourceSpan.end.moveBy(-trailingWhitespace.length),
|
|
|
|
|
);
|
2018-10-13 13:55:38 +08:00
|
|
|
|
2020-04-25 21:56:28 +08:00
|
|
|
if (leadingWhitespace) {
|
2022-01-11 22:06:46 +09:00
|
|
|
if (prevChild) {
|
|
|
|
|
prevChild.hasTrailingSpaces = true;
|
|
|
|
|
}
|
|
|
|
|
child.hasLeadingSpaces = true;
|
2018-10-13 13:55:38 +08:00
|
|
|
}
|
2020-04-25 21:56:28 +08:00
|
|
|
if (trailingWhitespace) {
|
2022-01-11 22:06:46 +09:00
|
|
|
child.hasTrailingSpaces = true;
|
|
|
|
|
if (nextChild) {
|
|
|
|
|
nextChild.hasLeadingSpaces = true;
|
|
|
|
|
}
|
2018-10-13 13:55:38 +08:00
|
|
|
}
|
2022-01-11 22:06:46 +09:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-10-13 13:55:38 +08:00
|
|
|
|
2021-07-01 19:46:24 +09:00
|
|
|
node.isWhitespaceSensitive = isWhitespaceSensitive;
|
|
|
|
|
node.isIndentationSensitive = isIndentationSensitive;
|
2018-10-13 13:55:38 +08:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-04 23:03:07 +08:00
|
|
|
function addIsSelfClosing(ast /*, options */) {
|
2022-01-11 22:06:46 +09:00
|
|
|
ast.walk((node) => {
|
|
|
|
|
node.isSelfClosing =
|
|
|
|
|
!node.children ||
|
|
|
|
|
(node.type === "element" &&
|
|
|
|
|
(node.tagDefinition.isVoid ||
|
|
|
|
|
// self-closing
|
2022-10-03 16:38:22 +03:00
|
|
|
(node.endSourceSpan &&
|
|
|
|
|
node.startSourceSpan.start === node.endSourceSpan.start &&
|
|
|
|
|
node.startSourceSpan.end === node.endSourceSpan.end)));
|
2022-01-11 22:06:46 +09:00
|
|
|
});
|
2018-11-04 23:03:07 +08:00
|
|
|
}
|
|
|
|
|
|
2018-11-29 11:03:22 +08:00
|
|
|
function addHasHtmComponentClosingTag(ast, options) {
|
2022-01-11 22:06:46 +09:00
|
|
|
ast.walk((node) => {
|
|
|
|
|
if (node.type !== "element") {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
node.hasHtmComponentClosingTag =
|
|
|
|
|
node.endSourceSpan &&
|
2024-06-18 06:52:54 +08:00
|
|
|
/^<\s*\/\s*\/\s*>$/u.test(
|
2022-01-11 22:06:46 +09:00
|
|
|
options.originalText.slice(
|
|
|
|
|
node.endSourceSpan.start.offset,
|
|
|
|
|
node.endSourceSpan.end.offset,
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
});
|
2018-11-29 11:03:22 +08:00
|
|
|
}
|
|
|
|
|
|
2018-10-13 13:55:38 +08:00
|
|
|
function addCssDisplay(ast, options) {
|
2022-01-11 22:06:46 +09:00
|
|
|
ast.walk((node) => {
|
|
|
|
|
node.cssDisplay = getNodeCssStyleDisplay(node, options);
|
|
|
|
|
});
|
2018-10-13 13:55:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* - add `isLeadingSpaceSensitive` field
|
|
|
|
|
* - add `isTrailingSpaceSensitive` field
|
|
|
|
|
* - add `isDanglingSpaceSensitive` field for parent nodes
|
|
|
|
|
*/
|
2020-04-17 07:54:24 +09:00
|
|
|
function addIsSpaceSensitive(ast, options) {
|
2021-07-01 19:46:24 +09:00
|
|
|
ast.walk((node) => {
|
2022-01-11 22:06:46 +09:00
|
|
|
const { children } = node;
|
|
|
|
|
if (!children) {
|
2021-07-01 19:46:24 +09:00
|
|
|
return;
|
2018-10-13 13:55:38 +08:00
|
|
|
}
|
2022-01-11 22:06:46 +09:00
|
|
|
if (children.length === 0) {
|
2021-07-01 19:46:24 +09:00
|
|
|
node.isDanglingSpaceSensitive = isDanglingSpaceSensitiveNode(node);
|
|
|
|
|
return;
|
2018-10-13 13:55:38 +08:00
|
|
|
}
|
2022-01-11 22:06:46 +09:00
|
|
|
for (const child of children) {
|
|
|
|
|
child.isLeadingSpaceSensitive = isLeadingSpaceSensitiveNode(
|
|
|
|
|
child,
|
|
|
|
|
options,
|
|
|
|
|
);
|
|
|
|
|
child.isTrailingSpaceSensitive = isTrailingSpaceSensitiveNode(
|
|
|
|
|
child,
|
|
|
|
|
options,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
for (let index = 0; index < children.length; index++) {
|
|
|
|
|
const child = children[index];
|
|
|
|
|
child.isLeadingSpaceSensitive =
|
|
|
|
|
index === 0
|
|
|
|
|
? child.isLeadingSpaceSensitive
|
|
|
|
|
: child.prev.isTrailingSpaceSensitive &&
|
|
|
|
|
child.isLeadingSpaceSensitive;
|
|
|
|
|
child.isTrailingSpaceSensitive =
|
|
|
|
|
index === children.length - 1
|
|
|
|
|
? child.isTrailingSpaceSensitive
|
|
|
|
|
: child.next.isLeadingSpaceSensitive &&
|
|
|
|
|
child.isTrailingSpaceSensitive;
|
|
|
|
|
}
|
2018-10-13 13:55:38 +08:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-21 16:44:56 +08:00
|
|
|
export default preprocess;
|