fix: catastrophic backtracking regex pattern#21
Merged
Conversation
5 tasks
worlpaker
approved these changes
Jun 5, 2025
Owner
|
Thanks for the PR! Your detailed analysis was very helpful. That level of information requires a lot of work, and I really appreciate it! Related code part is actually for: // better support for struct type one line with semicolon(;) -before formatting with gofmt
type oneLineSemi struct{a1, a2, a3 context.Context; a4, a5 string; a6 context.Context; a7 context.Context; context.Context; a8, a9 context.Context}So your solution makes sense. I think your changes are fine. I also made a few changes to improve performance in excessive scenarios — hope that's okay :) These tests are for extreme scenarios. I am more familiar with Oniguruma, so there might be other ways to improve performance in the JS engine. JS EngineUsing js engine took: 1.3s import { createJavaScriptRegexEngine } from '@shikijs/engine-javascript';
import { createHighlighter } from 'shiki';
import fs from 'fs';
console.time('exec');
// Edited new go.tmLanguage.json
const myLang = JSON.parse(fs.readFileSync('new.json', 'utf8'));
const highlighter = await createHighlighter({
themes: ['github-light'],
langs: [myLang],
engine: createJavaScriptRegexEngine(),
});
const code = 'type GandalfServer struct { //nolint:bgolint // 222222222221222022222122022220220022021222222222020222222220222202222222222220022222222222202222222222020222222221220222220202122211222222222212012222222222222221222022222122122220220022022222222222021222222220222222222222222222122222222222202222222222220222222222221222221202222222222212222222022222222222222222222222222122222222220222220222222222022222222220222222222222222222222222222222202222222222020222222222221222220222222201222202222222212222222222222220222222222122222221220022220222222222122222222220222202222222222222122222222222212222222222022222222220211222222222022222222222222222222222222222222222222122222122122220220022121222222222121222222222222202222222222222022222222222202222222222022222222221220222221212022201222212222202112222222222222222222222222022222222222222222222222222220222222221222202222221222222222222222222222222222222222222222220212222221222122210222202222222222222222222222221222222222122122221222022222222222222121222222220222212222221222221022222222222222222222222221222222220200222221222022222222222222222022222222222222220222022222122222220220002120222222202222222222220222202222221222221122222222222202222222222122222222221200222221222222212222222222222222222222222222221222222222222022221222122220222222202220222222221212202202220222222122222222222222222222222222222222221011222221222022220222202222212122222222222222220222022222222122220220202222222222212022222222220212212202221222222122222222220202222222222221222222221201222220202222202222202222212122222222222222221222122222122122222220222121222222202020222222222212202222222121222222222222222212222202222222222222122222222222212222222202112222202020222012222222222120122222222222222222220222221222222212221020200212212202220222220222222222222222222222222021222222220222222220202022212222202222212222222222222222222222022222022122222220222122222222202121222222221222212202222222221222222222222202222222222220222222222001222222202222222222202222222222222222222222222222022222022222222222022021222222212221222222221202212222221222222222222222221212222222222120222222220122222222222122220222202222202022222222222222222222222222122022220220012121222222212022222222222222002222220222221122222222222202222222222002222222220102222221212022212222202222202022222222222222221222022222022122221220012220222222212222222222221211102212221122221022222222222222222222222012202222221110222220212122201222202222212012222222222222220222222222222222221220012020222222222222222222222200202202220122220222222220220212222222222122222222222120222222222122210222212222212102222222222222220200122222022122221221012120222222212221222022221222102202220122220122222222220202222222222112202222222221222221212122210222202222222012222222222222222100022222222222220222002220222222202120222022222210202202221122220222222220222202222222222021202222221000222221212122210222202222202212222222122222222112022222222022222221122220222222222222222222221222002212222222222022222210220202222222222112202222221100222222202122200222212222212012222222122222221201222222022122221220212220222222202020222122220212112202222022220122222212220202222222222100222222221102222220202022211222222222212112222222222222222221122222222122211221202120222222202221222122220201102202220022221022222200221222222222222012222222221102222221212022211222222222202002222222222222221002122222122022202221012020222222212220222122222211102202221022220022222201220222222222222000212222220100222222211122201222212222222102222222122222222112022222222222201222022021222222202022222122221201002212222022220222222201221202222222222220202222222121222222200222220222202222222102222222222222221012102222022022212221112122222222202121222222220222002212220022222222222210220212222222222111222222222221222220210222222222222222202222222222122222220201222222222122211222222222222222202020222122222222202212220022220122222221221212222222222111212222220000222222202222210220212222212102222222022222221112112222122022202222022121222222212021222222220200212202220222220222222222222202222222222220212222222220222222201122210211222222202212222222022222220112012222122122202221002222222222202121222122220200022222220022220122222222221202222222222202202222220120222222211022202220212222222022222222122222222222102222122222222221222221222222212020222222222200222202221022221022222201222202222222222101102222220211222222220022221202202222210202222222022222220022122222222022201222222020222222202020222122221201022222222122221102222210222222222222222021102222221210222221210022212221222222222212222222022222221202222222122022210220212022222222222021222022220211122222221022222202222202220222222222222120112222222211222220200122222201222222222202222222022222222010212221122120222221012120222222202020222022220211112202222022220102222211221202222222022200112222221222222220211022221211202222201212222222122222222211212220222021212222212220222222222122222022221200200202220222221212222201220222222222122022202222222200222222222122201212212222201212222222222222221102112221222120202122212022222222212222222122221211201202220222222102222200220212222222122101222222220211222222222222202210202222211002222222122222221200222220022222211221112120222222212222222122220222200212220122220002222221220212222222022001112222222211222222212222200201222222220102222222122222222102122221022021200121002020222222222221222222221202022202220222221122222200222212222202022012112022221121222221201022220221212022212122222222222222220210022221222121220222112222222222202122222222220221020222220122220222222200222212222222022022212022221200222222210222212220202122210102222222022222221021222221122122221222022121222222222220222022220211121212220122220212222202222222222222022220102122221021222220200022201220222022200122222222222222221221012222222020200220222020222222222222222122222211020222222022222212222220221202222222022221112122220111222222202122022222202122201122222222222022222001112220122020221122012021222212222022222022221211211212222122221012222221220202222212022012202122202000222221220222212220222222221012222222222022220121202222222022222221122221222222222220222222220201201202222222221022222202220222222202222212212022212021222220222222020201212022222102222222222222221012212220022021222122122222222222212120222222222222001202222022021022222201221222222212222100122022210000222222201222221210212122222102222222022122221111012221222221201120222021222222222220222022221201010202220022221022222222220212222202222200022222221202222221210022210210222022210012222222002122222112222221222022202120002022222202202021222222222200111222222122022222222201222202222222022001202122201112222220202122002212222022102002222222212022222120102222122222221020002021222212202022222022221222100202221122122102222220220212222212022021212222202201222221222222212202212222110202222222022022222221112220122222201121112121222212202222222222221200002202220222222102222211222202222222122102002022211102222221201122220222222022200002222222212022222200122220222122202122102221222202212120222222220222122202222022121022222222220212222212222022202222220211222220210222021222212222022022222222022222221202012222222220221220102121222212222121222022221201100202220222021212222202222202222212022112112022202020222221212122102201212022111202222222222222220110122221022021201020012222222202202222222022221201212202221122121022222220221222222212222121112222202012222220201122102211212122022112222222222122220120212220122121202120112020222212222221222222222200011222220122120122022221222222222202122210112222202122222221222222122202212222110012222222012222221111022220122020220022012121222202202020222122222200020202222122021212120201221202222212222001102222200100222222210122220211222222100222222222002222221212112221112121221121222121222212202121222022220102112222222222021202120220211202222222122022112222222020222220202222100201222022102112222222002120221222212222122020202020202020222212202122222222222120101001222122122122222221220202222202222222122122202121222222210222021222212122011012222222222022221001022222122222202221022021222212202022222222220120111210220222220102102212222212222212222022002222212001222220010122122221212222010212222222202121222120112222212021221120102220222202222220222122222121001222221022020222222212200222221212222020002022212022222222201112001122222120222012222222112220221020022221002220220220122022222220202022222122220112002000222022122212121221200202220212222211022222200112222220222222021020212220011102222212122120221122112222222121200020112221222210202122222222220120110202222222220002210221211212220222222001002122200001222221100022111212212021001222020202202120221120002220022122201022202222222202222120222122221121011211221022220212111200222222221212022011200022011221222222220012110112222121220122220212002122222221012222002121200020002221222201222122222022222210211122222222121012011212200202221212222022221222002001222222000222200112212121021222021221202120221222202222012022220221022022222200212222222122222111002022222222121002201221212212220222122220222222122022222222221112122021202121012002022112222220220011212220212121212222212221222212222021222122220010020110221022020022211210202202221212222201221022222210222222022012120002202120211112121200202122220010102222002020202120022122222212222020022022222221120200220222220002220222200202222222122010210222121120222221122012020222212022010022122122012222220012222221112120220220002120222201212021122122222002022022220122121122200200200212220202022111120122221211222220101122122201222222112222020220102120222000222222222120221022212120222211202022222222220112221210221222022202201210201222221212122200111022100100222220010012100102212120000212220111112121221000012221112121202122202022222222202120122022222012202211220222022122222201221202222222122111010022012200222222210001111101212021122212122110002021222010122221102121211121202220222211202121022022222100010102222102121122011221221212221222222012222122011001222220102012210221222121100002022121002222220111022221112221212020002221222221202222122222220212111000222012220112210201210222220222222120210122022012222222110110221212202121011212222102212221222221212222102020200021202122222222202221222122221122011002220002021112112221020222221202212121111022101101222222012201022200222220020202120111012122222010102221222120210020112020222201202221122222221111110010221000022112002212000212221212202200121222200122222221112012220211222022120002220022122020222122222220012121202022012021222201222222120022221210102112220210122112122210000212220212102122100222201111222222212202221110212221021012220220222221222012222222122022222221122022222210222121021222221201200220222200221012121222112202220222110010010202000010212221122211212022222222010012122102222120221011202221012220200222122220222211202101220122202020020001220020021202201212101212221202000210201002122000212220012010022011202021202202122001012121222120002220012122200220022120222202202110021022201222011121222011221022020222020212221222122011201102001210212220211121212222221122122022122201002022220022012222112121210021002021222221202112022122212222121010221110220212200201220202220222220012012012111021212222112221000222210022010112120210222020221120202222122021222120211222222211202100222022202020010012221211022002211200202202220202112212220102012101212221121001101011200021100002122002022221221000112221002021222222021121222202212211122122222100122112222210221212200210111212220212020100022102221021212222111012212012202221220202122212122020221002012221012122212122202220222000202221021022222101202200220101021212010221000212221202220202002112122211202222021102102012201121200212021110022221222000222221112222200222021022222012212020220222211012022222221111012002002212011222221202120022110102000120022220000222210112112220001112020202022220221100012220012022212221110020222121202200221122221101110010222200112002211220021202221202200220200022222121212222020001011110200121010112022201212222222020022220022221222122122121222011222200020222200220002001221110021122200210020222222222220101021112020001022220101122022110220121122112022121222222020002012220122222221120012121022211222220221122212122120010221100202122101221211202221212000012222012022001112222101101112011210122021202022020202122021211102221002022200222202121122002202121220222202212000211222121000202212210111202222222022220212112011121202220022000201210200022111222222011122221121112102221102022221220012220222021212011022022221220222010220021011002212220122212222222122000100202001102022222221111101201222201121112221111202221122122122222112121210021222020122210212120122022221011210221220121112102202202110212222222002010222122020202212221112102110102021220022002220110002221121100112221022121222120120120022212112022220122221002101110211021211012200201112202221222221200010012210022202222221122020002221210200022222000212121220121012222022121211120001222022220122122020022212220112200202220021002110222110222221222120202121102222010222222222001210021122111220202022001122021121020022220012222220122221021122121222112221222201002001212222011121211121200202202221202210220222102211112102221212221200111210002121112121121122221120112212221212121221221201222122000202202222022202210002000200221222221002211221202221212102122001202110221102221221221212200022111002122120201022122120002012220002220200221020020122102122022022222202010112211211102201111000221220212220212122210210222021120002201221210120000010001220002020012112120122021122221122021200120121020222012002000221222222210000000001121022021110211022222220202102111210222011201212210111112011211100021100102122012102122022111102220112022222222102220222212202210221112220020201120120100122200211220202212221212121021000102101111202201212121012022202011201212021210002020022202222220112221212001202022022202012120022112221001022120011202001222020200202202222222111212110112011222022221111220211121201010010122221101122220220212202221122222201001112122022101122121222002211122010120110200100221012211001222221222101211102102112111102200121222120212000221102022120001122220022112122221112021220200122021222201222210020112220011212010212020020022211201011202222222222112020102010002002211102002101201212011110102120211012221121110202220202122202000021020122012002121022012212200001101112022212201022212121202222222102220212202202221022211011110112200222121201002122002222221020002122221222120200210221220222102112012222012202212212221000220222011012210012202221222211101220012010012112201210121122202222210110122220010002120220121222221102220202011212220222220102120222202222110022010202201200022002210212212221222021200010112100100120210020200101222212021201222122000112222220120102220122122221222101122122211002122020210212021221210021112112012210211012202221212012220202222200102221221012001111001012000020202121111222220220020102220012120210010221020122012112221220212200102220021110111222201220211012212221202111112210122211220111220110211120120111000011012121221111000211002021100121001010220000102000102000022112202002201220000222221220120121000002000101020012212101111012100020101220000120000002021111000201';
const result = highlighter.codeToHtml(
code, { lang: myLang, theme: 'github-light' }
);
console.timeEnd('exec');
// Output
// exec: 1.359sOnigurumaUsing oniguruma took: 107ms. import { createOnigurumaEngine } from 'shiki/engine/oniguruma';
import { createHighlighter } from 'shiki';
import fs from 'fs';
console.time('exec');
// Edited new go.tmLanguage.json
const myLang = JSON.parse(fs.readFileSync('new.json', 'utf8'));
const highlighter = await createHighlighter({
themes: ['github-light'],
langs: [myLang],
engine: createOnigurumaEngine(import('shiki/wasm')),
});
const code = 'type GandalfServer struct { //nolint:bgolint // 222222222221222022222122022220220022021222222222020222222220222202222222222220022222222222202222222222020222222221220222220202122211222222222212012222222222222221222022222122122220220022022222222222021222222220222222222222222222122222222222202222222222220222222222221222221202222222222212222222022222222222222222222222222122222222220222220222222222022222222220222222222222222222222222222222202222222222020222222222221222220222222201222202222222212222222222222220222222222122222221220022220222222222122222222220222202222222222222122222222222212222222222022222222220211222222222022222222222222222222222222222222222222122222122122220220022121222222222121222222222222202222222222222022222222222202222222222022222222221220222221212022201222212222202112222222222222222222222222022222222222222222222222222220222222221222202222221222222222222222222222222222222222222222220212222221222122210222202222222222222222222222221222222222122122221222022222222222222121222222220222212222221222221022222222222222222222222221222222220200222221222022222222222222222022222222222222220222022222122222220220002120222222202222222222220222202222221222221122222222222202222222222122222222221200222221222222212222222222222222222222222222221222222222222022221222122220222222202220222222221212202202220222222122222222222222222222222222222222221011222221222022220222202222212122222222222222220222022222222122220220202222222222212022222222220212212202221222222122222222220202222222222221222222221201222220202222202222202222212122222222222222221222122222122122222220222121222222202020222222222212202222222121222222222222222212222202222222222222122222222222212222222202112222202020222012222222222120122222222222222222220222221222222212221020200212212202220222220222222222222222222222222021222222220222222220202022212222202222212222222222222222222222022222022122222220222122222222202121222222221222212202222222221222222222222202222222222220222222222001222222202222222222202222222222222222222222222222022222022222222222022021222222212221222222221202212222221222222222222222221212222222222120222222220122222222222122220222202222202022222222222222222222222222122022220220012121222222212022222222222222002222220222221122222222222202222222222002222222220102222221212022212222202222202022222222222222221222022222022122221220012220222222212222222222221211102212221122221022222222222222222222222012202222221110222220212122201222202222212012222222222222220222222222222222221220012020222222222222222222222200202202220122220222222220220212222222222122222222222120222222222122210222212222212102222222222222220200122222022122221221012120222222212221222022221222102202220122220122222222220202222222222112202222222221222221212122210222202222222012222222222222222100022222222222220222002220222222202120222022222210202202221122220222222220222202222222222021202222221000222221212122210222202222202212222222122222222112022222222022222221122220222222222222222222221222002212222222222022222210220202222222222112202222221100222222202122200222212222212012222222122222221201222222022122221220212220222222202020222122220212112202222022220122222212220202222222222100222222221102222220202022211222222222212112222222222222222221122222222122211221202120222222202221222122220201102202220022221022222200221222222222222012222222221102222221212022211222222222202002222222222222221002122222122022202221012020222222212220222122222211102202221022220022222201220222222222222000212222220100222222211122201222212222222102222222122222222112022222222222201222022021222222202022222122221201002212222022220222222201221202222222222220202222222121222222200222220222202222222102222222222222221012102222022022212221112122222222202121222222220222002212220022222222222210220212222222222111222222222221222220210222222222222222202222222222122222220201222222222122211222222222222222202020222122222222202212220022220122222221221212222222222111212222220000222222202222210220212222212102222222022222221112112222122022202222022121222222212021222222220200212202220222220222222222222202222222222220212222222220222222201122210211222222202212222222022222220112012222122122202221002222222222202121222122220200022222220022220122222222221202222222222202202222220120222222211022202220212222222022222222122222222222102222122222222221222221222222212020222222222200222202221022221022222201222202222222222101102222220211222222220022221202202222210202222222022222220022122222222022201222222020222222202020222122221201022222222122221102222210222222222222222021102222221210222221210022212221222222222212222222022222221202222222122022210220212022222222222021222022220211122222221022222202222202220222222222222120112222222211222220200122222201222222222202222222022222222010212221122120222221012120222222202020222022220211112202222022220102222211221202222222022200112222221222222220211022221211202222201212222222122222222211212220222021212222212220222222222122222022221200200202220222221212222201220222222222122022202222222200222222222122201212212222201212222222222222221102112221222120202122212022222222212222222122221211201202220222222102222200220212222222122101222222220211222222222222202210202222211002222222122222221200222220022222211221112120222222212222222122220222200212220122220002222221220212222222022001112222222211222222212222200201222222220102222222122222222102122221022021200121002020222222222221222222221202022202220222221122222200222212222202022012112022221121222221201022220221212022212122222222222222220210022221222121220222112222222222202122222222220221020222220122220222222200222212222222022022212022221200222222210222212220202122210102222222022222221021222221122122221222022121222222222220222022220211121212220122220212222202222222222222022220102122221021222220200022201220222022200122222222222222221221012222222020200220222020222222222222222122222211020222222022222212222220221202222222022221112122220111222222202122022222202122201122222222222022222001112220122020221122012021222212222022222022221211211212222122221012222221220202222212022012202122202000222221220222212220222222221012222222222022220121202222222022222221122221222222222220222222220201201202222222221022222202220222222202222212212022212021222220222222020201212022222102222222222222221012212220022021222122122222222222212120222222222222001202222022021022222201221222222212222100122022210000222222201222221210212122222102222222022122221111012221222221201120222021222222222220222022221201010202220022221022222222220212222202222200022222221202222221210022210210222022210012222222002122222112222221222022202120002022222202202021222222222200111222222122022222222201222202222222022001202122201112222220202122002212222022102002222222212022222120102222122222221020002021222212202022222022221222100202221122122102222220220212222212022021212222202201222221222222212202212222110202222222022022222221112220122222201121112121222212202222222222221200002202220222222102222211222202222222122102002022211102222221201122220222222022200002222222212022222200122220222122202122102221222202212120222222220222122202222022121022222222220212222212222022202222220211222220210222021222212222022022222222022222221202012222222220221220102121222212222121222022221201100202220222021212222202222202222212022112112022202020222221212122102201212022111202222222222222220110122221022021201020012222222202202222222022221201212202221122121022222220221222222212222121112222202012222220201122102211212122022112222222222122220120212220122121202120112020222212222221222222222200011222220122120122022221222222222202122210112222202122222221222222122202212222110012222222012222221111022220122020220022012121222202202020222122222200020202222122021212120201221202222212222001102222200100222222210122220211222222100222222222002222221212112221112121221121222121222212202121222022220102112222222222021202120220211202222222122022112222222020222220202222100201222022102112222222002120221222212222122020202020202020222212202122222222222120101001222122122122222221220202222202222222122122202121222222210222021222212122011012222222222022221001022222122222202221022021222212202022222222220120111210220222220102102212222212222212222022002222212001222220010122122221212222010212222222202121222120112222212021221120102220222202222220222122222121001222221022020222222212200222221212222020002022212022222222201112001122222120222012222222112220221020022221002220220220122022222220202022222122220112002000222022122212121221200202220212222211022222200112222220222222021020212220011102222212122120221122112222222121200020112221222210202122222222220120110202222222220002210221211212220222222001002122200001222221100022111212212021001222020202202120221120002220022122201022202222222202222120222122221121011211221022220212111200222222221212022011200022011221222222220012110112222121220122220212002122222221012222002121200020002221222201222122222022222210211122222222121012011212200202221212222022221222002001222222000222200112212121021222021221202120221222202222012022220221022022222200212222222122222111002022222222121002201221212212220222122220222222122022222222221112122021202121012002022112222220220011212220212121212222212221222212222021222122220010020110221022020022211210202202221212222201221022222210222222022012120002202120211112121200202122220010102222002020202120022122222212222020022022222221120200220222220002220222200202222222122010210222121120222221122012020222212022010022122122012222220012222221112120220220002120222201212021122122222002022022220122121122200200200212220202022111120122221211222220101122122201222222112222020220102120222000222222222120221022212120222211202022222222220112221210221222022202201210201222221212122200111022100100222220010012100102212120000212220111112121221000012221112121202122202022222222202120122022222012202211220222022122222201221202222222122111010022012200222222210001111101212021122212122110002021222010122221102121211121202220222211202121022022222100010102222102121122011221221212221222222012222122011001222220102012210221222121100002022121002222220111022221112221212020002221222221202222122222220212111000222012220112210201210222220222222120210122022012222222110110221212202121011212222102212221222221212222102020200021202122222222202221222122221122011002220002021112112221020222221202212121111022101101222222012201022200222220020202120111012122222010102221222120210020112020222201202221122222221111110010221000022112002212000212221212202200121222200122222221112012220211222022120002220022122020222122222220012121202022012021222201222222120022221210102112220210122112122210000212220212102122100222201111222222212202221110212221021012220220222221222012222222122022222221122022222210222121021222221201200220222200221012121222112202220222110010010202000010212221122211212022222222010012122102222120221011202221012220200222122220222211202101220122202020020001220020021202201212101212221202000210201002122000212220012010022011202021202202122001012121222120002220012122200220022120222202202110021022201222011121222011221022020222020212221222122011201102001210212220211121212222221122122022122201002022220022012222112121210021002021222221202112022122212222121010221110220212200201220202220222220012012012111021212222112221000222210022010112120210222020221120202222122021222120211222222211202100222022202020010012221211022002211200202202220202112212220102012101212221121001101011200021100002122002022221221000112221002021222222021121222202212211122122222100122112222210221212200210111212220212020100022102221021212222111012212012202221220202122212122020221002012221012122212122202220222000202221021022222101202200220101021212010221000212221202220202002112122211202222021102102012201121200212021110022221222000222221112222200222021022222012212020220222211012022222221111012002002212011222221202120022110102000120022220000222210112112220001112020202022220221100012220012022212221110020222121202200221122221101110010222200112002211220021202221202200220200022222121212222020001011110200121010112022201212222222020022220022221222122122121222011222200020222200220002001221110021122200210020222222222220101021112020001022220101122022110220121122112022121222222020002012220122222221120012121022211222220221122212122120010221100202122101221211202221212000012222012022001112222101101112011210122021202022020202122021211102221002022200222202121122002202121220222202212000211222121000202212210111202222222022220212112011121202220022000201210200022111222222011122221121112102221102022221220012220222021212011022022221220222010220021011002212220122212222222122000100202001102022222221111101201222201121112221111202221122122122222112121210021222020122210212120122022221011210221220121112102202202110212222222002010222122020202212221112102110102021220022002220110002221121100112221022121222120120120022212112022220122221002101110211021211012200201112202221222221200010012210022202222221122020002221210200022222000212121220121012222022121211120001222022220122122020022212220112200202220021002110222110222221222120202121102222010222222222001210021122111220202022001122021121020022220012222220122221021122121222112221222201002001212222011121211121200202202221202210220222102211112102221212221200111210002121112121121122221120112212221212121221221201222122000202202222022202210002000200221222221002211221202221212102122001202110221102221221221212200022111002122120201022122120002012220002220200221020020122102122022022222202010112211211102201111000221220212220212122210210222021120002201221210120000010001220002020012112120122021122221122021200120121020222012002000221222222210000000001121022021110211022222220202102111210222011201212210111112011211100021100102122012102122022111102220112022222222102220222212202210221112220020201120120100122200211220202212221212121021000102101111202201212121012022202011201212021210002020022202222220112221212001202022022202012120022112221001022120011202001222020200202202222222111212110112011222022221111220211121201010010122221101122220220212202221122222201001112122022101122121222002211122010120110200100221012211001222221222101211102102112111102200121222120212000221102022120001122220022112122221112021220200122021222201222210020112220011212010212020020022211201011202222222222112020102010002002211102002101201212011110102120211012221121110202220202122202000021020122012002121022012212200001101112022212201022212121202222222102220212202202221022211011110112200222121201002122002222221020002122221222120200210221220222102112012222012202212212221000220222011012210012202221222211101220012010012112201210121122202222210110122220010002120220121222221102220202011212220222220102120222202222110022010202201200022002210212212221222021200010112100100120210020200101222212021201222122000112222220120102220122122221222101122122211002122020210212021221210021112112012210211012202221212012220202222200102221221012001111001012000020202121111222220220020102220012120210010221020122012112221220212200102220021110111222201220211012212221202111112210122211220111220110211120120111000011012121221111000211002021100121001010220000102000102000022112202002201220000222221220120121000002000101020012212101111012100020101220000120000002021111000201';
const result = highlighter.codeToHtml(
code, { lang: myLang, theme: 'github-light' }
);
console.timeEnd('exec');
// Output
// exec: 107.668msI've published v0.8.4 |
Contributor
Author
|
Thanks to merge, very professional modification and rigorous test cases. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Link issue shikijs/shiki#1026
Describe the bug
When parse code
the regex
will cause catastrophic backtracking
Core changed
Change
[\\S]+to[^\\s/]to avoid comments//Tests
All passed