I need to highlight a block of code but at the same time, I need the code to be placed on separate and numbered lines, to leave comments for each line of code, just as can be done on Github. I managed to do this but because I highlight the code for each line, the "SQL" code that is on several lines will not be highlighted correctly (only the first line is highlighted) and I fail to fix this. Do you have any suggestions?
if (data.success === 1) {
setCodeLanguage(translateLanguage(data.code.language));
let rows = [];
data.code.source_code.split("\n").forEach((line, index) => {
rows.push(
<tr key={index} className="line">
<td className="line-number">{index + 1}</td>
<td id={"plus" + index} className="plus-square-line">
<PlusSquareTwoTone className="plus-square" />
</td>
<td id={"codeblock" + index}
className={'language-' + codeLanguage} style={rowStyle}>
{line}
</td>
</tr>
);
});
setCodeRows(rows);
for (let i = 0; i < codeRows.length; ++i) {
hljs.highlightBlock(document.getElementById("codeblock" + i));
}