MCPcopy Index your code
hub / github.com/prettydiff/prettydiff / mode

Function mode

api/mode.ts:2–761  ·  view source on GitHub ↗
(diffmeta?:diffmeta)

Source from the content-addressed store, hash-verified

1/*global prettydiff*/
2function mode(diffmeta?:diffmeta):string {
3 "use strict";
4 const pdcomment = function mode_pdcomment():void {
5 const ops:any = prettydiff.sparser.options;
6 let sindex:number = options.source.search(/((\/(\*|\/))|<!--*)\s*prettydiff\.com/),
7 dindex:number = options.diff.search(/((\/(\*|\/))|<!--*)\s*prettydiff\.com/),
8 a:number = 0,
9 b:number = 0,
10 keys:string[],
11 def:any,
12 len:number;
13 // parses the prettydiff settings comment
14 //
15 // - Source Priorities:
16 // * the prettydiff comment is only accepted if it occurs before non-comments (near the top)
17 // * options.source is the priority material for reading the comment
18 // * the prettydiff comment will be processed from options.diff only if it present there, missing from options.source, and options.mode is diff
19 //
20 // - Examples:
21 // /*prettydiff.com width:80 preserve:4*/
22 // /* prettydiff.com width:80 preserve:4 */
23 // /*prettydiff.com width=80 preserve=4 */
24 // // prettydiff.com width=80 preserve:4
25 // <!-- prettydiff.com width:80 preserve=4 -->
26 // <!--prettydiff.com width:40 preserve:2-->
27 //
28 // - Parsing Considerations:
29 // * there may be any amount of space at the start or end of the comment
30 // * "prettydiff.com" must exist at the start of the comment
31 // * comment must exist prior to non-comment tokens (near top of code)
32 // * parameters are name value pairs separated by white space
33 // * the delimiter separating name and value is either ":" or "=" characters
34
35 if ((sindex > -1 && (sindex === 0 || "\"':".indexOf(options.source.charAt(sindex - 1)) < 0)) || (options.mode === "diff" && dindex > -1 && (dindex === 0 || "\"':".indexOf(options.diff.charAt(dindex - 1)) < 0))) {
36 let pdcom:number = sindex,
37 a:number = (pdcom > -1)
38 ? pdcom
39 : dindex,
40 b:number = 0,
41 quote:string = "",
42 item:string = "",
43 lang:string = "",
44 lex:string = "",
45 valkey:string[] = [],
46 op:string[] = [];
47 const ops:string[] = [],
48 source:string = (pdcom > -1)
49 ? options.source
50 : options.diff,
51 len:number = source.length,
52 comment:string = (source.charAt(a) === "<")
53 ? "<!--"
54 : (source.charAt(a + 1) === "/")
55 ? "//"
56 : "/\u002a",
57 esc = function mode_pdcomment_esc():boolean {
58 if (source.charAt(a - 1) !== "\\") {
59 return false;
60 }

Callers 1

mode.tsFile · 0.85

Calls 8

pdcommentFunction · 0.85
rowFunction · 0.85
padFunction · 0.85
tabFunction · 0.85
insertFunction · 0.85
delFunction · 0.85
summaryFunction · 0.85
autoMethod · 0.80

Tested by

no test coverage detected