@@ -187,36 +187,47 @@ export const transformHeadingNode = (entry, remark, node, index, parent) => {
187187 undefined,
188188 { textHandling: { boundaries: 'preserve' } }
189189 ).node.children;
190+ // Helper to recursively extract all text from a node and its children
191+ /**
192+ *
193+ * @param node
194+ */
195+ function extractText(node) {
196+ if (!node) {
197+ return '';
198+ }
199+ if (typeof node.value === 'string') {
200+ return node.value;
201+ }
202+ if (Array.isArray(node.children)) {
203+ return node.children.map(extractText).join('');
204+ }
205+ return '';
206+ }
190207
191208 // Derive plain text for type matching
192- const typeText = sliced
193- .map(n => {
194- if (n.type === 'text') {
195- return n.value;
196- }
197- if (n.type === 'inlineCode') {
198- return n.value;
199- }
200- if (n.type === 'link' && Array.isArray(n.children)) {
201- return n.children.map(c => c.value || '').join('');
202- }
203- return '';
204- })
205- .join('')
206- .trim()
207- .toLowerCase();
209+ const typeText = sliced.map(extractText).join('').trim().toLowerCase();
208210
209211 // Map user-facing deprecation types to AlertBox levels
210212 // documentation / compilation -> blue (`info`)
211213 // runtime / application -> orange (`warning`)
212214 // fallback -> danger (red)
213215 let level = 'danger';
214216
215- if (typeText.includes('documentation') || typeText.includes('compil')) {
217+ // Use stricter matching to avoid false positives (e.g., "compilation" inside "End-of-Life")
218+ const normalizedTypeText = typeText
219+ .replace(/[.,]/g, ' ')
220+ .split(/\s+/)
221+ .filter(Boolean);
222+
223+ if (
224+ normalizedTypeText.includes('documentation') ||
225+ normalizedTypeText.includes('compilation')
226+ ) {
216227 level = 'info';
217228 } else if (
218- typeText .includes('runtime') ||
219- typeText .includes('application')
229+ normalizedTypeText .includes('runtime') ||
230+ normalizedTypeText .includes('application')
220231 ) {
221232 level = 'warning';
222233 }
0 commit comments