10 |
|
#include <menes-api/exename.hpp> |
11 |
|
#include <menes-api/files.hpp> |
12 |
|
#include <menes-app/application.hpp> |
13 |
+ |
#include <menes-ext/stack.hpp> |
14 |
|
|
15 |
|
struct IffyCommand : public app::Application |
16 |
|
{ |
85 |
|
ext::String segment; |
86 |
|
bool text(true); |
87 |
|
ios::FormatWriter fout(out); |
88 |
+ |
ext::Stack<ext::String> opens; |
89 |
|
|
90 |
|
while (read(in, segment, text)) if (text) |
91 |
|
{ |
99 |
|
|
100 |
|
if (tag == "br") tag = STANDALONE; |
101 |
|
|
102 |
< |
// XXX: automagically fix |
102 |
> |
switch (tag) |
103 |
> |
{ |
104 |
> |
case OPEN: |
105 |
> |
opens.Push(tag); |
106 |
> |
|
107 |
> |
break; |
108 |
> |
case CLOSE: |
109 |
> |
if (tag != opens.Top()) tag = opens.Top(); |
110 |
> |
|
111 |
> |
opens.Pop(); |
112 |
> |
|
113 |
> |
break; |
114 |
> |
default: |
115 |
> |
break; |
116 |
> |
} |
117 |
|
|
118 |
|
fout << tag << ios::Flush; |
119 |
|
|