4 |
|
// |
5 |
|
// $Id$ |
6 |
|
|
7 |
< |
#include "Tag.hpp" |
7 |
> |
#include "Cleaner.hpp" |
8 |
|
#include "Matcher.hpp" |
9 |
|
|
10 |
|
#include <menes-api/exename.hpp> |
82 |
|
|
83 |
|
void Iffy::iffy(ios::Reader& in, ios::Writer& out) |
84 |
|
{ |
85 |
– |
ios::FormatWriter fout(out); |
86 |
– |
|
87 |
– |
fout << "<html>"; |
88 |
– |
|
85 |
|
ext::String segment; |
86 |
|
bool text(false); |
87 |
< |
ext::Stack<ext::String> opens; |
87 |
> |
Cleaner cleaner; |
88 |
|
|
89 |
|
while (read(in, segment, (text = !text))) if (text) |
90 |
|
{ |
91 |
< |
fout << segment; |
91 |
> |
cleaner.insert(segment); |
92 |
|
} |
93 |
|
else |
94 |
|
{ |
96 |
|
|
97 |
|
if (segment == matcher("^!--( \\(\\d{1,2}:\\d{2}:\\d{2} [AP]M\\))--$")) |
98 |
|
{ |
99 |
< |
fout << matcher[1]; |
99 |
> |
cleaner.insert(matcher[1]); |
100 |
|
|
101 |
|
continue; |
102 |
|
} |
105 |
|
|
106 |
|
if (tag == "br") tag = STANDALONE; |
107 |
|
|
108 |
< |
switch (tag) |
109 |
< |
{ |
114 |
< |
case OPEN: |
115 |
< |
opens.Push(tag); |
108 |
> |
cleaner.insert(tag); |
109 |
> |
} |
110 |
|
|
111 |
< |
break; |
118 |
< |
case CLOSE: |
119 |
< |
if (tag != opens.Top()) tag = opens.Top(); |
120 |
< |
|
121 |
< |
opens.Pop(); |
122 |
< |
|
123 |
< |
break; |
124 |
< |
default: |
125 |
< |
break; |
126 |
< |
} |
111 |
> |
cleaner.clean(); |
112 |
|
|
113 |
< |
fout << tag; |
129 |
< |
} |
113 |
> |
ios::FormatWriter fout(out); |
114 |
|
|
115 |
< |
fout << "</html>\n"; |
115 |
> |
fout << cleaner; |
116 |
|
} |
117 |
|
|
118 |
|
bool Iffy::read(ios::Reader& in, ext::String& segment, bool text) |