| 169 | let result = ''; |
| 170 | |
| 171 | const getCodeBlockText = (codeNode) => { |
| 172 | let text = ''; |
| 173 | |
| 174 | const appendNodeText = (currentNode) => { |
| 175 | if (currentNode.nodeType === Node.TEXT_NODE) { |
| 176 | text += currentNode.textContent; |
| 177 | return; |
| 178 | } |
| 179 | |
| 180 | if (currentNode.nodeType !== Node.ELEMENT_NODE) { |
| 181 | return; |
| 182 | } |
| 183 | |
| 184 | if (currentNode.tagName === 'BR') { |
| 185 | text += '\n'; |
| 186 | return; |
| 187 | } |
| 188 | |
| 189 | currentNode.childNodes.forEach(appendNodeText); |
| 190 | }; |
| 191 | |
| 192 | codeNode.childNodes.forEach(appendNodeText); |
| 193 | return text.replace(/\n$/, ''); |
| 194 | }; |
| 195 | |
| 196 | const normalizeCodeLanguage = (language) => { |
| 197 | const normalized = (language || '').trim().toLowerCase(); |