You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A decent enough solution might just be to write a fresh function that takes the result of highlighting the code (an input HTML string that is a <code> or its innerHTML, parses/rewrites it, then returns an HTML string that includes line numbers.
Use it here. https://github.com/gobengo/distbin/blob/master/src/distbin-html/an-activity.ts#L45
starting point:
consthighlightedHtmlToLines=(html: string): Array<string>=>html.split('\n');// will probably need a more html-aware implementationtypeHtmlString=stringtypeHtmlRewriter=(in: HtmlString)=>HtmlString;constaddLineNumbers: HtmlRewriter=(highlightedCode: HtmlString): HtmlString=>{constlines=highlightedHtmlToLines(highlightedCode)// two-column table with cells: lineNumber, actualLineHtmlreturn` <table>${lines.map((lineStr,lineIndex)=>` <tr> <td class="lineNumber">${lineIndex}</td> <td class="lineOfCode>${lineStr}</td> </tr>`.join('\n')} </table> `}
The text was updated successfully, but these errors were encountered: