-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcustom.js
970 lines (795 loc) · 36.3 KB
/
custom.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
// ------------------------------------------- Settings -------------------------------------------
var cm = null; // codemirror
var doc_str = null;
var word_wrap = true;
var font_size = 14;
// ------------------------------------------- Character Highlighting -------------------------------------------
// arrays used for storing character highlighting (marking) set to code mirror
var greek_extended_markers = [];
var greek_coptic_markers = [];
var number_markers = [];
var latin_markers = [];
var unwanted_markers = [];
var punctuation_markers = [];
// UI settings (checkboxes) start by default true
var mark_greek_extended = true;
var mark_greek_coptic = true;
var mark_numbers = true;
var mark_latin_red = true;
var mark_unwanted = true;
var mark_punctuation = true;
// Regular Expression Objects to be used with the highlighting function: mark()
const regex_punctuation = /\t|\.|\,|\’| |…|:|;|!|«|»|-/g;
const regex_greek_extended = /[\u1F00-\u1FFF]/g;
const regex_greek_coptic = /[\u0370-\u03FF]/g;
const regex_numbers = /[\u0028-\u002b]|[\u002f-\u0039]/g;
const regex_latin = /[\u003C-\u007F]/g;
const regex_unwanted = /\"|\'|\/|µ|∆|·|˙|΄|᾽|ι|᾿|῀|῁|῍|῎|῏|῝|῞|῟|῭|΅|`|´|῾|\‘|“|”|ʼ|ʽ/g;
// string values of CSS class names for highlighting characters
var char_class_punctuation = "punctuation";
var char_class_gr_ext = "gr-ext";
var char_class_gr_coptic = "gr-coptic";
var char_class_numbers = "num";
var char_class_latin = "latin";
var char_class_unwanted = "unwanted";
// ------------------------------------------- - - - - - - - - - - - - ------------------------------------------
$(document).ready(function(){
cm = CodeMirror(document.body,{
theme:"monokai",
lineNumbers: true,
lineWrapping: word_wrap
});
cm.setSize("100%", "100%");
cm.focus();
// cm.getDoc().setValue('\n');
cm.on('change',function(){
if (mark_greek_extended) {
clear_greek_extended_markers();
mark_greek_extended_text();
}
if (mark_greek_coptic) {
clear_greek_coptic_markers();
mark_greek_coptic_text();
}
if (mark_numbers) {
clear_number_markers();
mark_numbers_text();
}
if (mark_latin_red) {
clear_latin_markers();
mark_latin_text();
}
if (mark_punctuation) {
clear_punctuation_markers();
mark_punctuation_text();
}
if (mark_unwanted) {
clear_unwanted_markers();
mark_unwanted_text();
}
});
// ------------------------------------------- Button Listeners ("Polytonic" section) -------------------------------------------
$(".btn-rp-daseia-psili").on('click',function(event){
event.preventDefault();
doc_str = cm.getDoc().getValue();
doc_str = doc_str
.replace(/Ἀ|Ἁ|ᾈ|ᾉ|ᾼ/g, "Α")
.replace(/Ἐ|Ἑ/g, "Ε")
.replace(/Ἠ|Ἡ|ᾘ|ᾙ/g, "Η")
.replace(/Ἰ|Ἱ/g, "Ι")
.replace(/Ὀ|Ὁ/g, "Ο")
.replace(/Ὑ/g, "Υ") // ypsilon can't take psili
.replace(/Ὠ|Ὡ|ᾨ|ᾩ/g, "Ω")
.replace(/Ῥ/g, "Ρ");
doc_str = doc_str
.replace(/ἀ|ἁ|ᾀ|ᾁ|ᾳ/g, "α")
.replace(/ἐ|ἑ/g, "ε")
.replace(/ἠ|ἡ|ᾐ|ᾑ|ῃ/g, "η")
.replace(/ἰ|ἱ/g, "ι")
.replace(/ὀ|ὁ/g, "ο")
.replace(/ὐ|ὑ/g, "υ")
.replace(/ὠ|ὡ|ᾠ|ᾡ/g, "ω")
.replace(/ῤ|ῥ/g, "ρ");
cm.getDoc().setValue(doc_str);
});
$(".btn-rp-daseia-psili-tonos").on('click',function(event){
event.preventDefault();
doc_str = cm.getDoc().getValue();
doc_str = doc_str
.replace(/Ἂ|Ἃ|Ἄ|Ἅ|Ἆ|Ἇ|ᾊ|ᾋ|ᾌ|ᾍ|ᾎ|ᾏ|Ὰ|Ά/g, "Ά")
.replace(/Ἒ|Ἓ|Ἔ|Ἕ|Ὲ|Έ/g, "Έ")
.replace(/Ἢ|Ἣ|Ἤ|Ἥ|Ἦ|Ἧ|ᾚ|ᾛ|ᾜ|ᾝ|ᾞ|ᾟ|Ὴ|Ή/g, "Ή")
.replace(/Ἲ|Ἳ|Ἴ|Ἵ|Ἶ|Ἷ|Ὶ|Ί/g, "Ί")
.replace(/Ὂ|Ὃ|Ὄ|Ὅ|Ὸ|Ό/g, "Ό")
.replace(/Ὓ|Ὕ|Ὗ|Ὺ|Ύ/g, "Ύ")
.replace(/Ὢ|Ὣ|Ὤ|Ὥ|Ὦ|Ὧ|ᾪ|ᾫ|ᾬ|ᾭ|ᾮ|ᾯ|Ὼ|Ώ/g, "Ώ");
doc_str = doc_str
.replace(/ἂ|ἃ|ἄ|ἅ|ἆ|ἇ|ὰ|ά|ᾂ|ᾃ|ᾄ|ᾅ|ᾆ|ᾇ|ᾲ|ᾴ|ᾶ|ᾷ/g, "ά")
.replace(/ἒ|ἓ|ἔ|ἕ|ὲ|έ/g, "έ")
.replace(/ἢ|ἣ|ἤ|ἥ|ἦ|ἧ|ὴ|ή|ᾒ|ᾓ|ᾔ|ᾕ|ᾖ|ᾗ|ῂ|ῄ|ῆ|ῇ/g, "ή")
.replace(/ἲ|ἳ|ἴ|ἵ|ἶ|ἷ|ὶ|ί|ῖ/g, "ί")
.replace(/ῒ|ΐ|ῗ/g, "ΐ")
.replace(/ὂ|ὃ|ὄ|ὅ|ὸ|ό/g, "ό")
.replace(/ὒ|ὓ|ὔ|ὕ|ὖ|ὗ|ὺ|ύ|ῦ/g, "ύ")
.replace(/ῢ|ΰ|ῧ/g, "ΰ")
.replace(/ὢ|ὣ|ὤ|ὥ|ὦ|ὧ|ὼ|ώ|ᾢ|ᾣ|ᾤ|ᾥ|ᾦ|ᾧ|ῲ|ῴ|ῶ|ῷ/g, "ώ");
cm.getDoc().setValue(doc_str);
});
$(".btn-rp-n-grams").on('click',function(event){
event.preventDefault();
doc_str = cm.getDoc().getValue();
// 2-grams
doc_str = doc_str
.replace(/(\n| |\,|\.|\!|\;)άς(\n| |\,|\.|\!|\;)/g, '$1ας$2')
.replace(/(\n| |\,|\.|\!|\;)Άς(\n| |\,|\.|\!|\;)/g, '$1Ας$2')
.replace(/(\n| |\,|\.|\!|\;)άν(\n| |\,|\.|\!|\;)/g, '$1αν$2')
.replace(/(\n| |\,|\.|\!|\;)Άν(\n| |\,|\.|\!|\;)/g, '$1Αν$2')
.replace(/(\n| |\,|\.|\!|\;)άχ(\n| |\,|\.|\!|\;)/g, '$1αχ$2')
.replace(/(\n| |\,|\.|\!|\;)Άχ(\n| |\,|\.|\!|\;)/g, '$1Αχ$2')
.replace(/(\n| |\,|\.|\!|\;)γή(\n| |\,|\.|\!|\;)/g, '$1γη$2')
.replace(/(\n| |\,|\.|\!|\;)Γή(\n| |\,|\.|\!|\;)/g, '$1Γη$2')
.replace(/(\n| |\,|\.|\!|\;)δέ(\n| |\,|\.|\!|\;)/g, '$1δε$2')
.replace(/(\n| |\,|\.|\!|\;)Δέ(\n| |\,|\.|\!|\;)/g, '$1Δε$2')
.replace(/(\n| |\,|\.|\!|\;)ζώ(\n| |\,|\.|\!|\;)/g, '$1ζω$2')
.replace(/(\n| |\,|\.|\!|\;)Ζώ(\n| |\,|\.|\!|\;)/g, '$1Ζω$2')
.replace(/(\n| |\,|\.|\!|\;)θά(\n| |\,|\.|\!|\;)/g, '$1θα$2')
.replace(/(\n| |\,|\.|\!|\;)Θά(\n| |\,|\.|\!|\;)/g, '$1Θα$2')
.replace(/(\n| |\,|\.|\!|\;)θέ(\n| |\,|\.|\!|\;)/g, '$1θε$2')
.replace(/(\n| |\,|\.|\!|\;)Θέ(\n| |\,|\.|\!|\;)/g, '$1Θε$2')
.replace(/(\n| |\,|\.|\!|\;)μά(\n| |\,|\.|\!|\;)/g, '$1μα$2')
.replace(/(\n| |\,|\.|\!|\;)Μά(\n| |\,|\.|\!|\;)/g, '$1Μα$2')
.replace(/(\n| |\,|\.|\!|\;)μέ(\n| |\,|\.|\!|\;)/g, '$1με$2')
.replace(/(\n| |\,|\.|\!|\;)Μέ(\n| |\,|\.|\!|\;)/g, '$1Με$2')
.replace(/(\n| |\,|\.|\!|\;)μή(\n| |\,|\.|\!|\;)/g, '$1μη$2')
.replace(/(\n| |\,|\.|\!|\;)Μή(\n| |\,|\.|\!|\;)/g, '$1Μη$2')
.replace(/(\n| |\,|\.|\!|\;)νά(\n| |\,|\.|\!|\;)/g, '$1να$2')
.replace(/(\n| |\,|\.|\!|\;)Νά(\n| |\,|\.|\!|\;)/g, '$1Να$2')
.replace(/(\n| |\,|\.|\!|\;)πώ(\n| |\,|\.|\!|\;)/g, '$1πω$2')
.replace(/(\n| |\,|\.|\!|\;)Πώ(\n| |\,|\.|\!|\;)/g, '$1Πω$2')
.replace(/(\n| |\,|\.|\!|\;)σέ(\n| |\,|\.|\!|\;)/g, '$1σε$2')
.replace(/(\n| |\,|\.|\!|\;)Σέ(\n| |\,|\.|\!|\;)/g, '$1Σε$2')
.replace(/(\n| |\,|\.|\!|\;)σύ(\n| |\,|\.|\!|\;)/g, '$1συ$2')
.replace(/(\n| |\,|\.|\!|\;)Σύ(\n| |\,|\.|\!|\;)/g, '$1Συ$2')
.replace(/(\n| |\,|\.|\!|\;)τά(\n| |\,|\.|\!|\;)/g, '$1τα$2')
.replace(/(\n| |\,|\.|\!|\;)Τά(\n| |\,|\.|\!|\;)/g, '$1Τα$2')
.replace(/(\n| |\,|\.|\!|\;)τή(\n| |\,|\.|\!|\;)/g, '$1τη$2')
.replace(/(\n| |\,|\.|\!|\;)Τή(\n| |\,|\.|\!|\;)/g, '$1Τη$2')
.replace(/(\n| |\,|\.|\!|\;)τί(\n| |\,|\.|\!|\;)/g, '$1τι$2')
.replace(/(\n| |\,|\.|\!|\;)Τί(\n| |\,|\.|\!|\;)/g, '$1Τι$2')
.replace(/(\n| |\,|\.|\!|\;)τό(\n| |\,|\.|\!|\;)/g, '$1το$2')
.replace(/(\n| |\,|\.|\!|\;)Τό(\n| |\,|\.|\!|\;)/g, '$1Το$2')
.replace(/(\n| |\,|\.|\!|\;)ώς(\n| |\,|\.|\!|\;)/g, '$1ως$2')
.replace(/(\n| |\,|\.|\!|\;)Ώς(\n| |\,|\.|\!|\;)/g, '$1Ως$2');
// 3-grams
doc_str = doc_str
.replace(/(\n| |\,|\.|\!|\;)βρώ(\n| |\,|\.|\!|\;)/g, '$1βρω$2')
.replace(/(\n| |\,|\.|\!|\;)Βρώ(\n| |\,|\.|\!|\;)/g, '$1Βρω$2')
.replace(/(\n| |\,|\.|\!|\;)γιά(\n| |\,|\.|\!|\;)/g, '$1για$2')
.replace(/(\n| |\,|\.|\!|\;)Γιά(\n| |\,|\.|\!|\;)/g, '$1Για$2')
.replace(/(\n| |\,|\.|\!|\;)γής(\n| |\,|\.|\!|\;)/g, '$1γης$2')
.replace(/(\n| |\,|\.|\!|\;)Γής(\n| |\,|\.|\!|\;)/g, '$1Γης$2')
.replace(/(\n| |\,|\.|\!|\;)δεί(\n| |\,|\.|\!|\;)/g, '$1δει$2')
.replace(/(\n| |\,|\.|\!|\;)Δεί(\n| |\,|\.|\!|\;)/g, '$1Δει$2')
.replace(/(\n| |\,|\.|\!|\;)δέν(\n| |\,|\.|\!|\;)/g, '$1δεν$2')
.replace(/(\n| |\,|\.|\!|\;)Δέν(\n| |\,|\.|\!|\;)/g, '$1Δεν$2')
.replace(/(\n| |\,|\.|\!|\;)δές(\n| |\,|\.|\!|\;)/g, '$1δες$2')
.replace(/(\n| |\,|\.|\!|\;)Δές(\n| |\,|\.|\!|\;)/g, '$1Δες$2')
.replace(/(\n| |\,|\.|\!|\;)δυό(\n| |\,|\.|\!|\;)/g, '$1δυο$2')
.replace(/(\n| |\,|\.|\!|\;)Δυό(\n| |\,|\.|\!|\;)/g, '$1Δυο$2')
.replace(/(\n| |\,|\.|\!|\;)ζεί(\n| |\,|\.|\!|\;)/g, '$1ζει$2')
.replace(/(\n| |\,|\.|\!|\;)Ζεί(\n| |\,|\.|\!|\;)/g, '$1Ζει$2')
.replace(/(\n| |\,|\.|\!|\;)θές(\n| |\,|\.|\!|\;)/g, '$1θες$2')
.replace(/(\n| |\,|\.|\!|\;)Θές(\n| |\,|\.|\!|\;)/g, '$1Θες$2')
.replace(/(\n| |\,|\.|\!|\;)καί(\n| |\,|\.|\!|\;)/g, '$1και$2')
.replace(/(\n| |\,|\.|\!|\;)Καί(\n| |\,|\.|\!|\;)/g, '$1Και$2')
.replace(/(\n| |\,|\.|\!|\;)λές(\n| |\,|\.|\!|\;)/g, '$1λες$2')
.replace(/(\n| |\,|\.|\!|\;)Λές(\n| |\,|\.|\!|\;)/g, '$1Λες$2')
.replace(/(\n| |\,|\.|\!|\;)μάς(\n| |\,|\.|\!|\;)/g, '$1μας$2')
.replace(/(\n| |\,|\.|\!|\;)Μάς(\n| |\,|\.|\!|\;)/g, '$1Μας$2')
.replace(/(\n| |\,|\.|\!|\;)μές(\n| |\,|\.|\!|\;)/g, '$1μες$2')
.replace(/(\n| |\,|\.|\!|\;)Μές(\n| |\,|\.|\!|\;)/g, '$1Μες$2')
.replace(/(\n| |\,|\.|\!|\;)μήν(\n| |\,|\.|\!|\;)/g, '$1μην$2')
.replace(/(\n| |\,|\.|\!|\;)Μήν(\n| |\,|\.|\!|\;)/g, '$1Μην$2')
.replace(/(\n| |\,|\.|\!|\;)μιά(\n| |\,|\.|\!|\;)/g, '$1μια$2')
.replace(/(\n| |\,|\.|\!|\;)Μιά(\n| |\,|\.|\!|\;)/g, '$1Μια$2')
.replace(/(\n| |\,|\.|\!|\;)μού(\n| |\,|\.|\!|\;)/g, '$1μου$2')
.replace(/(\n| |\,|\.|\!|\;)Μού(\n| |\,|\.|\!|\;)/g, '$1Μου$2')
.replace(/(\n| |\,|\.|\!|\;)ναί(\n| |\,|\.|\!|\;)/g, '$1ναι$2')
.replace(/(\n| |\,|\.|\!|\;)Ναί(\n| |\,|\.|\!|\;)/g, '$1Ναι$2')
.replace(/(\n| |\,|\.|\!|\;)νού(\n| |\,|\.|\!|\;)/g, '$1νου$2')
.replace(/(\n| |\,|\.|\!|\;)Νού(\n| |\,|\.|\!|\;)/g, '$1Νου$2')
.replace(/(\n| |\,|\.|\!|\;)πάς(\n| |\,|\.|\!|\;)/g, '$1πας$2')
.replace(/(\n| |\,|\.|\!|\;)Πάς(\n| |\,|\.|\!|\;)/g, '$1Πας$2')
.replace(/(\n| |\,|\.|\!|\;)πεί(\n| |\,|\.|\!|\;)/g, '$1πει$2')
.replace(/(\n| |\,|\.|\!|\;)Πεί(\n| |\,|\.|\!|\;)/g, '$1Πει$2')
.replace(/(\n| |\,|\.|\!|\;)πές(\n| |\,|\.|\!|\;)/g, '$1πες$2')
.replace(/(\n| |\,|\.|\!|\;)Πές(\n| |\,|\.|\!|\;)/g, '$1Πες$2')
.replace(/(\n| |\,|\.|\!|\;)πιά(\n| |\,|\.|\!|\;)/g, '$1πια$2')
.replace(/(\n| |\,|\.|\!|\;)Πιά(\n| |\,|\.|\!|\;)/g, '$1Πια$2')
.replace(/(\n| |\,|\.|\!|\;)πιό(\n| |\,|\.|\!|\;)/g, '$1πιο$2')
.replace(/(\n| |\,|\.|\!|\;)Πιό(\n| |\,|\.|\!|\;)/g, '$1Πιο$2')
.replace(/(\n| |\,|\.|\!|\;)πού(\n| |\,|\.|\!|\;)/g, '$1που$2')
.replace(/(\n| |\,|\.|\!|\;)Πού(\n| |\,|\.|\!|\;)/g, '$1Που$2')
.replace(/(\n| |\,|\.|\!|\;)πώς(\n| |\,|\.|\!|\;)/g, '$1πως$2')
.replace(/(\n| |\,|\.|\!|\;)Πώς(\n| |\,|\.|\!|\;)/g, '$1Πως$2')
.replace(/(\n| |\,|\.|\!|\;)σάς(\n| |\,|\.|\!|\;)/g, '$1σας$2')
.replace(/(\n| |\,|\.|\!|\;)Σάς(\n| |\,|\.|\!|\;)/g, '$1Σας$2')
.replace(/(\n| |\,|\.|\!|\;)σάν(\n| |\,|\.|\!|\;)/g, '$1σαν$2')
.replace(/(\n| |\,|\.|\!|\;)Σάν(\n| |\,|\.|\!|\;)/g, '$1Σαν$2')
.replace(/(\n| |\,|\.|\!|\;)σού(\n| |\,|\.|\!|\;)/g, '$1σου$2')
.replace(/(\n| |\,|\.|\!|\;)Σού(\n| |\,|\.|\!|\;)/g, '$1Σου$2')
.replace(/(\n| |\,|\.|\!|\;)στά(\n| |\,|\.|\!|\;)/g, '$1στα$2')
.replace(/(\n| |\,|\.|\!|\;)Στά(\n| |\,|\.|\!|\;)/g, '$1Στα$2')
.replace(/(\n| |\,|\.|\!|\;)στή(\n| |\,|\.|\!|\;)/g, '$1στη$2')
.replace(/(\n| |\,|\.|\!|\;)Στή(\n| |\,|\.|\!|\;)/g, '$1Στη$2')
.replace(/(\n| |\,|\.|\!|\;)στό(\n| |\,|\.|\!|\;)/g, '$1στο$2')
.replace(/(\n| |\,|\.|\!|\;)Στό(\n| |\,|\.|\!|\;)/g, '$1Στο$2')
.replace(/(\n| |\,|\.|\!|\;)τήν(\n| |\,|\.|\!|\;)/g, '$1την$2')
.replace(/(\n| |\,|\.|\!|\;)Τήν(\n| |\,|\.|\!|\;)/g, '$1Την$2')
.replace(/(\n| |\,|\.|\!|\;)τής(\n| |\,|\.|\!|\;)/g, '$1της$2')
.replace(/(\n| |\,|\.|\!|\;)Τής(\n| |\,|\.|\!|\;)/g, '$1Της$2')
.replace(/(\n| |\,|\.|\!|\;)τίς(\n| |\,|\.|\!|\;)/g, '$1τις$2')
.replace(/(\n| |\,|\.|\!|\;)Τίς(\n| |\,|\.|\!|\;)/g, '$1Τις$2')
.replace(/(\n| |\,|\.|\!|\;)τόν(\n| |\,|\.|\!|\;)/g, '$1τον$2')
.replace(/(\n| |\,|\.|\!|\;)Τόν(\n| |\,|\.|\!|\;)/g, '$1Τον$2')
.replace(/(\n| |\,|\.|\!|\;)τού(\n| |\,|\.|\!|\;)/g, '$1του$2')
.replace(/(\n| |\,|\.|\!|\;)Τού(\n| |\,|\.|\!|\;)/g, '$1Του$2')
.replace(/(\n| |\,|\.|\!|\;)τών(\n| |\,|\.|\!|\;)/g, '$1των$2')
.replace(/(\n| |\,|\.|\!|\;)Τών(\n| |\,|\.|\!|\;)/g, '$1Των$2')
.replace(/(\n| |\,|\.|\!|\;)φώς(\n| |\,|\.|\!|\;)/g, '$1φως$2')
.replace(/(\n| |\,|\.|\!|\;)Φώς(\n| |\,|\.|\!|\;)/g, '$1Φως$2');
// 4-grams
doc_str = doc_str
.replace(/(\n| |\,|\.|\!|\;)βρές(\n| |\,|\.|\!|\;)/g, '$1βρες$2')
.replace(/(\n| |\,|\.|\!|\;)Βρές(\n| |\,|\.|\!|\;)/g, '$1Βρες$2')
.replace(/(\n| |\,|\.|\!|\;)βγεί(\n| |\,|\.|\!|\;)/g, '$1βγει$2')
.replace(/(\n| |\,|\.|\!|\;)Βγεί(\n| |\,|\.|\!|\;)/g, '$1Βγει$2')
.replace(/(\n| |\,|\.|\!|\;)δείς(\n| |\,|\.|\!|\;)/g, '$1δεις$2')
.replace(/(\n| |\,|\.|\!|\;)Δείς(\n| |\,|\.|\!|\;)/g, '$1Δεις$2')
.replace(/(\n| |\,|\.|\!|\;)ζείς(\n| |\,|\.|\!|\;)/g, '$1ζεις$2')
.replace(/(\n| |\,|\.|\!|\;)Ζείς(\n| |\,|\.|\!|\;)/g, '$1Ζεις$2')
.replace(/(\n| |\,|\.|\!|\;)μιάν(\n| |\,|\.|\!|\;)/g, '$1μιαν$2')
.replace(/(\n| |\,|\.|\!|\;)Μιάν(\n| |\,|\.|\!|\;)/g, '$1Μιαν$2')
.replace(/(\n| |\,|\.|\!|\;)μιάς(\n| |\,|\.|\!|\;)/g, '$1μιας$2')
.replace(/(\n| |\,|\.|\!|\;)Μιάς(\n| |\,|\.|\!|\;)/g, '$1Μιας$2')
.replace(/(\n| |\,|\.|\!|\;)νούς(\n| |\,|\.|\!|\;)/g, '$1νους$2')
.replace(/(\n| |\,|\.|\!|\;)Νούς(\n| |\,|\.|\!|\;)/g, '$1Νους$2')
.replace(/(\n| |\,|\.|\!|\;)πείς(\n| |\,|\.|\!|\;)/g, '$1πεις$2')
.replace(/(\n| |\,|\.|\!|\;)Πείς(\n| |\,|\.|\!|\;)/g, '$1Πεις$2')
.replace(/(\n| |\,|\.|\!|\;)ποιό(\n| |\,|\.|\!|\;)/g, '$1ποιο$2')
.replace(/(\n| |\,|\.|\!|\;)Ποιό(\n| |\,|\.|\!|\;)/g, '$1Ποιο$2')
.replace(/(\n| |\,|\.|\!|\;)πρίν(\n| |\,|\.|\!|\;)/g, '$1πριν$2')
.replace(/(\n| |\,|\.|\!|\;)Πρίν(\n| |\,|\.|\!|\;)/g, '$1Πριν$2')
.replace(/(\n| |\,|\.|\!|\;)πρός(\n| |\,|\.|\!|\;)/g, '$1προς$2')
.replace(/(\n| |\,|\.|\!|\;)Πρός(\n| |\,|\.|\!|\;)/g, '$1Προς$2')
.replace(/(\n| |\,|\.|\!|\;)στήν(\n| |\,|\.|\!|\;)/g, '$1στην$2')
.replace(/(\n| |\,|\.|\!|\;)Στήν(\n| |\,|\.|\!|\;)/g, '$1Στην$2')
.replace(/(\n| |\,|\.|\!|\;)στής(\n| |\,|\.|\!|\;)/g, '$1στης$2')
.replace(/(\n| |\,|\.|\!|\;)Στής(\n| |\,|\.|\!|\;)/g, '$1Στης$2')
.replace(/(\n| |\,|\.|\!|\;)στίς(\n| |\,|\.|\!|\;)/g, '$1στις$2')
.replace(/(\n| |\,|\.|\!|\;)Στίς(\n| |\,|\.|\!|\;)/g, '$1Στις$2')
.replace(/(\n| |\,|\.|\!|\;)στόν(\n| |\,|\.|\!|\;)/g, '$1στον$2')
.replace(/(\n| |\,|\.|\!|\;)Στόν(\n| |\,|\.|\!|\;)/g, '$1Στον$2')
.replace(/(\n| |\,|\.|\!|\;)στού(\n| |\,|\.|\!|\;)/g, '$1στου$2')
.replace(/(\n| |\,|\.|\!|\;)Στού(\n| |\,|\.|\!|\;)/g, '$1Στου$2')
.replace(/(\n| |\,|\.|\!|\;)τούς(\n| |\,|\.|\!|\;)/g, '$1τους$2')
.replace(/(\n| |\,|\.|\!|\;)Τούς(\n| |\,|\.|\!|\;)/g, '$1Τους$2');
// 5-grams
doc_str = doc_str
.replace(/(\n| |\,|\.|\!|\;)βγείς(\n| |\,|\.|\!|\;)/g, '$1βγεις$2')
.replace(/(\n| |\,|\.|\!|\;)Βγείς(\n| |\,|\.|\!|\;)/g, '$1Βγεις$2')
.replace(/(\n| |\,|\.|\!|\;)βρείς(\n| |\,|\.|\!|\;)/g, '$1βρεις$2')
.replace(/(\n| |\,|\.|\!|\;)Βρείς(\n| |\,|\.|\!|\;)/g, '$1Βρεις$2')
.replace(/(\n| |\,|\.|\!|\;)μπρός(\n| |\,|\.|\!|\;)/g, '$1μπρος$2')
.replace(/(\n| |\,|\.|\!|\;)Μπρός(\n| |\,|\.|\!|\;)/g, '$1Μπρος$2')
.replace(/(\n| |\,|\.|\!|\;)ποιόν(\n| |\,|\.|\!|\;)/g, '$1ποιον$2')
.replace(/(\n| |\,|\.|\!|\;)Ποιόν(\n| |\,|\.|\!|\;)/g, '$1Ποιον$2')
.replace(/(\n| |\,|\.|\!|\;)ποιός(\n| |\,|\.|\!|\;)/g, '$1ποιος$2')
.replace(/(\n| |\,|\.|\!|\;)Ποιός(\n| |\,|\.|\!|\;)/g, '$1Ποιος$2')
.replace(/(\n| |\,|\.|\!|\;)στούς(\n| |\,|\.|\!|\;)/g, '$1στους$2')
.replace(/(\n| |\,|\.|\!|\;)Στούς(\n| |\,|\.|\!|\;)/g, '$1Στους$2');
cm.getDoc().setValue(doc_str);
});
$(".btn-rp-all").on('click',function(event){
event.preventDefault();
$(".btn-rp-daseia-psili").trigger('click');
$(".btn-rp-daseia-psili-tonos").trigger('click');
$(".btn-rp-n-grams").trigger('click');
});
// ------------------------------------------- Button Listeners ("Fix" section) -------------------------------------------
$(".btn-fix-single-quotes").on('click',function(event){
event.preventDefault();
doc_str = cm.getDoc().getValue();
// doc_str = doc_str.replace(/\᾿|\’|\‘|\᾽/g, '\'');
doc_str = doc_str.replace(/\'|\‘|\᾽|΄|ʼ|ʽ/g, '\’');
cm.getDoc().setValue(doc_str);
});
$(".btn-fix-math-symbols").on('click',function(event){
event.preventDefault();
cm.getDoc().setValue(cm.getDoc().getValue().replace(/µ/g, 'μ').replace(/∆/g, 'Δ'));
});
$(".btn-fix-psili").on('click',function(event){
event.preventDefault();
doc_str = cm.getDoc().getValue();
doc_str = doc_str.replace(/᾿/g, '\’');
cm.getDoc().setValue(doc_str);
});
$(".btn-fix-ano-teleia").on('click',function(event){
// replaces:
// - Middle Dot U+00B7
// - Dot Above U+02D9
// with Greek Ano Teleia U+0387
event.preventDefault();
doc_str = cm.getDoc().getValue();
doc_str = doc_str.replace(/·|˙/g, '·');
cm.getDoc().setValue(doc_str);
});
$(".btn-fix-latin-greek").on('click',function(event){
// replaces:
// ABEHIKMNOPTXYZ opvxz (Latin) with
// ΑΒΕΗΙΚΜΝΟΡΤΧΥΖ ορνχζ (Greek)
event.preventDefault();
doc_str = cm.getDoc().getValue();
doc_str = doc_str.replace(/A/g, 'Α').replace(/B/g, 'Β').replace(/E/g, 'Ε').replace(/H/g, 'Η').replace(/I/g, 'Ι').replace(/K/g, 'Κ').replace(/M/g, 'Μ')
.replace(/N/g, 'Ν').replace(/O/g, 'Ο').replace(/P/g, 'Ρ').replace(/T/g, 'Τ').replace(/X/g, 'Χ').replace(/Y/g, 'Υ').replace(/Z/g, 'Ζ')
.replace(/o/g, 'ο').replace(/p/g, 'ρ').replace(/v/g, 'ν').replace(/x/g, 'χ').replace(/z/g, 'ζ');
cm.getDoc().setValue(doc_str);
});
$(".btn-fix-diacritics").on('click',function(event){
event.preventDefault();
doc_str = cm.getDoc().getValue();
// fix [diacritic]+[character] to one single character
// ===================================================
// Case:
// (᾽) Greek Koronis, U+1FBD OR (᾿) Greek Psili: U+1FBF
doc_str = doc_str.replace(/(᾽|᾿)Α/g, 'Ἀ') // (Ἀ) Greek Capital Letter Alpha with Psili: U+1F08
.replace(/(᾽|᾿)Ε/g, 'Ἐ') // (Ἐ) Greek Capital Letter Epsilon with Psili: U+1F18
.replace(/(᾽|᾿)Η/g, 'Ἠ') // (Ἠ) Greek Capital Letter Eta with Psili: U+1F28
.replace(/(᾽|᾿)Ι/g, 'Ἰ') // (Ἰ) Greek Capital Letter Iota with Psili: U+1F38
.replace(/(᾽|᾿)Ο/g, 'Ὀ') // (Ὀ) Greek Capital Letter Omicron with Psili: U+1F48
// Greek Capital Letter Upsilon with Psili does not exist
.replace(/(᾽|᾿)Ω/g, 'Ὠ') // (Ὠ) Greek Capital Letter Omega with Psili: U+1F68
// Case:
// (῍) Greek Psili and Varia: U+1FCD
.replace(/῍Α/g, 'Ἂ') // (Ἂ) Greek Capital Letter Alpha with Psili and Varia: U+1F0A
.replace(/῍Ε/g, 'Ἒ') // (Ἒ) Greek Capital Letter Epsilon with Psili and Varia: U+1F1A
.replace(/῍Η/g, 'Ἢ') // (Ἢ) Greek Capital Letter Eta with Psili and Varia: U+1F2A
.replace(/῍Ι/g, 'Ἲ') // (Ἲ) Greek Capital Letter Iota with Psili and Varia: U+1F3A
.replace(/῍Ο/g, 'Ὂ') // (Ὂ) Greek Capital Letter Omicron with Psili and Varia: U+1F4A
// Greek Capital Letter Upsilon with Psili and Varia does not exist
.replace(/῍Ω/g, 'Ὢ') // (Ὢ) Greek Capital Letter Omega with Psili and Varia: U+1F6A
// Case:
// (῎) Greek Psili and Oxia: U+1FCE
.replace(/῎Α/g, 'Ἄ') // (Ἄ) Greek Capital Letter Alpha with Psili and Oxia: U+1F0C
.replace(/῎Ε/g, 'Ἔ') // (Ἔ) Greek Capital Letter Epsilon with Psili and Oxia: U+1F1C
.replace(/῎Η/g, 'Ἤ') // (Ἤ) Greek Capital Letter Eta with Psili and Oxia: U+1F2C
.replace(/῎Ι/g, 'Ἴ') // (Ἴ) Greek Capital Letter Iota with Psili and Oxia: U+1F3C
.replace(/῎Ο/g, 'Ὄ') // (Ὄ) Greek Capital Letter Omicron with Psili and Oxia: U+1F4C
// Greek Capital Letter Upsilon with Psili and Oxia does not exist
.replace(/῎Ω/g, 'Ὤ') // (Ὤ) Greek Capital Letter Omega with Psili and Oxia: U+1F6C
// Case:
// (῏) Greek Psili and Perispomeni: U+1FCF
.replace(/῏Α/g, 'Ἆ') // (Ἆ) Greek Capital Letter Alpha with Psili and Perispomeni: U+1F0E
// Greek Capital Letter Epsilon with Psili and Perispomeni does not exist
.replace(/῏Η/g, 'Ἦ') // (Ἦ) Greek Capital Letter Eta with Psili and Perispomeni: U+1F2E
.replace(/῏Ι/g, 'Ἶ') // (Ἶ) Greek Capital Letter Iota with Psili and Perispomeni: U+1F3E
// Greek Capital Letter Omicron with Psili and Perispomeni does not exist
// Greek Capital Letter Upsilon with Psili and Perispomeni does not exist
.replace(/῏Ω/g, 'Ὦ') // (Ὦ) Greek Capital Letter Omega with Psili and Perispomeni: U+1F6E
// Case:
// (῾) Greek Dasia: U+1FFE
.replace(/῾Α/g, 'Ἁ') // (Ἁ) Greek Capital Letter Alpha with Dasia: U+1F09
.replace(/῾Ε/g, 'Ἑ') // (Ἑ) Greek Capital Letter Epsilon with Dasia: U+1F19
.replace(/῾Η/g, 'Ἡ') // (Ἡ) Greek Capital Letter Eta with Dasia: U+1F29
.replace(/῾Ι/g, 'Ἱ') // (Ἱ) Greek Capital Letter Iota with Dasia: U+1F39
.replace(/῾Ο/g, 'Ὁ') // (Ὁ) Greek Capital Letter Omicron with Dasia: U+1F49
.replace(/῾Υ/g, 'Ὑ') // (Ὑ) Greek Capital Letter Upsilon with Dasia: U+1F59
.replace(/῾Ω/g, 'Ὡ') // (Ὡ) Greek Capital Letter Omega with Dasia: U+1F69
// Case:
// (῝) Greek Dasia and Varia: U+1FDD
.replace(/῝Α/g, 'Ἃ') // (Ἃ) Greek Capital Letter Alpha with Dasia and Varia: U+1F0B
.replace(/῝Ε/g, 'Ἓ') // (Ἓ) Greek Capital Letter Epsilon with Dasia and Varia: U+1F1B
.replace(/῝Η/g, 'Ἣ') // (Ἣ) Greek Capital Letter Eta with Dasia and Varia: U+1F2B
.replace(/῝Ι/g, 'Ἳ') // (Ἳ) Greek Capital Letter Iota with Dasia and Varia: U+1F3B
.replace(/῝Ο/g, 'Ὃ') // (Ὃ) Greek Capital Letter Omicron with Dasia and Varia: U+1F4B
.replace(/῝Υ/g, 'Ὓ') // (Ὓ) Greek Capital Letter Upsilon with Dasia and Varia: U+1F5B
.replace(/῝Ω/g, 'Ὣ') // (Ὣ) Greek Capital Letter Omega with Dasia and Varia: U+1F6B
// Case:
// (῞) Greek Dasia and Oxia: U+1FDE
.replace(/῞Α/g, 'Ἅ') // (Ἅ) Greek Capital Letter Alpha with Dasia and Oxia: U+1F0D
.replace(/῞Ε/g, 'Ἕ') // (Ἕ) Greek Capital Letter Epsilon with Dasia and Oxia: U+1F1D
.replace(/῞Η/g, 'Ἥ') // (Ἥ) Greek Capital Letter Eta with Dasia and Oxia: U+1F2D
.replace(/῞Ι/g, 'Ἵ') // (Ἵ) Greek Capital Letter Iota with Dasia and Oxia: U+1F3D
.replace(/῞Ο/g, 'Ὅ') // (Ὅ) Greek Capital Letter Omicron with Dasia and Oxia: U+1F4D
.replace(/῞Υ/g, 'Ὕ') // (Ὕ) Greek Capital Letter Upsilon with Dasia and Oxia: U+1F5D
.replace(/῞Ω/g, 'Ὥ') // (Ὥ) Greek Capital Letter Omega with Dasia and Oxia: U+1F6D
// Case:
// (῟) Greek Dasia and Perispomeni: U+1FDF
.replace(/῟Α/g, 'Ἇ') // (Ἇ) Greek Capital Letter Alpha with Dasia and Perispomeni: U+1F0F
// Greek Capital Letter Epsilon with Dasia and Perispomeni does not exist
.replace(/῟Η/g, 'Ἧ') // (Ἧ) Greek Capital Letter Eta with Dasia and Perispomeni: U+1F2F
.replace(/῟Ι/g, 'Ἷ') // (Ἷ) Greek Capital Letter Iota with Dasia and Perispomeni: U+1F3F
// Greek Capital Letter Omicron with Dasia and Perispomeni does not exist
.replace(/῟Υ/g, 'Ὗ') // (Ὗ) Greek Capital Letter Upsilon with Dasia and Perispomeni: U+1F5F
.replace(/῟Ω/g, 'Ὧ') // (Ὧ) Greek Capital Letter Omega with Dasia and Perispomeni: U+1F6F
// // Case:
// // (X) Greek ... and ...: U+...
// .replace(/XΑ/g, '') //
// .replace(/XΕ/g, '') //
// .replace(/XΗ/g, '') //
// .replace(/XΙ/g, '') //
// .replace(/XΟ/g, '') //
// .replace(/XΥ/g, '') //
// .replace(/XΩ/g, '') //
cm.getDoc().setValue(doc_str);
});
$(".btn-fix-spaces").on('click',function(event){
event.preventDefault();
cm.getDoc().setValue(cm.getDoc().getValue().replace(/( )+/g, ' '));
});
$(".btn-fix-spaces-newline").on('click',function(event){
event.preventDefault();
cm.getDoc().setValue(cm.getDoc().getValue().replace(/( )+\n/g, '\n').trim());
});
$(".btn-fix-all").on('click',function(event){
event.preventDefault();
$(".btn-fix-diacritics").trigger('click');
$(".btn-fix-single-quotes").trigger('click');
$(".btn-fix-math-symbols").trigger('click');
$(".btn-fix-psili").trigger('click');
$(".btn-fix-ano-teleia").trigger('click');
$(".btn-fix-latin-greek").trigger('click');
$(".btn-fix-spaces").trigger('click');
$(".btn-fix-spaces-newline").trigger('click');
});
//
// Normalization Form D (NFD): Canonical Decomposition
//
$(".btn-norm-NFD").on('click',function(event){
event.preventDefault();
cm.getDoc().setValue(cm.getDoc().getValue().normalize('NFD'));
});
//
// Normalization Form C (NFC): Canonical Decomposition, followed by Canonical Composition
//
$(".btn-norm-NFC").on('click',function(event){
event.preventDefault();
cm.getDoc().setValue(cm.getDoc().getValue().normalize('NFC'));
});
//
// Normalization Form KD (NFKD): Compatibility Decomposition
//
$(".btn-norm-NFKD").on('click',function(event){
event.preventDefault();
cm.getDoc().setValue(cm.getDoc().getValue().normalize('NFKD'));
});
//
// Normalization Form KC (NFKC): Compatibility Decomposition, followed by Canonical Composition
//
$(".btn-norm-NFKC").on('click',function(event){
event.preventDefault();
cm.getDoc().setValue(cm.getDoc().getValue().normalize('NFKC'));
});
//
// Normalize (remove) greek accents
//
$(".btn-norm-GR").on('click',function(event){
event.preventDefault();
cm.getDoc().setValue(cm.getDoc().getValue().normalize('NFD').replace(/[\u0300-\u036f]/g, ""));
});
// mark greek extended
$(".btn-mark-greek-ext").on('click',function(event){
event.preventDefault();
event.stopPropagation();
// var checkBox = $(".btn-mark-greek-ext input");
// checkBox.prop("checked", !checkBox.prop("checked"));
$(".btn-mark-greek-ext input").trigger('click');
});
$(".btn-mark-greek-ext input").on('click',function(event){
event.stopPropagation();
});
$(".btn-mark-greek-ext input").change( function(event){
// event.preventDefault();
event.stopPropagation();
mark_greek_extended = this.checked;
if (mark_greek_extended) {
mark_greek_extended_text();
// mark(char_list_greek_extended, char_class_gr_ext, greek_extended_markers);
// mark_(regex_greek_extended, char_class_gr_ext);
} else {
clear_greek_extended_markers();
}
});
//
// listeners for inc/decrease the font size
//
$(".btn-font-inc").on('click',function(event){
event.preventDefault();
event.stopPropagation();
$(".CodeMirror").css("font-size",++font_size);
cm.refresh();
});
$(".btn-font-dec").on('click',function(event){
event.preventDefault();
event.stopPropagation();
$(".CodeMirror").css("font-size",--font_size);
cm.refresh();
});
$(".btn-font-rst").on('click',function(event){
event.preventDefault();
event.stopPropagation();
font_size = 14;
$(".CodeMirror").css("font-size",font_size);
cm.refresh();
});
// mark greek
$(".btn-mark-greek-coptic").on('click',function(event){
event.preventDefault();
event.stopPropagation();
$(".btn-mark-greek-coptic input").trigger('click');
});
$(".btn-mark-greek-coptic input").on('click',function(event){
event.stopPropagation();
});
$(".btn-mark-greek-coptic input").change( function(event){
event.preventDefault();
event.stopPropagation();
mark_greek_coptic = this.checked;
if (mark_greek_coptic) {
mark_greek_coptic_text();
} else {
clear_greek_coptic_markers();
}
});
// mark numbers
$(".btn-mark-num").on('click',function(event){
event.preventDefault();
event.stopPropagation();
$(".btn-mark-num input").trigger('click');
});
$(".btn-mark-num input").on('click',function(event){
event.stopPropagation();
});
$(".btn-mark-num input").change( function(event){
event.preventDefault();
event.stopPropagation();
mark_numbers = this.checked;
if (mark_numbers) {
mark_numbers_text();
} else {
clear_number_markers();
}
});
// mark basic-latin
$(".btn-mark-latin-red").on('click',function(event){
event.preventDefault();
event.stopPropagation();
$(".btn-mark-latin-red input").trigger('click');
});
$(".btn-mark-latin-red input").on('click',function(event){
event.stopPropagation();
});
$(".btn-mark-latin-red input").change( function(event){
event.stopPropagation();
mark_latin_red = this.checked;
if (mark_latin_red) {
mark_latin_text();
} else {
clear_latin_markers();
}
});
// mark unwanted
$(".btn-mark-unwanted").on('click',function(event){
event.preventDefault();
event.stopPropagation();
$(".btn-mark-unwanted input").trigger('click');
});
$(".btn-mark-unwanted input").on('click',function(event){
event.stopPropagation();
});
$(".btn-mark-unwanted input").change( function(event){
event.stopPropagation();
mark_unwanted = this.checked;
if (mark_unwanted) {
mark_unwanted_text();
} else {
clear_unwanted_markers();
}
});
// mark punctuation
$(".btn-mark-punctuation").on('click',function(event){
event.preventDefault();
event.stopPropagation();
$(".btn-mark-punctuation input").trigger('click');
});
$(".btn-mark-punctuation input").on('click',function(event){
event.stopPropagation();
});
$(".btn-mark-punctuation input").change( function(event){
event.stopPropagation();
mark_punctuation = this.checked;
if (mark_punctuation) {
mark_punctuation_text();
} else {
clear_punctuation_markers();
}
});
// toggle word wrap
$(".btn-toggle-wrap").on('click',function(event){
event.preventDefault();
event.stopPropagation();
$(".btn-toggle-wrap input").trigger('click');
});
$(".btn-toggle-wrap input").on('click',function(event){
event.stopPropagation();
});
$(".btn-toggle-wrap input").change( function(event){
event.stopPropagation();
word_wrap = this.checked;
cm.setOption("lineWrapping", word_wrap);
});
});
function clear_greek_extended_markers() {
greek_extended_markers.forEach(marker => marker.clear());
}
function clear_greek_coptic_markers() {
greek_coptic_markers.forEach(marker => marker.clear());
}
function clear_number_markers() {
number_markers.forEach(marker => marker.clear());
}
function clear_latin_markers() {
latin_markers.forEach(marker => marker.clear());
}
function clear_unwanted_markers() {
unwanted_markers.forEach(marker => marker.clear());
}
function clear_punctuation_markers() {
punctuation_markers.forEach(marker => marker.clear());
}
function mark_greek_extended_text() {
mark_(regex_greek_extended, char_class_gr_ext);
}
function mark_greek_coptic_text() {
mark_(regex_greek_coptic,char_class_gr_coptic);
}
function mark_numbers_text() {
mark_(regex_numbers, char_class_numbers);
}
function mark_latin_text() {
mark_(regex_latin, char_class_latin);
}
function mark_unwanted_text() {
// BASIC LATIN
// " : U+0022 Quotation Mark
// ' : U+0027 APOSTROPHE {APL quote}
// / : U+002F Solidus
// LATIN-1 SUPPLEMENT
// µ : U+00B5 Micro Sign
// · : U+00B7 Middle Dot
// SPACING MODIFIER LETTERS
// ˙ : U+02D9 Dot Above
// GREEK AND COPTIC
// ΄ : U+0384 Greek Tonos
// GREEK EXTENDED
// ᾽ : U+1FBD Greek Koronis
// ι : U+1FBE Greek Prosgegrammeni
// ᾿ : U+1FBF Greek Psili
// ῀ : U+1FC0 Greek Perispomeni
// ῁ : U+1FC1 Greek Dialytika and Perispomeni
// ῍ : U+1FCD Greek Psili and Varia
// ῎ : U+1FCE Greek Psili and Oxia
// ῏ : U+1FCF Greek Psili and Perispomeni
// ῝ : U+1FDD Greek Dasia and Varia
// ῞ : U+1FDE Greek Dasia and Oxia
// ῟ : U+1FDF Greek Dasia and Perispomeni
// ῭ : U+1FED Greek Dialytika and Varia
// ΅ : U+1FEE Greek Dialytika and Oxia
// ` : U+1FEF Greek Varia
// ´ : U+1FFD Greek Oxia
// ῾ : U+1FFE Greek Dasia
// GENERAL PUNCTUATION
// ‘ : U+2018 Left Single Quotation Mark
// ’ : U+2019 Right Single Quotation Mark
// “ : U+201C Left Double Quotation Mark
// ” : U+201D Right Double Quotation Mark
// IPA EXTENSIONS
// ʼ : U+02BC Modifier Letter Apostrophe
// ʽ : U+02BD Modifier Letter Reversed Comma
mark_(regex_unwanted, char_class_unwanted);
}
function mark_punctuation_text() {
// U+0009 : <control> CHARACTER TABULATION [TAB] {horizontal tabulation (HT)}
// U+002E : FULL STOP {period, dot, decimal point}
// U+002C : COMMA {decimal separator}
// U+2019 : RIGHT SINGLE QUOTATION MARK {single comma quotation mark}
// U+0020 : SPACE [SP]
// U+2026 : HORIZONTAL ELLIPSIS {three dot leader}
// U+003A : COLON
// U+003B : SEMICOLON
// U+0021 : EXCLAMATION MARK {factorial; bang}
// U+00AB : LEFT-POINTING DOUBLE ANGLE QUOTATION MARK {left guillemet; chevrons (in typography)}
// U+00BB : RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK {right guillemet}
// U+002D : HYPHEN-MINUS {hyphen or minus sign}
mark_(regex_punctuation, char_class_punctuation);
}
// function that scans the whole text and adds color when needed.
// For the regex used, see the declarations at the beginning of the file.
//
function mark_(regex, css_class_name) {
doc_str = cm.getDoc().getValue();
var lines = doc_str.split('\n');
var from = {line:0,ch:0};
var to = {line:0,ch:0};
var matched_char_positions = [];
var css_class_obj = {className: css_class_name};
for (var i=0; i<lines.length; i++) { // iterate lines
from.line = i;
from.ch = 0;
to.line = i;
to.ch = 0;
matched_char_positions = [];
for (var j=0; j<lines[i].length; j++) { // iterate columns
if (lines[i][j].match(regex) != null) {
matched_char_positions.push(j);
} else {
if (matched_char_positions.length == 0) {
continue;
} else {
from.ch = matched_char_positions[0];
to.ch = matched_char_positions[0] + matched_char_positions.length;
switch (css_class_name) {
case 'gr-ext':
greek_extended_markers.push(cm.markText(from,to,css_class_obj));
break;
case 'gr-coptic':
greek_coptic_markers.push(cm.markText(from,to,css_class_obj));
break;
case 'num':
number_markers.push(cm.markText(from,to,css_class_obj));
break;
case 'latin':
latin_markers.push(cm.markText(from,to,css_class_obj));
break;
case 'unwanted':
unwanted_markers.push(cm.markText(from,to,css_class_obj));
break;
case 'punctuation':
punctuation_markers.push(cm.markText(from,to,css_class_obj));
break;
default:
break;
}
matched_char_positions = [];
}
}
if (j==lines[i].length-1) {
from.ch = matched_char_positions[0];
to.ch = matched_char_positions[0] + matched_char_positions.length;
switch (css_class_name) {
case 'gr-ext':
greek_extended_markers.push(cm.markText(from,to,css_class_obj));
break;
case 'gr-coptic':
greek_coptic_markers.push(cm.markText(from,to,css_class_obj));
break;
case 'num':
number_markers.push(cm.markText(from,to,css_class_obj));
break;
case 'latin':
latin_markers.push(cm.markText(from,to,css_class_obj));
break;
case 'unwanted':
unwanted_markers.push(cm.markText(from,to,css_class_obj));
break;
case 'punctuation':
punctuation_markers.push(cm.markText(from,to,css_class_obj));
break;
default:
break;
}
matched_char_positions = [];
}
}
}
}