Rev Author Line No. Line
253 miho 1 <hcax version="1">
2 <file ID="HTML" Name="MS Word HTML (*.htm;*.html)" Wildcard="*.htm;*.html" RemoveComments="0" IgnoreUnknownTags="1" cssc="breakstyle:None" PostOptimizeHandler="WordOnPostOptimize" PreFileHandler="WordOnPreFile">
3 <tag Name="__default" DeleteTag="0" RemoveQuote="1" PackString="1" Container="1" RemovePrecedingWhitespace="2" DeleteEmptyAttr="0" />
4 <tag Name=style DeleteTag="1" RemoveQuote="0" PackString="2" Container="1" RemovePrecedingWhitespace="2" DeleteEmptyAttr="0" OnParseContent="RemoveStyleContent" />
5 <tag Name=/style DeleteTag="1" RemoveQuote="0" PackString="0" Container="0" RemovePrecedingWhitespace="2" DeleteEmptyAttr="1" />
6 <tag Name=body DeleteTag="0" RemoveQuote="0" PackString="0" Container="1" RemovePrecedingWhitespace="2" DeleteEmptyAttr="1">
7 <attrs Name=link DeleteAttr="1" DeleteTag="0" RemoveQuote="0" PackString="0" Container="1" RemovePrecedingWhitespace="2" DeleteEmptyAttr="1" />
8 <attrs Name=vlink DeleteAttr="1" DeleteTag="0" RemoveQuote="0" PackString="0" Container="1" RemovePrecedingWhitespace="2" DeleteEmptyAttr="1" />
9 </tag>
10 <tag Name=div DeleteTag="0" RemoveQuote="0" PackString="0" Container="1" RemovePrecedingWhitespace="2" DeleteEmptyAttr="1">
11 <attrs Name=class DeleteAttr="1" DeleteTag="0" RemoveQuote="0" PackString="0" Container="1" RemovePrecedingWhitespace="2" DeleteEmptyAttr="1" ReplaceWith="div class=&quot;Text&quot;">
12 <attr Name=Class MatchName=0 Value=Section MatchValue=mvContains />
13 </attrs>
14 </tag>
15 <tag Name=h1 DeleteTag="0" RemoveQuote="0" PackString="0" Container="1" RemovePrecedingWhitespace="2" DeleteEmptyAttr="1">
16 <attrs Name=style DeleteAttr="1" DeleteTag="0" RemoveQuote="0" PackString="0" Container="1" RemovePrecedingWhitespace="2" DeleteEmptyAttr="1" />
17 <attrs Name=align DeleteAttr="1" DeleteTag="0" RemoveQuote="0" PackString="0" Container="1" RemovePrecedingWhitespace="2" DeleteEmptyAttr="1" />
18 </tag>
19 <tag Name=h2 DeleteTag="0" RemoveQuote="0" PackString="0" Container="1" RemovePrecedingWhitespace="2" DeleteEmptyAttr="1">
20 <attrs Name=style DeleteAttr="1" DeleteTag="0" RemoveQuote="0" PackString="0" Container="1" RemovePrecedingWhitespace="2" DeleteEmptyAttr="1" />
21 <attrs Name=align DeleteAttr="1" DeleteTag="0" RemoveQuote="0" PackString="0" Container="1" RemovePrecedingWhitespace="2" DeleteEmptyAttr="1" />
22 </tag>
23 <tag Name=h3 DeleteTag="0" RemoveQuote="0" PackString="0" Container="1" RemovePrecedingWhitespace="2" DeleteEmptyAttr="1">
24 <attrs Name=style DeleteAttr="1" DeleteTag="0" RemoveQuote="0" PackString="0" Container="1" RemovePrecedingWhitespace="2" DeleteEmptyAttr="1" />
25 <attrs Name=align DeleteAttr="1" DeleteTag="0" RemoveQuote="0" PackString="0" Container="1" RemovePrecedingWhitespace="2" DeleteEmptyAttr="1" />
26 </tag>
27 <tag Name=h4 DeleteTag="0" RemoveQuote="0" PackString="0" Container="1" RemovePrecedingWhitespace="2" DeleteEmptyAttr="1">
28 <attrs Name=style DeleteAttr="1" DeleteTag="0" RemoveQuote="0" PackString="0" Container="1" RemovePrecedingWhitespace="2" DeleteEmptyAttr="1" />
29 <attrs Name=align DeleteAttr="1" DeleteTag="0" RemoveQuote="0" PackString="0" Container="1" RemovePrecedingWhitespace="2" DeleteEmptyAttr="1" />
30 </tag>
31 <tag Name=img DeleteTag="0" RemoveQuote="0" PackString="1" Container="0" RemovePrecedingWhitespace="2" DeleteEmptyAttr="1">
32 <attrs Name=align DeleteAttr="1" DeleteTag="0" RemoveQuote="0" PackString="1" Container="0" RemovePrecedingWhitespace="2" DeleteEmptyAttr="1" />
33 <attrs Name=hspace DeleteAttr="1" DeleteTag="0" RemoveQuote="0" PackString="1" Container="0" RemovePrecedingWhitespace="2" DeleteEmptyAttr="1" />
34 <attrs Name=style DeleteAttr="1" DeleteTag="0" RemoveQuote="0" PackString="1" Container="0" RemovePrecedingWhitespace="2" DeleteEmptyAttr="1" />
35 </tag>
36 <tag Name=td DeleteTag="0" RemoveQuote="0" PackString="0" Container="1" RemovePrecedingWhitespace="2" DeleteEmptyAttr="1">
37 <attrs Name=width DeleteAttr="1" DeleteTag="0" RemoveQuote="0" PackString="0" Container="1" RemovePrecedingWhitespace="2" DeleteEmptyAttr="1" />
38 <attrs Name=valign DeleteAttr="1" DeleteTag="0" RemoveQuote="0" PackString="0" Container="1" RemovePrecedingWhitespace="2" DeleteEmptyAttr="1" />
39 <attrs Name=style DeleteAttr="1" DeleteTag="0" RemoveQuote="0" PackString="0" Container="1" RemovePrecedingWhitespace="2" DeleteEmptyAttr="1" />
40 </tag>
41 <tag Name=table DeleteTag="0" RemoveQuote="0" PackString="0" Container="1" RemovePrecedingWhitespace="2" DeleteEmptyAttr="1">
42 <attrs Name=class DeleteAttr="1" DeleteTag="0" RemoveQuote="0" PackString="0" Container="1" RemovePrecedingWhitespace="2" DeleteEmptyAttr="1">
43 <attr Name=class MatchName=1 Value=Mso MatchValue=mvContains />
44 </attrs>
45 <attrs Name=style DeleteAttr="1" DeleteTag="0" RemoveQuote="0" PackString="0" Container="1" RemovePrecedingWhitespace="2" DeleteEmptyAttr="1" />
46 <attrs Name=border DeleteAttr="1" DeleteTag="0" RemoveQuote="0" PackString="0" Container="1" RemovePrecedingWhitespace="2" DeleteEmptyAttr="1" />
47 <attrs Name=cellspacing DeleteAttr="1" DeleteTag="0" RemoveQuote="0" PackString="0" Container="1" RemovePrecedingWhitespace="2" DeleteEmptyAttr="1" />
48 <attrs Name=cellpadding DeleteAttr="1" DeleteTag="0" RemoveQuote="0" PackString="0" Container="1" RemovePrecedingWhitespace="2" DeleteEmptyAttr="1" />
49 </tag>
50 <tag Name=tr DeleteTag="0" RemoveQuote="0" PackString="0" Container="1" RemovePrecedingWhitespace="2" DeleteEmptyAttr="1">
51 <attrs Name=style DeleteAttr="1" DeleteTag="0" RemoveQuote="0" PackString="0" Container="1" RemovePrecedingWhitespace="2" DeleteEmptyAttr="1" />
52 </tag>
53 <tag Name=ul DeleteTag="0" RemoveQuote="0" PackString="0" Container="1" RemovePrecedingWhitespace="2" DeleteEmptyAttr="1">
54 <attrs Name=style DeleteAttr="1" DeleteTag="0" RemoveQuote="0" PackString="0" Container="1" RemovePrecedingWhitespace="2" DeleteEmptyAttr="1" />
55 <attrs Name=type DeleteAttr="1" DeleteTag="0" RemoveQuote="0" PackString="0" Container="1" RemovePrecedingWhitespace="2" DeleteEmptyAttr="1" />
56 </tag>
57 <tag Name=li DeleteTag="0" RemoveQuote="0" PackString="0" Container="1" RemovePrecedingWhitespace="2" DeleteEmptyAttr="1">
58 <attrs Name=class DeleteAttr="1" DeleteTag="0" RemoveQuote="0" PackString="0" Container="1" RemovePrecedingWhitespace="2" DeleteEmptyAttr="1">
59 <attr Name=class MatchName=0 Value=MsoNormal MatchValue=mvEqual />
60 </attrs>
61 </tag>
62 <tag Name=p DeleteTag="0" RemoveQuote="0" PackString="0" Container="1" RemovePrecedingWhitespace="2" DeleteEmptyAttr="1">
63 <attrs Name=class DeleteAttr="1" DeleteTag="0" RemoveQuote="0" PackString="0" ReplaceWith="p class=&quot;Subtitle&quot;" Container="1" RemovePrecedingWhitespace="2" DeleteEmptyAttr="1">
64 <attr MatchName=0 Value=MsoSubtitle MatchValue=mvEqual />
65 </attrs>
66 <attrs Name=class DeleteAttr="1" DeleteTag="0" RemoveQuote="0" PackString="0" Container="1" RemovePrecedingWhitespace="2" DeleteEmptyAttr="1">
67 <attr Name=class MatchName=0 Value=MsoNormal MatchValue=mvEqual />
68 </attrs>
69 <attrs Name=class DeleteAttr="1" DeleteTag="0" RemoveQuote="0" PackString="0" Container="1" RemovePrecedingWhitespace="2" DeleteEmptyAttr="1">
70 <attr Name=class MatchName=0 Value=MsoHeader MatchValue=mvEqual />
71 </attrs>
72 <attrs Name=style DeleteAttr="0" DeleteTag="1" RemoveQuote="0" PackString="0" Container="1" RemovePrecedingWhitespace="2" DeleteEmptyAttr="1" />
73 </tag>
74 </file>
75 <script version="0">const
76 Indent = ' ';//#32#32;
77 Format = True;
78 RemoveStyleWidth = False;
79 RemoveEmptyTags = True;
80  
81 var
82 blocktags: TStringList;
83 inlinetags: TStringList;
84 Level: Integer;
85  
86 procedure Initialize;
87 begin
88 blocktags := TStringList.Create;
89 blocktags.Add('html');
90 blocktags.Add('body');
91 blocktags.Add('head');
92 blocktags.Add('td');
93 blocktags.Add('table');
94 blocktags.Add('tbody');
95  
96 inlinetags := TStringList.Create;
97 inlinetags.Add('a');
98 inlinetags.Add('b');
99 inlinetags.Add('i');
100 inlinetags.Add('img');
101 inlinetags.Add('span');
102 inlinetags.Add('sup');
103 inlinetags.Add('big');
104 inlinetags.Add('small');
105 end;
106  
107 procedure Finalize;
108 begin
109 blocktags.Clear;
110 blocktags.Free;
111 inlinetags.Clear;
112 inlinetags.Free;
113 end;
114  
115 function GetIndentStr: String;
116 var
117 i: Integer;
118 begin
119 Result := '';
120 for i := 0 to Level - 1 do
121 Result := Result + Indent;
122 end;
123  
124 function InLineTag: Boolean;
125 begin
126 result := inlinetags.IndexOf(NodeClass.Name) &gt;= 0;
127 end;
128  
129 function BlockEndTag: Boolean;
130 begin
131 result := blocktags.IndexOf(Copy(NodeClass.Name, 2, Length(NodeClass.Name) -1)) &gt;= 0;
132 end;
133  
134 function BlockTag: Boolean;
135 begin
136 result := blocktags.IndexOf(NodeClass.Name) &gt;= 0;
137 end;
138  
139 function EndTag: Boolean;
140 begin
141 result := Copy(NodeClass.Name, 1, 1) = '/';
142 end;
143  
144 procedure GoToBeginning;
145 begin
146 // go to beginning
147 while NodeClass.PreviousNode do
148 ;
149 end;
150  
151 procedure NewIndentedLine;
152 var
153 i: Integer;
154 begin
155 NodeClass.PreviousNode;
156 if NodeClass.NodeType = ntText then
157 begin
158 i := Length(NodeClass.Name);
159 while (i &gt; 0) and (NodeClass.Name = #32) do
160 begin
161 i := i - 1;
162 end;
163 if (i = 0) then
164 NodeClass.Delete
165 else
166 NodeClass.Name := Copy(NodeClass.Name, 1, i);
167 end;
168 NodeClass.Add;
169 Nodeclass.NextNode;
170 NodeClass.NodeType := ntCustom;
171 NodeClass.Name := #13#10 + GetIndentStr;
172 NodeClass.NextNode;
173 end;
174  
175 procedure DoFormat;
176 begin
177 GoToBeginning;
178 // new line per item
179 while NodeClass.NextNode do
180 begin
181 if (NodeClass.NodeType = ntTag) then
182 begin
183 if EndTag then
184 begin
185 if BlockEndTag then
186 begin
187 Level := Level - 1;
188 NewIndentedLine;
189 end;
190 end
191 else
192 begin
193 if not InLineTag then
194 begin
195 NewIndentedLine;
196 end;
197 if BlockTag then Level := Level + 1;
198 end;
199 end;
200 end;
201 end;
202  
203 procedure WordOnPreFile(var S: String; var Pos: Integer);
204 var
205 i: Integer;
206 c: Integer;
207 begin
208 Level := 0;
209 i := Length(S);
210 while i &gt; 0 do
211 begin
212 if S[i] = #$A0 then s[i] := #32
213 else if SameTextLi(S, '&amp;nbsp;', i, 1, 6) then
214 begin
215 for c := i to i + 5 do
216 s[c] := ' ';
217 end;
218 i := i - 1;
219 end;
220 end;
221  
222 procedure WordOnPostOptimize;
223 var
224 starttag, endtagname: String;
225 begin
226 // remove empty paragraphs with &amp;nbsp;
227 while NodeClass.NextNode do
228 begin
229 if NodeClass.NodeType = ntText then
230 begin
231 if (NodeClass.Name = '&amp;nbsp;') or (NodeClass.Name = ' ') then
232 begin
233 if NodeClass.NextNode and // check next node is an end node
234 (NodeClass.NodeType = ntTag) and EndTag then
235 begin
236 endtagname := NodeClass.Name;
237 // go back find start node
238 if NodeClass.PreviousNode then // text (&amp;nbsp;) node
239 begin
240 if NodeClass.PreviousNode then // NodeClass.NodeType = ntTag
241 begin
242 while NodeClass.NodeType = ntAttribute do
243 begin
244 NodeClass.PreviousNode;
245 end;
246 starttag := NodeClass.Name;
247 if (NodeClass.NodeType = ntTag)
248 and ('/' + starttag = endtagname) then
249 begin
250 // delete start tag
251 NodeClass.Delete;
252 NodeClass.NextNode;
253 // delete any attributes
254 while NodeClass.NodeType = ntAttribute do
255 begin
256 NodeClass.Delete;
257 NodeClass.NextNode;
258 end;
259 // delete text
260 NodeClass.Delete;
261 // delete end tag
262 NodeClass.NextNode;
263 NodeClass.Delete;
264  
265 NodeClass.NextNode;
266 end
267 else
268 begin
269 NodeClass.NextNode; // node
270 // attributes
271 while NodeClass.NodeType = ntAttribute do
272 begin
273 // NodeClass.Delete; // by default it goes backwards first
274 NodeClass.NextNode;
275 end;
276 NodeClass.NextNode; // text
277 end;
278 end
279 else
280 begin
281 NodeClass.NextNode;
282 end;
283 end
284 end;
285 end;
286 end;
287 end; { while }
288  
289 GoToBeginning;
290  
291 if RemoveStyleWidth then
292 while NodeClass.NextNode do
293 begin
294 if (NodeClass.NodeType = ntAttribute) and
295 (SameText(NodeClass.Name, 'style') or
296 SameText(NodeClass.Name, 'width')) then
297 begin
298 NodeClass.Delete;
299 end;
300 end; { while }
301  
302 GoToBeginning;
303  
304 // remove empty tags
305 if RemoveEmptyTags then
306 while NodeClass.NextNode do
307 begin
308 if NodeClass.NodeType = ntTag then
309 begin
310 starttag := NodeClass.Name;
311 if NodeClass.NextNode and EndTag and (NodeClass.name = '/' + Starttag)
312 then
313 begin
314 NodeClass.Delete;
315 NodeClass.Delete;
316 end;
317 end;
318 end;
319  
320 if Format then DoFormat;
321 end;
322  
323 procedure RemoveStyleContent(S: String; var Pos: Integer);
324 begin
325 while Pos &lt; Length(S) do
326 begin
327 if (SameTextLi(s, '&lt;/style&gt;', pos, 1, 8)) then
328 begin
329 Break;
330 end
331 Pos := Pos + 1;
332 end;
333 end;
334  
335 begin
336 Level := 0;
337 Initialize;
338 end.</script>
339 </hcax>