forked from SO-Close-Vote-Reviewers/UserScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Magic™Editor.user.js
3630 lines (3551 loc) · 163 KB
/
Magic™Editor.user.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
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// ==UserScript==
// @name Magic™Editor
// @author Cameron Bernhardt (AstroCB)
// @developer Jonathan Todd (jt0dd)
// @developer sathyabhat
// @contributor Unihedron
// @contributor Tiny Giant
// @contributor Mogsdad
// @contributor Makyen
// @contributor VLAZ
// @grant none
// @license MIT
// @namespace http://github.com/SO-Close-Vote-Reviewers/UserScripts/Magic™Editor
// @version 1.8.0
// @description Fix common grammar/usage annoyances on Stack Exchange posts with a click. Forked from https://github.com/AstroCB/Stack-Exchange-Editor-Toolkit
// @include /^https?:\/\/([\w-]*\.)*((stackoverflow|stackexchange|serverfault|superuser|askubuntu|stackapps)\.com|mathoverflow.net)\/(c\/[^\/]*\/)?(questions|posts|review|tools)\/(?!tagged\/|new\/).*/
// @exclude *://chat.stackoverflow.com/*
// @exclude *://chat.stackexchange.com/*
// @exclude *://chat.*.stackexchange.com/*
// @exclude *://api.*.stackexchange.com/*
// @exclude *://data.stackexchange.com/*
// ==/UserScript==
/* globals StackExchange, $ */
/* eslint-disable no-multi-spaces, no-sequences */
(function() {
"use strict";
function extendEditor(root) {
var App = {};
// Place edit items here
App.items = {};
App.originals = {};
// Place selected jQuery items here
App.selections = {};
// Place "global" app data here
App.globals = {};
// Place "const" app data here
App.consts = {};
// Place "helper" functions here
App.funcs = {};
// True to display counts and / or rule names in Edit Summary
App.globals.showCounts = false;
App.globals.showRules = false;
App.globals.root = root;
App.globals.reasons = {};
App.globals.placeHolders = {
//The text here is staticly used in some edit RegExp to prevent substitution of placeholders.
// See:
// badphrases which relies on "_xPlacexHolderx" starting a placeholder.
"auto": "_xPlacexHolderxAutoxInsertxTextxPlacexHolderx_",
"quote": "_xPlacexHolderxBlockxQuotexPlacexHolderx_",
"backtickCode": "_xPlacexHolderxCodexPreserveBlockxPlacexHolderx_",
"block": "_xPlacexHolderxCodexBlockxPlacexHolderx_",
"blockStart": "_xPlacexHolderxCodexBlockxStartxPlacexHolderx_",
"lsec": "_xPlacexHolderxLinkxSectionxPlacexHolderx_",
"links": "_xPlacexHolderxLinkxPlacexHolderx_",
"preBlock": "_xPlacexHolderxPrexBlockxPlacexHolderx_",
"codeTag": "_xPlacexHolderxCodexTagxPlacexHolderx_",
"tags": "_xPlacexHolderxTagxPlacexHolderx_",
"dashes": "_xPlacexHolderxDashesxPlacexHolderx_"
};
App.globals.replacedStrings = {};
App.globals.replacedStringsOriginal = {};
App.globals.placeHolderChecks = {};
App.globals.placeHolderKeys = Object.keys(App.globals.placeHolders);
App.globals.checks = {
//automatically inserted text
// https://regex101.com/r/cI6oK2/1
"auto": /[^]*\<\!\-\- End of automatically inserted text \-\-\>/g,
//blockquotes
// https://regex101.com/r/fU5lE6/1
"quote": /^\>(?:(?!\n\n)[^])+/gm,
//code surrounded by backticks
// https://regex101.com/r/8tZD3i/2
"backtickCode": /(?:(?:^(`{3,})[^]+?\1)|(`+)(?:\\`|[^`](?!\n\n))+\2)/gm,
//code blocks and multiline inline code.
// https://regex101.com/r/eC7mF7/4
"block": /(?:(?:^[ \t]*(?:[\r\n]|\r\n))?`[^`]+`|(?:^[ \t]*(?:[\r\n]|\r\n))^(?:(?:[ ]{4}|[ ]{0,3}\t).+(?:[\r\n]?(?!\n\S)(?:[ \t]+\n)*)+)+)/gm,
//code blocks at the start of the post.
// https://regex101.com/r/vu7fBd/1
"blockStart": /(?:^(?:(?:[ ]{4}|[ ]{0,3}\t).+(?:[\r\n]?(?!\n\S)(?:[ ]+\n)*)+)+)/g,
//link-sections
// Testing of this and the "links" RegExp were done within the same regex101.com "regex".
// The prior version of this was https://regex101.com/r/tZ4eY3/7 it was saved and became version 21.
// It was then forked into it's own regex:
// https://regex101.com/r/C7nXfd/2
"lsec": /(?:^ *(?:[\r\n]|\r\n))?(?: {2}(?:\[\d\]): \w*:+\/\/.*\n*)+/gm,
//links and pathnames
// See comment above the "lsec" RegExp regarding testing sharing the same "regex" on regex101.com
// https://regex101.com/r/tZ4eY3/22
"links": /!?\[[^\]\n]+\](?:\([^\)\n]+\)|\[[^\]\n]+\])(?:\](?:\([^\)\n]+\)|\[[^\]\n]+\]))?|(?:\/\w+\/|.:\\|\w*:\/\/|\.+\/[./\w\d]+|(?:\w+\.\w+){2,})[./\w\d:/?#\[\]@!$&'()*+,;=\-~%]*/gi, // ' fix syntax highlighting in code editor
//<pre></pre> blocks
// https://regex101.com/r/KFvgol/1
"preBlock": /<pre(?: [^>]*?|)>[\W\w]*?<\/pre>/gi,
//<code></code> blocks
// https://regex101.com/r/waCxWR/1
"codeTag": /<code(?: [^>]*?|)>[\W\w]*?<\/code>/gi,
// https://regex101.com/r/bF0iQ0/2 tags and html comments
"tags": /\<[\/a-z]+\>|\<\!\-\-[^>]+\-\-\>|\[tag:[\w.-]+\]/gi,
"dashes": /^(\s*--+\s*?)$/gim
};
//Make a shallow copy of the App.globals.checks Object
App.globals.checksr = (function(objIn){
var objOut = {};
var keys = Object.keys(objIn);
for(var i = keys.length-1; i >= 0; --i) objOut[keys[i]] = objIn[keys[i]];
return objOut;
})(App.globals.checks);
// Assign modules here
App.pipeMods = {};
// Define order in which mods affect here
App.globals.order = ["omit", "codefix", "inlineImages", "edit", "diff", "replace", "output"];
// Define reason constant strings
App.consts.reasons = {
legalSO: "'Stack Overflow' is the legal name",
legalSE: "'Stack Exchange' is the legal name",
tagTitle: "removed tags from title",
trademark: "trademark capitalization",
acronym: "acronym capitalization",
spelling: "spelling",
grammar: "grammar",
noise: "noise reduction",
punctuation: "punctuation",
layout: "layout",
silent: "", // Unreported / uncounted
titleSaysAll: "replicated title in body",
inlineImage: "inline image"
};
// Get the original post tags
App.globals.taglist = [];
$('a.post-tag').each( function(){
var newtag = $(this).text();
if (App.globals.taglist.indexOf(newtag) === -1) {
App.globals.taglist.push(newtag);
}
});
// Define edit rules
// See https://regex101.com/r/fC3bY5/2 for a basic RegExp that excludes matches in filenames, paths, library names, etc.
// The following properties are available for each edit rule:
// expr: RegExp Used as the argument for the String methods .match() and the first argument for .replace().
// replacement: String or function Used as the second argument for the String method .replace(). e.g. "$1 want".
// reason: String Should be one of the constants defined as a reason. e.g.: App.consts.reasons.grammar
// rerun: String or Array of String The keys of rules which will be re-run if there are any changes made by this current rule. "rerrun" is executed before "runAfter"
// runBefore: String or Array of String The keys of rules which will be run, perhaps re-run, immediately before this key.
// runAfter: String or Array of String The keys of rules which will be run, perhaps re-run, immediately after this key.
// notAlone: truthy (Boolean) If evaluates to true, then the rule is only run when specified in a "rerun", "runBefore", or "runAfter"
// titleOnly: truthy (Boolean) If evaluates to true, then the rule is only applied to titles.
// bodyOnly: truthy (Boolean) If evaluates to true, then the rule is only applied to bodies.
// debug: truthy (Boolean) If evaluates to true, then debug output is logged to the console for this rule.
// WARNING: rerun, runBefore, and runAfter can result in an infinite loop.
App.edits = {
// Handle all-caps posts first
noneedtoyell: {
expr: /^((?=.*[A-Z])[^a-z]*)$/g,
replacement: function(input) {
return input.trim().substr(0, 1).toUpperCase() + input.trim().substr(1).toLowerCase();
},
reason: App.consts.reasons.grammar
},
// Remove tags from title
taglist: { // https://regex101.com/r/wH4oA3/25
// WARNING: the expression from regex101 must have backslashes escaped here - wbn to automate this...
expr: new RegExp(
"(?:^(?:[(]?(?:_xTagsx_)(?!\\.\\w)(?:and|[ ,.&+/-])*)+[:. \\)-]*|\\b(?:[:. \\(-]|in|with|using|by|for|from)*(?:(?:_xTagsx_)(?:and|[ ,&+/)-])*)+([?.! ]*)$)"
.replace(/_xTagsx_/g,App.globals.taglist.map(escapeTag).join("|")),
//Consider escaping character classes:
//.replace(/\\(?=[bsSdDwW])/g,"\\"), // https://regex101.com/r/pY1hI2/1 - WBN to figure this out.
'gi'
),
replacement: "$1",
debug: false,
titleOnly: true,
reason: App.consts.reasons.tagTitle
},
so: {
expr: /\bstack\s*overflow\b/gi,
replacement: "Stack Overflow",
reason: App.consts.reasons.legalSO
},
se: {
expr: /\bstack\s*exchange\b/gi,
replacement: "Stack Exchange",
reason: App.consts.reasons.legalSE
},
expansionSO: {
expr: /([^\b\w.]|^)SO\b/g,
replacement: "$1Stack Overflow",
reason: App.consts.reasons.legalSO
},
expansionSE: {
expr: /([^\b\w.]|^)SE\b/g,
replacement: "$1Stack Exchange",
reason: App.consts.reasons.legalSE
},
/*
** Trademark names
**/
jsfiddle: {
expr: /\bjs ?fiddle\b/gi,
replacement: "JSFiddle",
reason: App.consts.reasons.trademark
},
meteor: { // must appear before "javascript"
expr: /([^\b\w.]|^)meteor(?: *(js))?\b(?![.-]\w)/gi,
replacement: function (str,pre,uppercase) {
var fixed = pre + "Meteor" + (uppercase ? uppercase.toUpperCase() : '');
return fixed;
},
reason: App.consts.reasons.trademark
},
knockout_js: { // must appear before "javascript"
expr: /\bknockout[. ]?js\b/gi,
replacement: "Knockout.js",
reason: App.consts.reasons.trademark
},
script: { // Spelling rule out-of-order, must run before javascript & google_apps_script
expr: /(s)c[ri]+pt?(ing|s)?\b/gi,
replacement: "$1cript$2",
reason: App.consts.reasons.spelling
},
javascript: {
expr: /([^\b\w.]|^)(java?scr?ipt?|js|java(?:[^\w.]|_)?script?)\b/gi,
replacement: "$1JavaScript",
reason: App.consts.reasons.trademark
},
jquery: {
expr: /\bjque?rr?y\b(?![.-]\w)/gi, // jqury, jquerry, jqurry... ~600 spelling mistakes
replacement: "jQuery",
reason: App.consts.reasons.trademark
},
angularjs: {
expr: /\bangularjs\b(?![.-]\w)/gi, //Updated as Angular and AngularJS are two different things.
replacement: "AngularJS",
reason: App.consts.reasons.trademark
},
angularcli: {
expr: /\bangular\W{0,2}cli\b(?![.-]\w)/gi,
replacement: "Angular CLI",
reason: App.consts.reasons.trademark
},
angular: {
expr: /\bangular\b(?![.-]\w)/gi,
replacement: "Angular",
reason: App.consts.reasons.trademark
},
php: {
expr: /(?:[^\b\w.]|^)php[\d]?\b(?![.-]\w)/gi,
replacement: function (match) { return match.toUpperCase(); },
reason: App.consts.reasons.trademark
},
c: {
expr: /(?:[^\b\w.]|^)c\b(?:#|\+\+)?/gi,
replacement: function (match) { return match.toUpperCase(); },
reason: App.consts.reasons.trademark
},
java: {
expr: /([^\b\w.]|^)java\b(?![.-]\w)/gi,
replacement: "$1Java",
reason: App.consts.reasons.trademark
},
sqlite: {
expr: /\bsql*\W?l*ite(\s*[0-9]*)\b/gi,
replacement: "SQLite$1",
reason: App.consts.reasons.trademark
},
android: {
expr: /\band(?:roi|ori)d\b(?![.-]\w)/gi,
replacement: "Android",
reason: App.consts.reasons.trademark
},
oracle: {
expr: /\boracle\b/gi,
replacement: "Oracle",
reason: App.consts.reasons.trademark
},
windows: {
// https://regex101.com/r/jF9zK1/8
expr: /\b(?:win(?=(?:\s+(?:2k|[0-9.]+|ce|me|nt|xp|vista|server)))|windows)(?:\s+(2k|[0-9.]+|ce|me|nt|xp|vista|server))?\b/gi,
replacement: function(match, ver) {
ver = !ver ? '' : ' ' + ver
.replace(/ce/i, 'CE')
.replace(/me/i, 'ME')
.replace(/nt/i, 'NT')
.replace(/xp/i, 'XP')
.replace(/2k/i, '2000')
.replace(/vista/i, 'Vista')
.replace(/server/i, 'Server');
return 'Windows' + ver;
},
reason: App.consts.reasons.trademark
},
unix: {
expr: /\bunix\b/gi,
replacement: "Unix",
reason: App.consts.reasons.trademark
},
linux: {
expr: /\blinux\b/gi,
replacement: "Linux",
reason: App.consts.reasons.trademark
},
wordpress: {
expr: /\bword ?press\b/gi,
replacement: "WordPress",
reason: App.consts.reasons.trademark
},
mysql: {
expr: /\bmysql\b/gi,
replacement: "MySQL",
reason: App.consts.reasons.trademark
},
nodejs: {
expr: /\bnode\.?js\b/gi,
replacement: "Node.js",
reason: App.consts.reasons.trademark
},
apache: {
expr: /\bapache([\d])?\b(?![.-]\w)/gi,
replacement: "Apache$1",
reason: App.consts.reasons.trademark
},
git: {
expr: /([^\b\w.]|^)git\b/gi,
replacement: "$1Git",
reason: App.consts.reasons.trademark
},
github: {
expr: /\bgithub\b/gi,
replacement: "GitHub",
reason: App.consts.reasons.trademark
},
facebook: { // https://regex101.com/r/rO1tH4/2
expr: /\bf(?:a[cs]e?)?be?o+k?(s)?/gi,
replacement: function(str,s) {
return "Facebook" + (s ? "'s" : "");
},
reason: App.consts.reasons.trademark
},
python: {
//Given that "python" is a real word, this isn't something we necessarily should be capitalizing all the time.
//However, on SO it's far more likely to be the programming language than a snake.
expr: /\bpython\b/gi,
replacement: "Python",
reason: App.consts.reasons.trademark
},
ios: {
expr: /\bios\b/gi,
replacement: "iOS",
reason: App.consts.reasons.trademark
},
iosnum: {
expr: /\bios([0-9])\b/gi,
replacement: "iOS $1",
reason: App.consts.reasons.trademark
},
ubuntu: { // https://regex101.com/r/sT8wV5/2
expr: /\b[uoa]+n?b[uoa]*[tn][oua]*[tnu][oua]*\b/gi,
replacement: "Ubuntu",
reason: App.consts.reasons.trademark
},
vbnet: { // https://regex101.com/r/bB9pP3/8
expr: /(?:vb\.net|\bvb|(?:[^\b\w.]|^)\.net)\b(?:\s*[0-9]+)?\s*(?:framework|core)?/gi,
replacement: function(str) {
return str.replace(/([^.])vb/i, '$1VB')
.replace(/([^.])asp/i, '$1ASP')
.replace(/net/i, 'NET')
.replace(/framework/i, 'Framework')
.replace(/core/i, 'Core');
},
reason: App.consts.reasons.trademark
},
vba_related: {
expr: /(?:[^\b\w.]|^)(?:vba|vbs|vbc|evb|vbo|vbp|vbide)\b/gi,
replacement: function (match) { return match.toUpperCase(); },
reason: App.consts.reasons.trademark
},
vbscript: {
expr: /\bvbscript/gi,
replacement: "VBScript",
reason: App.consts.reasons.trademark
},
excel: {
expr: /\bexcel\b(?!\-|\.\w)/gi,
replacement: "Excel",
reason: App.consts.reasons.trademark
},
regex: {
expr: /\b(r)egg?([ea]*)x(p)?\b/gi,
replacement: function (match, p1, p2, p3) {
//If this is JavaScript related, then use RegExp
const isRegExp = ['javascript', 'jquery', 'reactjs', 'nodejs'].some(function(testTag) {
return App.globals.taglist.indexOf(testTag) > -1;
});
let result = `${(isRegExp ? 'R' : p1)}eg`;
if ((p2 && p2 === p2.toUpperCase()) || isRegExp) {
result += 'E';
} else {
result += 'e';
}
result += `x${(isRegExp ? 'p' : (p3 || ''))}`;
return result;
},
reason: App.consts.reasons.trademark
},
postgresql: {
expr: /\bpost?gres*(q?l|s)?\b/gi,
replacement: "PostgreSQL",
reason: App.consts.reasons.trademark
},
paypal: {
expr: /\bpaypal\b/gi,
replacement: "PayPal",
reason: App.consts.reasons.trademark
},
tomcat: {
expr: /\btomcat([0-9.]*)/gi,
replacement: "Tomcat$1",
reason: App.consts.reasons.trademark
},
netbeans: {
expr: /\b(?:netbean?|net-bean|net bean|netbeen)s?\b/gi,
replacement: "NetBeans",
reason: App.consts.reasons.trademark
},
nginx: {
expr: /\bnginx\b/g,
replacement: function (match) { return match.toUpperCase(); },
reason: App.consts.reasons.trademark
},
firefox: {
expr: /\bfire?fox\b/gi,
replacement: "Firefox",
reason: App.consts.reasons.trademark
},
safari: {
expr: /\bsafari\b/gi,
replacement: "Safari",
reason: App.consts.reasons.trademark
},
chrome: {
expr: /\bchrome\b(?![-.]\w)/gi, //Don't match chrome.* namespace and chrome-* schemes
replacement: "Chrome",
reason: App.consts.reasons.trademark
},
gnu: {
expr: /\bgnu\b/g,
replacement: function (match) { return match.toUpperCase(); },
reason: App.consts.reasons.trademark
},
gcc: {
expr: /(?:[^\b\w.]|^)gcc\b/g,
replacement: function (match) { return match.toUpperCase(); },
reason: App.consts.reasons.trademark
},
maven: {
expr: /\bmaven\b/gi,
replacement: "Maven",
reason: App.consts.reasons.trademark
},
youtube: {
expr: /\byoutube\b/gi,
replacement: "YouTube",
reason: App.consts.reasons.trademark
},
amazon: {
// https://regex101.com/r/dR0pJ7/1
expr: /\b(amazon(?: )?(?:redshift|web services|cloudfront|console)?)((?: )?(?:ec2|aws|s3|rds|sqs|iam|elb|emr|vpc))?\b/gi,
replacement: function(str,titlecase,uppercase) {
var fixed = toTitleCase(titlecase) + (uppercase ? uppercase.toUpperCase() : '');
return fixed;
},
reason: App.consts.reasons.trademark
},
zend: {
expr: /\bzend((?: )?(?:framework|studio|guard))?\b/gi,
//replacement: toTitleCase(), // Doesn't work like built-in toUpperCase, returns 'undefined'. Load order?
replacement: function(str) {
return toTitleCase(str);
},
reason: App.consts.reasons.trademark
},
twitter: {
expr: /\btwitter\b(?![.-]\w)/gi,
replacement: "Twitter",
reason: App.consts.reasons.trademark
},
bootstrap: { // "bootstrap" is also a general computing term, so expect some false positives
expr: /\bbootst?r?ap\b/gi,
replacement: "Bootstrap",
reason: App.consts.reasons.trademark
},
apple: {
expr: /\bapple\b/g,
replacement: "Apple",
reason: App.consts.reasons.trademark
},
iphone: {
expr: /\biph?one?\b/gi,
replacement: "iPhone",
reason: App.consts.reasons.trademark
},
google: { // https://regex101.com/r/qW8fI8/4
expr: /\bgo+(?:g+le?|lge?|gl?el)(e[drs]*|ing)\b/gi,
replacement: "Googl$1",
reason: App.consts.reasons.trademark
},
google_verbed: {
expr: /\bgoogl(?:ed|ing|er)\b/gi,
replacement: function(str) {
return toTitleCase(str);
},
reason: App.consts.reasons.trademark
},
spreadsheet: { // https://regex101.com/r/oK4uW3/1 - must appear before google_things
expr: /\b(s)[pr]+[ea]+dsh?e+t(?:ing)?(s)?\b/gi,
replacement: "$1preadsheet$2",
reason: App.consts.reasons.spelling
},
google_things: { // https://regex101.com/r/iS5fO1/1
expr: /\bgoogle\b[ \t-]*(?:maps?|sheets?|docs?|drive|sites?|forms?|documents?|spreadsheets?|images?|presentations?|play)?\b/gi,
replacement: function(str) {
return toTitleCase(str);
},
reason: App.consts.reasons.trademark
},
google_apps_script: { //Not in google_things due to possible missing 's' on Apps.
expr: /\bgoogle[- ]?(?:apps?)?[- ]?script(ing|s)?\b/gi,
replacement: "Google Apps Script$1",
reason: App.consts.reasons.trademark
},
google_app_engine: { //Not in google_things due to possible 's' on App.
expr: /\bgoogle[- ]?(?:apps?)?[- ]?engine(s)?\b/gi,
replacement: "Google App Engine$1",
reason: App.consts.reasons.trademark
},
google_analytics: { //Not in google_things due to possible missing 's' on analytics.
expr: /\bgoogle[- ]?analytics?\b/gi,
replacement: "Google Analytics",
},
bluetooth: {
expr: /\bbl(?:ue|oo)too?th?\b/gi,
replacement: "Bluetooth",
reason: App.consts.reasons.trademark
},
lenovo: {
expr: /\bleno?vo\b/gi,
replacement: "Lenovo",
reason: App.consts.reasons.trademark
},
matlab: {
expr: /([^\b\w.]|^)math?lab\b/gi,
replacement: "$1MATLAB",
reason: App.consts.reasons.trademark
},
internet: {
expr: /\binternet\b/g,
replacement: "Internet",
reason: App.consts.reasons.trademark
},
oauth: { // https://regex101.com/r/sA2cQ5/1
expr: /\boauth(?:(?: )*(\d)(?!\.\d)|(?: )*([\d.]+))?\b/gi,
replacement: "OAuth$1 $2",
reason: App.consts.reasons.trademark
},
web_services: {
expr: /\bweb services\b/g,
replacement: "Web services",
reason: App.consts.reasons.trademark
},
opencv: {
expr: /\bopencv\b/gi,
replacement: "OpenCV",
reason: App.consts.reasons.trademark
},
ruby: {
expr: /\bruby\b/g,
replacement: "Ruby",
reason: App.consts.reasons.trademark
},
rails: {
expr: /\brails\b/g,
replacement: "Rails",
reason: App.consts.reasons.trademark
},
grails: {
expr: /\bgrails\b/g,
replacement: "Grails",
reason: App.consts.reasons.trademark
},
subversion: {
expr: /\bsubvers[io]*n\b/g,
replacement: "Subversion",
reason: App.consts.reasons.trademark
},
javafx: {
expr: /\bjavafx\b/gi,
replacement: "JavaFX",
reason: App.consts.reasons.trademark
},
delphi: {
expr: /\bdelphi\b/gi,
replacement: "Delphi",
reason: App.consts.reasons.trademark
},
dotnetnuke: {
expr: /\bdotnetnuke\b/gi,
replacement: "DotNetNuke",
reason: App.consts.reasons.trademark
},
silverlight: {
expr: /\bsilv?erl(?:ight|ite)\b/gi,
replacement: "Silverlight",
reason: App.consts.reasons.trademark
},
scipy: {
expr: /([^\b\w.]|^)scipy\b/gi,
replacement: "$1SciPy",
reason: App.consts.reasons.trademark
},
numpy: {
expr: /([^\b\w.]|^)numpy\b/gi,
replacement: "$1NumPy",
reason: App.consts.reasons.trademark
},
openssl: {
expr: /([^\b\w.]|^)openssl\b/gi,
replacement: "$1OpenSSL",
reason: App.consts.reasons.trademark
},
drupal: {
expr: /([^\b\w.]|^)drupal\b/gi,
replacement: "$1Drupal",
reason: App.consts.reasons.trademark
},
saas: {
expr: /([^\b\w.]|^)saas\b/gi,
replacement: "$1SaaS",
reason: App.consts.reasons.trademark
},
gwt: {
expr: /([^\b\w.]|^)gwt[- ](mosaic|designer)?\b/gi,
replacement: function (str,pre,titlecase) {
var fixed = pre + "GWT" + (titlecase ? ' ' + toTitleCase(titlecase) : ' ');
return fixed;
},
reason: App.consts.reasons.trademark
},
gmail: {
expr: /([^\b\w.]|^)gmail(s)?\b/gi,
replacement: "$1Gmail$2",
reason: App.consts.reasons.trademark
},
xampp: {
expr: /([^\b\w.]|^)xam+p+\b/gi,
replacement: "$1XAMPP",
reason: App.consts.reasons.trademark
},
galaxy: {
expr: /([^\b\w.]|^)galaxy\b/gi,
replacement: "$1Galaxy",
reason: App.consts.reasons.trademark
},
mongo: {
expr: /([^\b\w.]|^)mongo(?:\s?(db))?\b/gi,
replacement: function(str,pre,uppercase) {
var fixed = pre + "Mongo" + (uppercase ? uppercase.toUpperCase() : '');
return fixed;
},
reason: App.consts.reasons.trademark
},
pymongo: {
expr: /([^\b\w.]|^)pymongo\b/gi,
replacement: "$1PyMongo",
reason: App.consts.reasons.trademark
},
scala: {
expr: /([^\b\w.]|^)scala\b/gi,
replacement: "$1Scala",
reason: App.consts.reasons.trademark
},
microsoft: { // https://regex101.com/r/dJ5tE3/1
expr: /\b([mM]icrosoft?|[mM]ircosoft|M[Ss]oft)\b/g,
replacement: "Microsoft",
reason: App.consts.reasons.trademark
},
intellisense: {
expr: /\bintell?isen[sc]e?\b/gi,
replacement: "IntelliSense",
reason: App.consts.reasons.trademark
},
sass: { // Syntactically Awesome Style Sheets
expr: /\bsass\b/gi,
replacement: "Sass",
reason: App.consts.reasons.trademark
},
heroku: {
expr: /\bheroku\b/gi,
replacement: "Heroku",
reason: App.consts.reasons.trademark
},
os_x: {
expr: /\bos ?x\b/gi,
replacement: "OS X",
reason: App.consts.reasons.trademark
},
el_capitan: {
expr: /\bel ?capi?tan\b/gi,
replacement: "El Capitan",
reason: App.consts.reasons.trademark
},
hadoop: {
expr: /\bhad+o+p+\b/gi,
replacement: "Hadoop",
reason: App.consts.reasons.trademark
},
django: {
expr: /\bdjango\b/gi,
replacement: "Django",
reason: App.consts.reasons.trademark
},
tcl: {
expr: /([^\b\w.]|^)tcl\b/gi,
replacement: "$1Tcl",
reason: App.consts.reasons.trademark
},
flickr: {
expr: /\bflickr(?!\.\w)/gi,
replacement: "Flickr",
reason: App.consts.reasons.trademark
},
poi: {
expr: /(?:[^\b\w.]|^)poi\b/gi,
replacement: function (match) { return match.toUpperCase(); },
reason: App.consts.reasons.trademark
},
vmware: {
expr: /\bvmware?\b/gi,
replacement: "VMware",
reason: App.consts.reasons.trademark
},
hortonworks: {
expr: /([^\b\w.]|^)horton ?works[- ](sandbox|data platform|phoenix|hive)?\b/gi,
replacement: function (str,pre,titlecase) {
var fixed = pre + "Hortonworks" + (titlecase ? ' ' + toTitleCase(titlecase) : ' ');
return fixed;
},
reason: App.consts.reasons.trademark
},
ambari: {
expr: /\bambari\b/gi,
replacement: "Ambari",
reason: App.consts.reasons.trademark
},
eclipse: {
expr: /\becli[ps]+e\b/gi,
replacement: "Eclipse",
reason: App.consts.reasons.trademark
},
pthread: {
expr: /([^\w.\-/\\_]|^)pthr[ea]+d(s)?\b(?![.\-]\w|[/\\_])/gi,
replacement: "$1Pthread$2",
reason: App.consts.reasons.trademark
},
perl: {
expr: /([^\w.\-/\\_]|^)perl\b(?![.\-]\w|[/\\_])/gi,
replacement: "$1Perl",
reason: App.consts.reasons.trademark
},
htc: {
expr: /\bhtc\b/gi,
replacement: "HTC",
reason: App.consts.reasons.trademark
},
greasemonkey: {
expr: /\bgre[ea]se\W?monkey\b/gi, //Should this also be correcting spelling, or should that be a separate rule?
replacement: "Greasemonkey",
reason: App.consts.reasons.trademark
},
tampermonkey: {
expr: /\btamper\W?monkey\b/gi,
replacement: "Tampermonkey",
reason: App.consts.reasons.trademark
},
violentmonkey: {
expr: /\bviolent\W?monkey\b/gi,
replacement: "Violentmonkey",
reason: App.consts.reasons.trademark
},
mozilla: {
expr: /\bmozill?a\b/gi,
replacement: "Mozilla",
reason: App.consts.reasons.trademark
},
webextensions: {
expr: /\bweb-*extension(s*)\b/gi,
replacement: "WebExtension$1",
reason: App.consts.reasons.trademark
},
firefoxWebextensions: {
expr: /\bfirefox[ \-]*web[ \-]*exten[st]ion(s*)\b/gi,
replacement: "Firefox WebExtension$1",
reason: App.consts.reasons.trademark
},
microsoftedge: {
expr: /\bmicrosoft[ \-]*edge\b/gi,
replacement: "Microsoft Edge",
reason: App.consts.reasons.trademark
},
typescript: {
expr: /\btypescript\b/gi,
replacement: "TypeScript",
reason: App.consts.reasons.trademark
},
xulrunner: {
expr: /\bxulrunner\b/gi,
replacement: "XULRunner",
reason: App.consts.reasons.trademark
},
xul: {
expr: /\bxul\b/gi,
replacement: "XUL",
reason: App.consts.reasons.trademark
},
webrtc: {
expr: /\bwebrtc\b/gi,
replacement: "WebRTC",
reason: App.consts.reasons.trademark
},
cakephp: {
expr: /\bcakephp\b/gi,
replacement: "CakePHP",
reason: App.consts.reasons.trademark
},
usps: {
expr: /\busps\b/gi,
replacement: "USPS",
reason: App.consts.reasons.trademark
},
ups: {
expr: /\bups\b/gi,
replacement: "UPS",
reason: App.consts.reasons.trademark
},
fedex: {
expr: /\bFedEx\b/gi,
replacement: "FedEx",
reason: App.consts.reasons.trademark
},
shopify: {
expr: /\bshopify\b/gi,
replacement: "Shopify",
reason: App.consts.reasons.trademark
},
xcode: {
expr: /\bxcode\b/gi,
replacement: "Xcode",
reason: App.consts.reasons.trademark
},
imagemagic: {
expr: /\bimagemagic\b/gi,
replacement: "ImageMagic",
reason: App.consts.reasons.trademark
},
openfire: {
expr: /\bopenfire\b/gi,
replacement: "Openfire",
reason: App.consts.reasons.trademark
},
wifi: {
expr: /\bwi-?fi\b/gi,
replacement: "Wi-Fi",
reason: App.consts.reasons.trademark
},
springboot: {
expr: /\bspring ?boot\b/gi,
replacement: "Spring Boot",
reason: App.consts.reasons.trademark
},
springcloud: {
expr: /\bspring ?cloud\b/gi,
replacement: "Spring Cloud",
reason: App.consts.reasons.trademark
},
jmeter: {
expr: /\bjmeter\b/gi,
replacement: "JMeter",
reason: App.consts.reasons.trademark
},
digitalocean: {
expr: /\bdigital\W?ocean\b/gi,
replacement: "DigitalOcean",
reason: App.consts.reasons.trademark
},
orangehrm: {
expr: /\borange\W?hrm\b/gi,
replacement: "OrangeHRM",
reason: App.consts.reasons.trademark
},
codeigniter: {
expr: /\bcode\W?igniter\b/gi,
replacement: "CodeIgniter",
reason: App.consts.reasons.trademark
},
openvpn: {
expr: /\bopenvpn(\d?)\b/gi,
replacement: "OpenVPN$1",
reason: App.consts.reasons.trademark
},
tensorflow: {
expr: /\btensor\W?flow\b/gi,
replacement: "TensorFlow",
reason: App.consts.reasons.trademark
},
netsuite: {
expr: /\bnetsuite\b/gi,
replacement: "NetSuite",
reason: App.consts.reasons.trademark
},
cpanel: {
expr: /\bcpanel\b/gi,
replacement: "cPanel",
reason: App.consts.reasons.trademark
},
putty: {
expr: /\bputty\b/gi,
replacement: "PuTTY",
reason: App.consts.reasons.trademark
},
godaddy: {
expr: /\bgodaddy\b/gi,
replacement: "GoDaddy",
reason: App.consts.reasons.trademark
},
cryptoapi: {
expr: /\bcrypto\s?api\b/gi,
replacement: "CryptoAPI",
reason: App.consts.reasons.trademark
},
selenium: {
expr: /\bselenium\b/gi,
replacement: "Selenium",
reason: App.consts.reasons.trademark
},
testng: {
expr: /\btest\s?ng\b/gi,
replacement: "TestNG",
reason: App.consts.reasons.trademark
},
ionic: {
expr: /\bionic(?:\s?pro)?\b/gi,
replacement: function(str) {
return toTitleCase(str);
},
reason: App.consts.reasons.trademark
},
opencart: {
expr: /\bopen\s?cart\b/gi,
replacement: "OpenCart",
reason: App.consts.reasons.trademark
},
woocommerce: {
expr: /\bwoo\s?commerce\b/gi,
replacement: "WooCommerce",
reason: App.consts.reasons.trademark
},
laravel: {
expr: /\blaravel/gi,
replacement: "Laravel",
reason: App.consts.reasons.trademark
},
pfsense: {
expr: /\bpfsense\b/gi,
replacement: "pfSense",
reason: App.consts.reasons.trademark
},
mipsN: {
expr: /\bmips(32|64)?\b/gi,
replacement: "MIPS$1",
reason: App.consts.reasons.trademark
},
armN: {
expr: /\barm(32|64)\b/gi, //arm by itself is too generic to automatically capitalize
replacement: "ARM$1",
reason: App.consts.reasons.trademark
},