Skip to content

Commit 6c44640

Browse files
committed
refactor(audit-implementation): escape markdown and less colors
1 parent fb227a6 commit 6c44640

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

scripts/audit-implementation.mjs

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,20 +98,20 @@ async function createReport(results) {
9898

9999
report += `- **${grouped.total}** audits in total\n`;
100100
if (grouped.ok.length) {
101-
report += `- **${grouped.ok.length}** pass\n`;
101+
report += `- **${grouped.ok.length}** pass\n`;
102102
}
103103
if (grouped.warn.length) {
104-
report += `- **${grouped.warn.length}** warnings (optional)\n`;
104+
report += `- ${'⚠️'} **${grouped.warn.length}** warnings (optional)\n`;
105105
}
106106
if (grouped.error.length) {
107-
report += `- **${grouped.error.length}** errors (required)\n`;
107+
report += `- **${grouped.error.length}** errors (required)\n`;
108108
}
109109
report += `\n`;
110110

111111
if (grouped.ok.length) {
112112
report += `## Passing\n`;
113113
for (const [i, result] of grouped.ok.entries()) {
114-
report += `${i + 1}. ${result.name}\n`;
114+
report += `${i + 1}. ${escapeMarkdown(result.name)}\n`;
115115
}
116116
report += '\n';
117117
}
@@ -120,8 +120,10 @@ async function createReport(results) {
120120
report += `## Warnings\n`;
121121
report += `The server _SHOULD_ support these, but is not required.\n`;
122122
for (const [i, result] of grouped.warn.entries()) {
123-
report += `${i + 1}. ${'⚠️'} ${result.name}<br />\n`;
124-
report += ` 💬 ${result.reason}\n`;
123+
report += `${i + 1}. ${escapeMarkdown(result.name)}<br />\n`;
124+
report += '```\n';
125+
report += `${result.reason}\n`;
126+
report += '```\n';
125127
}
126128
report += '\n';
127129
}
@@ -130,8 +132,10 @@ async function createReport(results) {
130132
report += `## Errors\n`;
131133
report += `The server _MUST_ support these.\n`;
132134
for (const [i, result] of grouped.error.entries()) {
133-
report += `${i + 1}. ❌ ${result.name}<br />\n`;
134-
report += ` 💬 ${result.reason}\n`;
135+
report += `${i + 1}. ${escapeMarkdown(result.name)}<br />\n`;
136+
report += '```\n';
137+
report += `${result.reason}\n`;
138+
report += '```\n';
135139
}
136140
}
137141

@@ -146,3 +150,10 @@ async function createReport(results) {
146150
},
147151
};
148152
}
153+
154+
/**
155+
* @param {string} str
156+
*/
157+
function escapeMarkdown(str) {
158+
return str.replace(/\*/g, '\\*');
159+
}

0 commit comments

Comments
 (0)