comparison src/goodjava/html/Html.java @ 1714:31a82b0d0a87

bbcode and html work
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 18 Jul 2022 23:49:47 -0600
parents 36c28be6d432
children a045f30fa67d
comparison
equal deleted inserted replaced
1713:4d70e9543ef2 1714:31a82b0d0a87
70 public static final class Tag { 70 public static final class Tag {
71 public final String name; 71 public final String name;
72 public final Map<String,Object> attributes; 72 public final Map<String,Object> attributes;
73 public final boolean isEmpty; 73 public final boolean isEmpty;
74 public final String raw; 74 public final String raw;
75 public final Map<String,String> style;
75 76
76 private Tag(String name,Map<String,Object> attributes,boolean isEmpty,String raw) { 77 private Tag(String name,Map<String,Object> attributes,boolean isEmpty,String raw) {
78 this(name,attributes,isEmpty,raw,null);
79 }
80
81 private Tag(String name,Map<String,Object> attributes,boolean isEmpty,String raw,Map<String,String> style) {
77 this.name = name; 82 this.name = name;
78 this.attributes = attributes; 83 this.attributes = attributes;
79 this.isEmpty = isEmpty; 84 this.isEmpty = isEmpty;
80 this.raw = raw; 85 this.raw = raw;
86 this.style = style;
81 } 87 }
82 } 88 }
83 89
84 public static final class Container { 90 public static final class Container {
85 public final Tag tag; 91 public final Tag tag;
207 return parser.failure(null); 213 return parser.failure(null);
208 while( matchNameChar() ); 214 while( matchNameChar() );
209 String name = parser.textFrom(start).toLowerCase(); 215 String name = parser.textFrom(start).toLowerCase();
210 Map<String,Object> attributes = new HashMap<String,Object>(); 216 Map<String,Object> attributes = new HashMap<String,Object>();
211 String attrName; 217 String attrName;
218 Map<String,String> style = null;
212 while( (attrName = parseAttrName()) != null ) { 219 while( (attrName = parseAttrName()) != null ) {
213 String attrValue = parseAttrValue(); 220 String attrValue = parseAttrValue();
214 attributes.put( attrName, attrValue!=null ? attrValue : true ); 221 attributes.put( attrName, attrValue!=null ? attrValue : true );
215 /* 222 if( attrName.equals("style") && attrValue!=null && style==null ) {
216 if( attrName.equals("style") && attrValue!=null ) { 223 style = Css.style(attrValue);
217 LuanTable style = Css.style(attrValue); 224 }
218 if( style!=null )
219 tbl.rawPut("style",style);
220 }
221 */
222 } 225 }
223 while( matchSpace() ); 226 while( matchSpace() );
224 boolean isEmpty = parser.match('/'); 227 boolean isEmpty = parser.match('/');
225 if( !parser.match('>') ) 228 if( !parser.match('>') )
226 return parser.failure(null); 229 return parser.failure(null);
227 String raw = parser.textFrom(tagStart); 230 String raw = parser.textFrom(tagStart);
228 Tag tag = new Tag(name,attributes,isEmpty,raw); 231 Tag tag = new Tag(name,attributes,isEmpty,raw,style);
229 return parser.success(tag); 232 return parser.success(tag);
230 } 233 }
231 234
232 private String parseAttrName() { 235 private String parseAttrName() {
233 parser.begin(); 236 parser.begin();