@@ -734,7 +734,7 @@ jobs:
734734 rejectsWorkflowDispatchPullRequest,
735735 rejectsWorkflowDispatchNonDefaultBranch,
736736 } = require(path.join(process.cwd(), ".github", "scripts", "issue-quality.cjs"));
737- const { stripTranslationBlock } = require(
737+ const { stripTranslationBlock, splitTranslationBlock } = require(
738738 path.join(process.cwd(), ".github", "scripts", "issue-translation.cjs"),
739739 );
740740
@@ -756,6 +756,17 @@ jobs:
756756 } else {
757757 issue_number = context.payload.issue.number;
758758 }
759+
760+ function translationPlainText(block) {
761+ if (!block) return "";
762+ return String(block)
763+ .replace(/<!--[\s\S]*?-->/g, " ")
764+ .replace(/<\/?details[^>]*>/gi, "\n")
765+ .replace(/<\/?summary[^>]*>/gi, "\n")
766+ .replace(/<[^>]+>/g, " ")
767+ .replace(/[ \t]+\n/g, "\n")
768+ .trim();
769+ }
759770 const actor = context.actor;
760771 const eventType = context.eventName === "issues"
761772 ? context.payload.action
@@ -791,7 +802,12 @@ jobs:
791802 return;
792803 }
793804
794- const issueBody = stripTranslationBlock(issue.body || "");
805+ const translationSplit = splitTranslationBlock(issue.body || "");
806+ const issueBody = translationSplit.sourceBody;
807+ const areaHeuristicBody = [
808+ issueBody,
809+ translationPlainText(translationSplit.block),
810+ ].filter(Boolean).join("\n\n");
795811
796812 // -----------------------------------------------------------------
797813 // Trusted-user exemption
@@ -909,14 +925,10 @@ jobs:
909925 }
910926 }
911927 const meta = AREA_LABELS[name];
912- const color = meta?.color || (name === "documentation" ? "0075ca" : "EDEDED");
913- const description = meta?.description
914- || (name === "documentation"
915- ? "Improvements or additions to documentation"
916- : name);
928+ if (!meta) return;
917929 try {
918930 await github.rest.issues.createLabel({
919- owner, repo, name, color, description,
931+ owner, repo, name, color: meta.color, description: meta. description,
920932 });
921933 core.info(`Created label "${name}".`);
922934 } catch (err) {
@@ -931,6 +943,7 @@ jobs:
931943 const areaLabels = detectAreaLabels({
932944 title: issue.title,
933945 body: issueBody,
946+ heuristicBody: areaHeuristicBody,
934947 labels,
935948 });
936949 const areaLabelsToAdd = areaLabels.filter((name) => !labels.includes(name));
@@ -1139,7 +1152,7 @@ jobs:
11391152 AREA_LABELS,
11401153 rejectsWorkflowDispatchNonDefaultBranch,
11411154 } = require(path.join(process.cwd(), ".github", "scripts", "issue-quality.cjs"));
1142- const { stripTranslationBlock } = require(
1155+ const { splitTranslationBlock } = require(
11431156 path.join(process.cwd(), ".github", "scripts", "issue-translation.cjs"),
11441157 );
11451158
@@ -1155,6 +1168,17 @@ jobs:
11551168
11561169 const { owner, repo } = context.repo;
11571170
1171+ function translationPlainText(block) {
1172+ if (!block) return "";
1173+ return String(block)
1174+ .replace(/<!--[\s\S]*?-->/g, " ")
1175+ .replace(/<\/?details[^>]*>/gi, "\n")
1176+ .replace(/<\/?summary[^>]*>/gi, "\n")
1177+ .replace(/<[^>]+>/g, " ")
1178+ .replace(/[ \t]+\n/g, "\n")
1179+ .trim();
1180+ }
1181+
11581182 async function ensureLabel(name) {
11591183 try {
11601184 await github.rest.issues.getLabel({ owner, repo, name });
@@ -1166,14 +1190,10 @@ jobs:
11661190 }
11671191 }
11681192 const meta = AREA_LABELS[name];
1169- const color = meta?.color || (name === "documentation" ? "0075ca" : "EDEDED");
1170- const description = meta?.description
1171- || (name === "documentation"
1172- ? "Improvements or additions to documentation"
1173- : name);
1193+ if (!meta) return;
11741194 try {
11751195 await github.rest.issues.createLabel({
1176- owner, repo, name, color, description,
1196+ owner, repo, name, color: meta.color, description: meta. description,
11771197 });
11781198 core.info(`Created label "${name}".`);
11791199 } catch (err) {
@@ -1197,10 +1217,16 @@ jobs:
11971217 const labels = (issue.labels || []).map((l) =>
11981218 typeof l === "string" ? l : l.name,
11991219 );
1200- const issueBody = stripTranslationBlock(issue.body || "");
1220+ const translationSplit = splitTranslationBlock(issue.body || "");
1221+ const issueBody = translationSplit.sourceBody;
1222+ const areaHeuristicBody = [
1223+ issueBody,
1224+ translationPlainText(translationSplit.block),
1225+ ].filter(Boolean).join("\n\n");
12011226 const areaLabels = detectAreaLabels({
12021227 title: issue.title,
12031228 body: issueBody,
1229+ heuristicBody: areaHeuristicBody,
12041230 labels,
12051231 });
12061232 const toAdd = areaLabels.filter((name) => !labels.includes(name));
0 commit comments