summaryrefslogtreecommitdiff
path: root/src/html.cpp
diff options
context:
space:
mode:
authorAleksey Veresov <aleksey@veresov.pro>2019-09-27 18:35:47 +0300
committerAleksey Veresov <aleksey@veresov.pro>2019-09-27 18:35:47 +0300
commit5dd4f05089608a66c435d6be36d4bc93dc425986 (patch)
treead3c7961983ffed2e225a1c6ae2f87df2664da89 /src/html.cpp
parent2eae362fd3f50325067fa3d7e13db6882df80e76 (diff)
downloadtexo-5dd4f05089608a66c435d6be36d4bc93dc425986.tar
texo-5dd4f05089608a66c435d6be36d4bc93dc425986.tar.xz
texo-5dd4f05089608a66c435d6be36d4bc93dc425986.zip
Prework for HTML.
Diffstat (limited to 'src/html.cpp')
-rw-r--r--src/html.cpp48
1 files changed, 43 insertions, 5 deletions
diff --git a/src/html.cpp b/src/html.cpp
index 22209f5..c9e3cde 100644
--- a/src/html.cpp
+++ b/src/html.cpp
@@ -8,20 +8,58 @@ TexoHTMLProducer::TexoHTMLProducer(TexoExporter &exporter):
void TexoHTMLProducer::Put(const Texo &piece)
{
switch (piece.type) {
- case Texo::character: exporter.Put(piece.c); break;
- case Texo::paragraph_begin: exporter.PutStr("<p>"); break;
- case Texo::paragraph_end: exporter.PutStr("</p>"); break;
- case Texo::newline: exporter.PutStr("<br/>");
+ case Texo::character: exporter.Put(piece.c); break;
+ case Texo::paragraph_begin: exporter.PutStr("<p>"); break;
+ case Texo::paragraph_end: exporter.PutStr("</p>"); break;
+ case Texo::newline: exporter.PutStr("<br/>"); break;
+ case Texo::bold_begin: exporter.PutStr("<b>"); break;
+ case Texo::bold_end: exporter.PutStr("</b>"); break;
+ case Texo::italic_begin: exporter.PutStr("<i>"); break;
+ case Texo::italic_end: exporter.PutStr("</i>"); break;
+ case Texo::strike_begin: exporter.PutStr("<del>"); break;
+ case Texo::strike_end: exporter.PutStr("</del>"); break;
+ case Texo::underline_begin: exporter.PutStr("<ins>"); break;
+ case Texo::underline_end: exporter.PutStr("</ins>"); break;
+ case Texo::link_begin: BeginLink(piece); break;
+ case Texo::link_end: exporter.PutStr("</a>"); break;
+ case Texo::image: Image(piece); break;
default: break;
}
}
+void TexoHTMLProducer::BeginLink(const Texo &piece)
+{
+ exporter.PutStr("<a");
+ if (piece.link_url) {
+ exporter.PutStr(" href='");
+ exporter.PutStr(piece.link_url);
+ exporter.Put('\'');
+ }
+ exporter.Put('>');
+}
+
+void TexoHTMLProducer::Image(const Texo &piece)
+{
+ exporter.PutStr("<img");
+ if (piece.image_src) {
+ exporter.PutStr(" src='");
+ exporter.PutStr(piece.image_src);
+ exporter.Put('\'');
+ }
+ if (piece.image_alt) {
+ exporter.PutStr(" alt='");
+ exporter.PutStr(piece.image_alt);
+ exporter.Put('\'');
+ }
+ exporter.PutStr("/>");
+}
+
TexoHTMLImporter::TexoHTMLImporter(TexoProducer &producer):
TexoImporter(producer)
{}
void TexoHTMLImporter::Put(const char c)
-{
+{ // TODO by automata
producer.Put(Texo(c));
}