-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcolor.xml
63 lines (62 loc) · 1.98 KB
/
color.xml
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
<?xml version="1.0" encoding="UTF-8"?>
<Export generator="Cache" version="25" zv="Cache for Windows (x86-32) 2012.2 (Build 612U)" ts="2013-06-14 22:56:35">
<CSP name="color.CSP" application="/csp/user/" default="1"><![CDATA[
<html>
<head>
<title>Colorizer</title>
</head>
<body>
<script language = 'Cache' runat='server'>
s tabSize = $G(%request.Data("tabSize",1),4)
s type = $G(%request.Data("type",1),"COS")
s code = $G(%request.Data("code",1))
</script>
<form method='post'>
Tab size: <input type='text' name='tabSize' size=4 value = #(..QuoteJS(tabSize))# />
Type: <select name="type">
<script language='Cache' runat='server'>
s langs = $LB("CLS","COS","SQL","JS","HTML")
f i=1:1:$LL(langs) {
s lang = $LI(langs,i)
&html<<option value='#(lang)#' #($case(lang,type:"selected",:""))#>#(lang)#</option>>
}
</script>
</select>
Source: <br/>
<textarea name='code' style="width:95%" rows=20>#(..EscapeHTML(code))#</textarea>
<br/><input type='submit'/>
</form>
<csp:if condition='$D(%request.Data("code",1))'>
<script language='Cache' runat='server'>
s tabReplace = ""
s $P(tabReplace, " ",tabSize) = " "
s code = $REPLACE(code,$C(9),tabReplace)
Set instr=##class(%GlobalCharacterStream).%New()
Do instr.WriteLine(code)
Set outstr=##class(%GlobalCharacterStream).%New()
Set colorer=##class(%SyntaxColor).%New()
Set ret=colorer.Color(instr,outstr,type,"PF",,,.langs,.coloringerrors)
If 'ret {Write "Fatal error: ",colorer.DLLResultCode,! Quit}
If coloringerrors {
Write "Syntax error(s)",!
}
w "<fieldset>"
Do outstr.Rewind()
While 'outstr.AtEnd {
Write outstr.ReadLine(),!
}
w "</fieldset>"
</script>
<br/>Result:
<br/><textarea style="width:95%" rows=20>
<script language='Cache' runat='server'>
Do outstr.Rewind()
While 'outstr.AtEnd {
Write $zcvt(outstr.ReadLine(),"O","HTML"),!
}
</script>
</textarea>
</csp:if>
</body>
</html>]]></CSP>
</Export>