@@ -403,128 +403,6 @@ func paintTS(v: string): string =
403
403
i += 1
404
404
405
405
406
- func paintPython (v: string ): string =
407
- # paint Python code one line at a time.
408
- let myInput = sanitize (v)
409
- var i = 0
410
- var old_i = - 1
411
-
412
- while i < len (myInput):
413
- while true :
414
- if myInput[i] == '"' :
415
- i += 1
416
- var bar = " "
417
- while myInput[i] != '"' :
418
- bar &= myInput[i]
419
- i += 1
420
-
421
- i += 1
422
- result &= " <span class=\" string\" >\" " & bar & " \" </span>"
423
-
424
- for bar in @ [" <" , " >" , " dataclass" ]:
425
- if myInput[i .. ^ 1 ].startsWith (bar):
426
- result &= bar
427
- i += len (bar)
428
-
429
- for bar in @ [" def" , " class" ]:
430
- if myInput[i .. ^ 1 ].startsWith (bar):
431
- result &= " <span class=\" keyword\" >" & bar & " </span>"
432
- i += len (bar)
433
-
434
- for bar in @ [" if" , " from" , " import" ]:
435
- if myInput[i .. ^ 1 ].startsWith (bar):
436
- result &= " <span class=\" keyword-import\" >" & bar & " </span>"
437
- i += len (bar)
438
-
439
- for bar in @ [" :" , " ," , " ->" ]:
440
- if myInput[i .. ^ 1 ].startsWith (bar):
441
- result &= " <span class=\" terminator\" >" & bar & " </span>"
442
- i += len (bar)
443
-
444
- for bar in @ [" bool" , " int" , " float" , " str" , " list" , " tuple" , " Literal" ]:
445
- if myInput[i .. ^ 1 ].startsWith (bar):
446
- result &= " <span class=\" type-primitive\" >" & bar & " </span>"
447
- i += len (bar)
448
-
449
- for bar in @ [" and" , " or" ]:
450
- if myInput[i .. ^ 1 ].startsWith (bar):
451
- result &= " <span class=\" operator\" >" & bar & " </span>"
452
- i += len (bar)
453
-
454
- if old_i == i:
455
- break
456
-
457
- old_i = i
458
-
459
- result &= myInput[i]
460
- i += 1
461
-
462
-
463
- func paintPalet (v: string ): string =
464
- let myInput = v
465
- var i = 0
466
- var old_i = - 1
467
-
468
- while i < len (myInput):
469
- while true :
470
- if myInput[i] == ';' :
471
- i += 1
472
- var bar = " "
473
- while i < len (myInput):
474
- bar &= myInput[i]
475
- i += 1
476
-
477
- result &= " <span class=\" comment\" >;" & bar.sanitize & " </span>"
478
-
479
- if myInput[i] == '"' :
480
- i += 1
481
- var bar = " "
482
- while myInput[i] != '"' :
483
- bar &= myInput[i]
484
- i += 1
485
-
486
- i += 1
487
- result &= " <span class=\" string\" >\" " & bar.sanitize & " \" </span>"
488
-
489
- for bar in @ [" define/c" , " define" , " let" ]:
490
- if myInput[i .. ^ 1 ].startsWith (bar):
491
- result &= " <span class=\" keyword\" >" & bar & " </span>"
492
- i += len (bar)
493
-
494
- for bar in @ [" when" , " if" ]:
495
- if myInput[i .. ^ 1 ].startsWith (bar):
496
- result &= " <span class=\" keyword-import\" >" & bar & " </span>"
497
- i += len (bar)
498
-
499
- for bar in @ [" map" , " lambda" ]:
500
- if myInput[i .. ^ 1 ].startsWith (bar):
501
- result &= " <span class=\" function-name\" >" & bar & " </span>"
502
- i += len (bar)
503
-
504
- for bar in @ [" ." , " ->" ]:
505
- if myInput[i .. ^ 1 ].startsWith (bar):
506
- result &= " <span class=\" terminator\" >" & bar.sanitize & " </span>"
507
- i += len (bar)
508
-
509
- for bar in @ [" bool?" , " int?" , " float?" , " nat?" , " str?" , " list?" , " threshold?" ]:
510
- if myInput[i .. ^ 1 ].startsWith (bar):
511
- result &= " <span class=\" type-primitive\" >" & bar.sanitize & " </span>"
512
- i += len (bar)
513
-
514
- for bar in @ [" and" , " or" , " equal?" , " >=" , " <=" , " =" , " >" , " <" , " /" ]:
515
- if myInput[i .. ^ 1 ].startsWith (bar):
516
- result &= " <span class=\" operator\" >" & bar.sanitize & " </span>"
517
- i += len (bar)
518
-
519
- if old_i == i:
520
- break
521
-
522
- old_i = i
523
-
524
- result &= myInput[i]
525
- i += 1
526
-
527
-
528
406
proc convert (file: string , path: string ) =
529
407
let text = readFile (file)
530
408
var
@@ -672,10 +550,6 @@ proc convert(file: string, path: string) =
672
550
f.write (paintTS (obj.value))
673
551
elif lexer.langName == " json" :
674
552
f.write (paintJson (obj.value))
675
- elif lexer.langName == " python" :
676
- f.write (paintPython (obj.value))
677
- elif lexer.langName == " palet" :
678
- f.write (paintPalet (obj.value))
679
553
else :
680
554
f.write (sanitize (obj.value))
681
555
has_text = true
0 commit comments