comparison src/luan/modules/HtmlLuan.java @ 1333:25746915a241

merge Luan and LuanState
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 12 Feb 2019 22:33:40 -0700
parents 1a68fc55a80c
children a015a0b5c388
comparison
equal deleted inserted replaced
1332:11b7e11f9ed5 1333:25746915a241
5 import java.util.Arrays; 5 import java.util.Arrays;
6 import java.util.Set; 6 import java.util.Set;
7 import java.util.HashSet; 7 import java.util.HashSet;
8 import java.util.Map; 8 import java.util.Map;
9 import luan.Luan; 9 import luan.Luan;
10 import luan.LuanState;
11 import luan.LuanTable; 10 import luan.LuanTable;
12 import luan.LuanException; 11 import luan.LuanException;
13 12
14 13
15 public final class HtmlLuan { 14 public final class HtmlLuan {
46 public static final String STYLE = "style"; 45 public static final String STYLE = "style";
47 46
48 public static Set<String> containerTags = new HashSet<String>(Arrays.asList(SCRIPT,STYLE)); 47 public static Set<String> containerTags = new HashSet<String>(Arrays.asList(SCRIPT,STYLE));
49 */ 48 */
50 /* 49 /*
51 public static LuanTable parse(LuanState luan,String text,LuanTable containerTagsTbl) 50 public static LuanTable parse(Luan luan,String text,LuanTable containerTagsTbl)
52 throws LuanException 51 throws LuanException
53 { 52 {
54 Utils.checkNotNull(luan,text); 53 Utils.checkNotNull(luan,text);
55 Utils.checkNotNull(luan,containerTagsTbl); 54 Utils.checkNotNull(luan,containerTagsTbl);
56 Set<String> containerTags = new HashSet<String>(); 55 Set<String> containerTags = new HashSet<String>();
273 } 272 }
274 */ 273 */
275 274
276 275
277 /* 276 /*
278 public static String to_string(LuanState luan,LuanTable tbl) throws LuanException { 277 public static String to_string(Luan luan,LuanTable tbl) throws LuanException {
279 List<Object> html = tbl.asList(); 278 List<Object> html = tbl.asList();
280 StringBuilder buf = new StringBuilder(); 279 StringBuilder buf = new StringBuilder();
281 for( Object o : html ) { 280 for( Object o : html ) {
282 if( o instanceof String ) { 281 if( o instanceof String ) {
283 buf.append( o ); 282 buf.append( o );
304 throw new LuanException(luan, "invalid value ("+Luan.type(o)+") in table for 'Html.to_string'" ); 303 throw new LuanException(luan, "invalid value ("+Luan.type(o)+") in table for 'Html.to_string'" );
305 } 304 }
306 return buf.toString(); 305 return buf.toString();
307 } 306 }
308 307
309 private static String tagToString(LuanState luan,LuanTable tbl) throws LuanException { 308 private static String tagToString(Luan luan,LuanTable tbl) throws LuanException {
310 StringBuilder buf = new StringBuilder(); 309 StringBuilder buf = new StringBuilder();
311 buf.append('<'); 310 buf.append('<');
312 buf.append(tbl.get(luan,"name")); 311 buf.append(tbl.get(luan,"name"));
313 LuanTable attributes = (LuanTable)tbl.get(luan,"attributes"); 312 LuanTable attributes = (LuanTable)tbl.get(luan,"attributes");
314 for( Map.Entry<Object,Object> attr : attributes.iterable(luan) ) { 313 for( Map.Entry<Object,Object> attr : attributes.iterable(luan) ) {