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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
#ifndef TEXO_INCLUDED_MARKDOWN
#define TEXO_INCLUDED_MARKDOWN
#include "exporter.hpp"
#include "producer.hpp"
#include "importer.hpp"
class TexoProducerMarkdown: public TexoProducer {
public:
TexoProducerMarkdown(TexoExporter &exporter);
void Put(const Texo &piece);
void Put(const TexoHeader &piece);
void Put(const TexoParagraph &piece);
void Put(const TexoCode &piece);
void Put(const TexoQuote &piece);
void Put(const TexoMono &piece);
void Put(const TexoBold &piece);
void Put(const TexoItalic &piece);
void Put(const TexoUnderline &piece);
void Put(const TexoStrike &piece);
void Put(const TexoImage &piece);
void Put(const TexoLink &piece);
void Put(const TexoLineBreak &piece);
void Put(const TexoHorizontalRule &piece);
private:
bool quoted;
bool newline;
bool header;
bool code;
};
class TexoImporterMarkdown: public TexoImporter {
public:
TexoImporterMarkdown(TexoProducer &producer);
~TexoImporterMarkdown();
void Put(char c);
void Put(const ScriptVariable &str);
void Put(FILE *file);
private:
enum State {
error,
start,
text,
header_text,
quote_text,
quote_newline,
code_text,
code_newline,
code_end,
backslash,
asterisk,
underline,
plus,
tilde,
newline,
rule,
paragraph,
header,
code
} state;
State wrapping_state;
enum Modificator {
italic,
bold,
mono,
underlined,
strike
} mods[5];
int mod_pos;
int header_level_last;
int header_level;
int rule_dash_count;
int code_quote_count;
void Start(char c);
void Text(char c);
void HeaderText(char c);
void QuoteText(char c);
void QuoteNewline(char c);
void CodeText(char c);
void CodeNewline(char c);
void CodeEnd(char c);
void Backslash(char c);
void Asterisk(char c);
void Underline(char c);
void Plus(char c);
void Tilde(char c);
void Newline(char c);
void Rule(char c);
void Paragraph(char c);
void Header(char c);
void Code(char c);
void Backquote();
bool CheckMods(Modificator mod);
bool Mod(Modificator mod);
void BlockState(State st);
void EndBlock();
};
#endif
|