Mercurial Hosting > luan
annotate core/src/luan/modules/HtmlLuan.java @ 625:a3c1e11fb6aa
rewrite much of Html to be more understandable;
add Lucene html_highlighter();
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 12 Jan 2016 23:52:56 -0700 |
parents | 60c549d43988 |
children | cdc70de628b5 |
rev | line source |
---|---|
167
4c0131c2b650
merge luan/lib into modules
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
142
diff
changeset
|
1 package luan.modules; |
49
8ede219cd111
add WebShell
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
2 |
318
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
3 import java.util.List; |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
4 import java.util.ArrayList; |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
5 import java.util.Arrays; |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
6 import java.util.Set; |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
7 import java.util.HashSet; |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
8 import java.util.Map; |
221
ec016471c6eb
make LuanTable an interface
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
171
diff
changeset
|
9 import luan.Luan; |
49
8ede219cd111
add WebShell
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
10 import luan.LuanState; |
8ede219cd111
add WebShell
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
11 import luan.LuanTable; |
124
f537ff5e511d
minor cleanup
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
112
diff
changeset
|
12 import luan.LuanException; |
49
8ede219cd111
add WebShell
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
13 |
8ede219cd111
add WebShell
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
14 |
168
ebe9db183eb7
rename *Lib.java to *Luan.java
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
167
diff
changeset
|
15 public final class HtmlLuan { |
49
8ede219cd111
add WebShell
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
16 |
318
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
17 public static String encode(LuanState luan,String s) throws LuanException { |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
18 Utils.checkNotNull(luan,s); |
49
8ede219cd111
add WebShell
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
19 char[] a = s.toCharArray(); |
8ede219cd111
add WebShell
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
20 StringBuilder buf = new StringBuilder(); |
8ede219cd111
add WebShell
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
21 for( int i=0; i<a.length; i++ ) { |
8ede219cd111
add WebShell
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
22 char c = a[i]; |
8ede219cd111
add WebShell
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
23 switch(c) { |
8ede219cd111
add WebShell
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
24 case '&': |
8ede219cd111
add WebShell
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
25 buf.append("&"); |
8ede219cd111
add WebShell
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
26 break; |
8ede219cd111
add WebShell
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
27 case '<': |
8ede219cd111
add WebShell
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
28 buf.append("<"); |
8ede219cd111
add WebShell
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
29 break; |
8ede219cd111
add WebShell
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
30 case '>': |
8ede219cd111
add WebShell
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
31 buf.append(">"); |
8ede219cd111
add WebShell
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
32 break; |
8ede219cd111
add WebShell
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
33 case '"': |
8ede219cd111
add WebShell
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
34 buf.append("""); |
8ede219cd111
add WebShell
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
35 break; |
8ede219cd111
add WebShell
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
36 default: |
8ede219cd111
add WebShell
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
37 buf.append(c); |
8ede219cd111
add WebShell
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
38 } |
8ede219cd111
add WebShell
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
39 } |
8ede219cd111
add WebShell
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
40 return buf.toString(); |
8ede219cd111
add WebShell
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
41 } |
8ede219cd111
add WebShell
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
42 |
318
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
43 /* |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
44 // public static final String TEXTAREA = "textarea"; |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
45 public static final String SCRIPT = "script"; |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
46 public static final String STYLE = "style"; |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
47 |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
48 public static Set<String> containerTags = new HashSet<String>(Arrays.asList(SCRIPT,STYLE)); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
49 */ |
625
a3c1e11fb6aa
rewrite much of Html to be more understandable;
Franklin Schmidt <fschmidt@gmail.com>
parents:
578
diff
changeset
|
50 /* |
318
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
51 public static LuanTable parse(LuanState luan,String text,LuanTable containerTagsTbl) |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
52 throws LuanException |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
53 { |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
54 Utils.checkNotNull(luan,text); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
55 Utils.checkNotNull(luan,containerTagsTbl); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
56 Set<String> containerTags = new HashSet<String>(); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
57 for( Object v : containerTagsTbl.asList() ) { |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
58 containerTags.add((String)v); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
59 } |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
60 List<Object> html = new ArrayList<Object>(); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
61 int len = text.length(); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
62 int i = 0; |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
63 outer: |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
64 while( i < len ) { |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
65 int i2 = text.indexOf('<',i); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
66 while( i2 != -1 && i2+1 < len ) { |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
67 char c = text.charAt(i2+1); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
68 if( Character.isLetter(c) || c=='/' || c=='!' ) |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
69 break; |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
70 i2 = text.indexOf('<',i2+1); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
71 } |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
72 if( i2 == -1 ) { |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
73 html.add( text.substring(i) ); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
74 break; |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
75 } |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
76 if( i < i2 ) |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
77 html.add( text.substring(i,i2) ); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
78 if( text.startsWith("<!--",i2) ) { |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
79 i = text.indexOf("-->",i2+4); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
80 if( i == -1 ) { |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
81 html.add( text.substring(i2) ); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
82 break; |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
83 } |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
84 html.add( comment( text.substring(i2+4,i) ) ); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
85 i += 3; |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
86 } else if( text.startsWith("<![CDATA[",i2) ) { |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
87 i = text.indexOf("]]>",i2+9); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
88 if( i == -1 ) { |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
89 html.add( text.substring(i2) ); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
90 break; |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
91 } |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
92 html.add( cdata( text.substring(i2+9,i) ) ); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
93 i += 3; |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
94 } else { |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
95 i = text.indexOf('>',i2); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
96 if( i == -1 ) { |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
97 html.add( text.substring(i2) ); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
98 break; |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
99 } |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
100 String tagText = text.substring(i2+1,i); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
101 try { |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
102 LuanTable tag = parseTag(tagText); |
426
23a93c118042
fix LuanTable.get() to use metatables
Franklin Schmidt <fschmidt@gmail.com>
parents:
411
diff
changeset
|
103 String tagName = (String)tag.rawGet("name"); |
318
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
104 if( containerTags.contains(tagName) ) { |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
105 i2 = i; |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
106 String endTagName = '/' + tagName; |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
107 while(true) { |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
108 i2 = text.indexOf('<',i2+1); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
109 if( i2 == -1 ) |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
110 break; |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
111 int i3 = text.indexOf('>',i2); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
112 if( i3 == -1 ) |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
113 break; |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
114 int j = i2+1; |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
115 while( j<i3 && !Character.isWhitespace(text.charAt(j)) ) j++; |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
116 String s = text.substring(i2+1,j); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
117 if( s.equalsIgnoreCase(endTagName) ) { |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
118 String text2 = text.substring(i+1,i2); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
119 LuanTable textContainer = textContainer(tag,text2); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
120 html.add( textContainer ); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
121 i = i3 + 1; |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
122 continue outer; |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
123 } |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
124 } |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
125 // logger.warn("unclosed "+tagName); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
126 } |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
127 i += 1; |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
128 html.add( tag ); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
129 } catch(BadTag e) { |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
130 // logger.debug("bad tag",e); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
131 i += 1; |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
132 // if( !removeBadTags ) { |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
133 html.add( "<" ); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
134 html.add( encode(luan,tagText) ); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
135 html.add( ">" ); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
136 // } |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
137 } |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
138 } |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
139 } |
411
23b99a5039b5
remove Luan.newTable()
Franklin Schmidt <fschmidt@gmail.com>
parents:
318
diff
changeset
|
140 return new LuanTable(html); |
318
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
141 } |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
142 |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
143 static LuanTable comment(String text) { |
411
23b99a5039b5
remove Luan.newTable()
Franklin Schmidt <fschmidt@gmail.com>
parents:
318
diff
changeset
|
144 LuanTable tbl = new LuanTable(); |
427
dae264ad6a7b
fix LuanTable.put() to use metatables
Franklin Schmidt <fschmidt@gmail.com>
parents:
426
diff
changeset
|
145 tbl.rawPut("type","comment"); |
dae264ad6a7b
fix LuanTable.put() to use metatables
Franklin Schmidt <fschmidt@gmail.com>
parents:
426
diff
changeset
|
146 tbl.rawPut("text",text); |
318
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
147 return tbl; |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
148 } |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
149 |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
150 static LuanTable cdata(String text) { |
411
23b99a5039b5
remove Luan.newTable()
Franklin Schmidt <fschmidt@gmail.com>
parents:
318
diff
changeset
|
151 LuanTable tbl = new LuanTable(); |
427
dae264ad6a7b
fix LuanTable.put() to use metatables
Franklin Schmidt <fschmidt@gmail.com>
parents:
426
diff
changeset
|
152 tbl.rawPut("type","cdata"); |
dae264ad6a7b
fix LuanTable.put() to use metatables
Franklin Schmidt <fschmidt@gmail.com>
parents:
426
diff
changeset
|
153 tbl.rawPut("text",text); |
318
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
154 return tbl; |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
155 } |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
156 |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
157 static LuanTable textContainer(LuanTable tag,String text) { |
411
23b99a5039b5
remove Luan.newTable()
Franklin Schmidt <fschmidt@gmail.com>
parents:
318
diff
changeset
|
158 LuanTable tbl = new LuanTable(); |
427
dae264ad6a7b
fix LuanTable.put() to use metatables
Franklin Schmidt <fschmidt@gmail.com>
parents:
426
diff
changeset
|
159 tbl.rawPut("type","container"); |
dae264ad6a7b
fix LuanTable.put() to use metatables
Franklin Schmidt <fschmidt@gmail.com>
parents:
426
diff
changeset
|
160 tbl.rawPut("tag",tag); |
dae264ad6a7b
fix LuanTable.put() to use metatables
Franklin Schmidt <fschmidt@gmail.com>
parents:
426
diff
changeset
|
161 tbl.rawPut("text",text); |
318
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
162 return tbl; |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
163 } |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
164 |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
165 |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
166 |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
167 static final class BadTag extends RuntimeException { |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
168 private BadTag(String msg) { |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
169 super(msg); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
170 } |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
171 } |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
172 |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
173 static LuanTable parseTag(String text) { |
411
23b99a5039b5
remove Luan.newTable()
Franklin Schmidt <fschmidt@gmail.com>
parents:
318
diff
changeset
|
174 LuanTable tbl = new LuanTable(); |
427
dae264ad6a7b
fix LuanTable.put() to use metatables
Franklin Schmidt <fschmidt@gmail.com>
parents:
426
diff
changeset
|
175 tbl.rawPut("type","tag"); |
318
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
176 if( text.endsWith("/") ) { |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
177 text = text.substring(0,text.length()-1); |
427
dae264ad6a7b
fix LuanTable.put() to use metatables
Franklin Schmidt <fschmidt@gmail.com>
parents:
426
diff
changeset
|
178 tbl.rawPut("is_empty",true); |
318
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
179 } else { |
427
dae264ad6a7b
fix LuanTable.put() to use metatables
Franklin Schmidt <fschmidt@gmail.com>
parents:
426
diff
changeset
|
180 tbl.rawPut("is_empty",false); |
318
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
181 } |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
182 int len = text.length(); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
183 int i = 0; |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
184 int i2 = i; |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
185 if( i2<len && text.charAt(i2)=='/' ) |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
186 i2++; |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
187 while( i2<len ) { |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
188 char c = text.charAt(i2); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
189 if( Character.isWhitespace(c) ) |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
190 break; |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
191 if( !( Character.isLetterOrDigit(c) || c=='_' || c=='.' || c=='-' || c==':' ) ) |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
192 throw new BadTag("invalid tag name for <"+text+">"); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
193 i2++; |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
194 } |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
195 String name = text.substring(i,i2).toLowerCase(); |
427
dae264ad6a7b
fix LuanTable.put() to use metatables
Franklin Schmidt <fschmidt@gmail.com>
parents:
426
diff
changeset
|
196 tbl.rawPut("name",name); |
411
23b99a5039b5
remove Luan.newTable()
Franklin Schmidt <fschmidt@gmail.com>
parents:
318
diff
changeset
|
197 LuanTable attributes = new LuanTable(); |
427
dae264ad6a7b
fix LuanTable.put() to use metatables
Franklin Schmidt <fschmidt@gmail.com>
parents:
426
diff
changeset
|
198 tbl.rawPut("attributes",attributes); |
318
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
199 i = i2; |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
200 while( i<len && Character.isWhitespace(text.charAt(i)) ) i++; |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
201 while( i<len ) { |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
202 i2 = toEndName(text,i,len); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
203 String attrName = unquote(text.substring(i,i2).toLowerCase()); |
426
23a93c118042
fix LuanTable.get() to use metatables
Franklin Schmidt <fschmidt@gmail.com>
parents:
411
diff
changeset
|
204 if( attributes.rawGet(attrName) != null ) |
318
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
205 throw new BadTag("duplicate attribute: "+attrName); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
206 i = i2; |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
207 while( i<len && Character.isWhitespace(text.charAt(i)) ) i++; |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
208 if( i<len && text.charAt(i) == '=' ) { |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
209 i++; |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
210 i2 = i; |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
211 while( i<len && Character.isWhitespace(text.charAt(i)) ) i++; |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
212 i2 = toEndValue(text,i,len); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
213 String attrValue = text.substring(i,i2); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
214 if( attrValue.indexOf('<') != -1 || attrValue.indexOf('>') != -1 ) |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
215 throw new BadTag("invalid attribute value: "+attrValue); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
216 attrValue = unquote(attrValue); |
427
dae264ad6a7b
fix LuanTable.put() to use metatables
Franklin Schmidt <fschmidt@gmail.com>
parents:
426
diff
changeset
|
217 attributes.rawPut(attrName,attrValue); |
318
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
218 i = i2; |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
219 while( i<len && Character.isWhitespace(text.charAt(i)) ) i++; |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
220 } else { |
427
dae264ad6a7b
fix LuanTable.put() to use metatables
Franklin Schmidt <fschmidt@gmail.com>
parents:
426
diff
changeset
|
221 attributes.rawPut(attrName,true); |
318
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
222 } |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
223 } |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
224 return tbl; |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
225 } |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
226 |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
227 private static int toEndName(String text,int i,int len) { |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
228 if( i==len ) |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
229 return i; |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
230 char c = text.charAt(i); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
231 switch(c) { |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
232 case '"': |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
233 case '\'': |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
234 i = text.indexOf(c,i+1); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
235 return i==-1 ? len : i+1; |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
236 default: |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
237 if( Character.isWhitespace(c) ) { |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
238 throw new RuntimeException("text="+text+" i="+i); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
239 } |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
240 do { |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
241 i++; |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
242 } while( i<len && (c=text.charAt(i))!='=' && !Character.isWhitespace(c) ); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
243 return i; |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
244 } |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
245 } |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
246 |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
247 private static int toEndValue(String text,int i,int len) { |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
248 if( i==len ) |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
249 return i; |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
250 char c = text.charAt(i); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
251 switch(c) { |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
252 case '"': |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
253 case '\'': |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
254 i = text.indexOf(c,i+1); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
255 return i==-1 ? len : i+1; |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
256 default: |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
257 if( Character.isWhitespace(c) ) { |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
258 throw new RuntimeException("text="+text+" i="+i); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
259 } |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
260 do { |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
261 i++; |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
262 } while( i<len && !Character.isWhitespace(text.charAt(i)) ); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
263 return i; |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
264 } |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
265 } |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
266 |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
267 public static String unquote(String s) { |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
268 if( s==null || s.length()<=1 ) |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
269 return s; |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
270 char c = s.charAt(0); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
271 return (c=='"' || c=='\'') && s.charAt(s.length()-1)==c |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
272 ? s.substring(1,s.length()-1) : s; |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
273 } |
625
a3c1e11fb6aa
rewrite much of Html to be more understandable;
Franklin Schmidt <fschmidt@gmail.com>
parents:
578
diff
changeset
|
274 */ |
318
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
275 |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
276 |
625
a3c1e11fb6aa
rewrite much of Html to be more understandable;
Franklin Schmidt <fschmidt@gmail.com>
parents:
578
diff
changeset
|
277 /* |
318
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
278 public static String to_string(LuanState luan,LuanTable tbl) throws LuanException { |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
279 List<Object> html = tbl.asList(); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
280 StringBuilder buf = new StringBuilder(); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
281 for( Object o : html ) { |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
282 if( o instanceof String ) { |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
283 buf.append( o ); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
284 } else if( o instanceof LuanTable ) { |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
285 LuanTable t = (LuanTable)o; |
575
7c3ad6db8ac3
make LuanState.JAVA private
Franklin Schmidt <fschmidt@gmail.com>
parents:
572
diff
changeset
|
286 String type = (String)t.get(luan,"type"); |
318
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
287 if( type==null ) |
578
60c549d43988
remove LuanState.exception()
Franklin Schmidt <fschmidt@gmail.com>
parents:
575
diff
changeset
|
288 throw new LuanException(luan, "no type in element of table for 'Html.to_string'" ); |
318
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
289 if( type.equals("comment") ) { |
575
7c3ad6db8ac3
make LuanState.JAVA private
Franklin Schmidt <fschmidt@gmail.com>
parents:
572
diff
changeset
|
290 buf.append( "<!--" ).append( t.get(luan,"text") ).append( "-->" ); |
318
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
291 } else if( type.equals("cdata") ) { |
575
7c3ad6db8ac3
make LuanState.JAVA private
Franklin Schmidt <fschmidt@gmail.com>
parents:
572
diff
changeset
|
292 buf.append( "<![CDATA[" ).append( t.get(luan,"text") ).append( "]]" ); |
318
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
293 } else if( type.equals("tag") ) { |
426
23a93c118042
fix LuanTable.get() to use metatables
Franklin Schmidt <fschmidt@gmail.com>
parents:
411
diff
changeset
|
294 buf.append( tagToString(luan,t) ); |
318
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
295 } else if( type.equals("container") ) { |
575
7c3ad6db8ac3
make LuanState.JAVA private
Franklin Schmidt <fschmidt@gmail.com>
parents:
572
diff
changeset
|
296 LuanTable tag = (LuanTable)t.get(luan,"tag"); |
426
23a93c118042
fix LuanTable.get() to use metatables
Franklin Schmidt <fschmidt@gmail.com>
parents:
411
diff
changeset
|
297 buf.append( tagToString(luan,tag) ); |
575
7c3ad6db8ac3
make LuanState.JAVA private
Franklin Schmidt <fschmidt@gmail.com>
parents:
572
diff
changeset
|
298 buf.append( t.get(luan,"text") ); |
7c3ad6db8ac3
make LuanState.JAVA private
Franklin Schmidt <fschmidt@gmail.com>
parents:
572
diff
changeset
|
299 buf.append( "</" ).append( tag.get(luan,"name") ).append( ">" ); |
318
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
300 } else { |
578
60c549d43988
remove LuanState.exception()
Franklin Schmidt <fschmidt@gmail.com>
parents:
575
diff
changeset
|
301 throw new LuanException(luan, "invalid element type for 'Html.to_string'" ); |
318
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
302 } |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
303 } else |
578
60c549d43988
remove LuanState.exception()
Franklin Schmidt <fschmidt@gmail.com>
parents:
575
diff
changeset
|
304 throw new LuanException(luan, "invalid value ("+Luan.type(o)+") in table for 'Html.to_string'" ); |
318
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
305 } |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
306 return buf.toString(); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
307 } |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
308 |
426
23a93c118042
fix LuanTable.get() to use metatables
Franklin Schmidt <fschmidt@gmail.com>
parents:
411
diff
changeset
|
309 private static String tagToString(LuanState luan,LuanTable tbl) throws LuanException { |
318
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
310 StringBuilder buf = new StringBuilder(); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
311 buf.append('<'); |
575
7c3ad6db8ac3
make LuanState.JAVA private
Franklin Schmidt <fschmidt@gmail.com>
parents:
572
diff
changeset
|
312 buf.append(tbl.get(luan,"name")); |
7c3ad6db8ac3
make LuanState.JAVA private
Franklin Schmidt <fschmidt@gmail.com>
parents:
572
diff
changeset
|
313 LuanTable attributes = (LuanTable)tbl.get(luan,"attributes"); |
7c3ad6db8ac3
make LuanState.JAVA private
Franklin Schmidt <fschmidt@gmail.com>
parents:
572
diff
changeset
|
314 for( Map.Entry<Object,Object> attr : attributes.iterable(luan) ) { |
318
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
315 buf.append( ' ' ); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
316 buf.append( attr.getKey() ); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
317 Object val = attr.getValue(); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
318 if( !val.equals(Boolean.TRUE) ) { |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
319 buf.append( '=' ); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
320 buf.append( quote((String)val) ); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
321 } |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
322 } |
575
7c3ad6db8ac3
make LuanState.JAVA private
Franklin Schmidt <fschmidt@gmail.com>
parents:
572
diff
changeset
|
323 if( tbl.get(luan,"is_empty").equals(Boolean.TRUE) ) |
318
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
324 buf.append('/'); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
325 buf.append('>'); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
326 return buf.toString(); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
327 } |
625
a3c1e11fb6aa
rewrite much of Html to be more understandable;
Franklin Schmidt <fschmidt@gmail.com>
parents:
578
diff
changeset
|
328 */ |
318
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
329 public static String quote(String s) { |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
330 StringBuilder buf = new StringBuilder(); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
331 buf.append('"'); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
332 int i = 0; |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
333 while(true) { |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
334 int i2 = s.indexOf('"',i); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
335 if( i2 == -1 ) { |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
336 buf.append(s.substring(i)); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
337 break; |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
338 } else { |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
339 buf.append(s.substring(i,i2)); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
340 buf.append("""); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
341 i = i2 + 1; |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
342 } |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
343 } |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
344 buf.append('"'); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
345 return buf.toString(); |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
346 } |
4fe6c9fed486
add html processing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
302
diff
changeset
|
347 |
49
8ede219cd111
add WebShell
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
348 } |