blob: db5c63bc5118bb025b450fd1ab2372120a98762c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
#include "plain.hpp"
TexoPlainImporter::TexoPlainImporter(TexoProducer &producer):
TexoImporter(producer), first(true), space(0), newline(false)
{}
void TexoPlainImporter::Put(const char c)
{
if (first) {
first = false;
producer.Put(Texo(Texo::paragraph_begin));
}
if (c == ' ') {
++space;
} else if (c == '\n') {
if (newline) {
newline = false;
producer.Put(Texo(Texo::paragraph_end));
producer.Put(Texo(Texo::paragraph_begin));
} else {
newline = true;
}
} else if (!c) {
producer.Put(Texo(Texo::paragraph_end));
} else {
if (newline) {
newline = false;
if (space) {
space = 0;
producer.Put(Texo(Texo::newline));
} else {
producer.Put(Texo(' '));
}
}
while (space) {
producer.Put(Texo(' '));
--space;
}
producer.Put(Texo(c));
}
}
|