blob: bacf048a6f83a7ab99692e0b93000a8d3eaa5fc0 (
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
#include "lines.hpp"
TexoProducerLines::TexoProducerLines(TexoExporter &exporter):
TexoProducer(exporter), newline(true)
{}
void TexoProducerLines::End()
{
if (!newline) {
exporter.Put('\n');
newline = true;
}
}
void TexoProducerLines::Put(const Texo &piece)
{
if (piece.c == '\n') {
if (!newline) {
exporter.Put(' ');
newline = true;
}
} else {
exporter.Put(piece.c);
newline = false;
}
}
void TexoProducerLines::Put(const TexoParagraph &piece)
{
if (!newline) {
exporter.Put('\n');
newline = true;
}
}
void TexoProducerLines::Put(const TexoQuote &piece)
{
if (!newline) {
exporter.Put('\n');
}
exporter.Put("> ");
newline = false;
}
TexoImporterLines::TexoImporterLines(TexoProducer &producer):
TexoImporter(producer), newline(true), quote(false)
{}
void TexoImporterLines::Put(char c)
{
if (c == '\n') {
if (!newline) {
newline = true;
quote = false;
}
} else if (newline) {
if (c == '>') {
producer.Put(TexoQuote());
quote = true;
} else {
producer.Put(TexoParagraph());
producer.Put(c);
}
newline = false;
} else if (quote) {
if (c != ' ') {
quote = false;
producer.Put(c);
}
} else {
producer.Put(c);
}
}
void TexoImporterLines::Put(const ScriptVariable &str)
{
TexoImporter::Put(str);
}
void TexoImporterLines::Put(FILE *file)
{
TexoImporter::Put(file);
}
|