From 2c12c0652d2b8c8440e1e908f004826840ed14ab Mon Sep 17 00:00:00 2001 From: Aleksey Veresov Date: Fri, 18 Oct 2019 17:33:06 +0300 Subject: [texo] Semi-working. --- src/html.cpp | 173 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 173 insertions(+) (limited to 'src/html.cpp') diff --git a/src/html.cpp b/src/html.cpp index 290891e..5155661 100644 --- a/src/html.cpp +++ b/src/html.cpp @@ -1 +1,174 @@ #include "html.hpp" + + +TexoProducerHTML::TexoProducerHTML(TexoExporter &exporter): + TexoProducer(exporter) +{} + +void TexoProducerHTML::Put(const Texo &piece) +{ + switch (piece.c) { + case '<': exporter.Put("<"); break; + case '>': exporter.Put(">"); break; + default: exporter.Put(piece.c); break; + } +} + +void TexoProducerHTML::Put(const TexoHeader &piece) +{ + exporter.Put('<'); + if (piece.closing) { + exporter.Put('/'); + } + if (piece.level <= 1) { + exporter.Put("h6>"); + } else if (piece.level == 2) { + exporter.Put("h5>"); + } else if (piece.level == 3) { + exporter.Put("h4>"); + } else if (piece.level == 4) { + exporter.Put("h3>"); + } else if (piece.level == 5) { + exporter.Put("h2>"); + } else { + exporter.Put("h1>"); + } +} + +void TexoProducerHTML::Put(const TexoParagraph &piece) +{ + if (piece.closing) { + exporter.Put("

"); + } else { + exporter.Put("

"); + } +} + +void TexoProducerHTML::Put(const TexoCode &piece) +{ + if (piece.closing) { + exporter.Put(""); + } else { + exporter.Put("

");
+    }
+}
+
+void TexoProducerHTML::Put(const TexoQuote &piece)
+{
+    if (piece.closing) {
+        exporter.Put("

"); + } else { + exporter.Put("

"); + } +} + +void TexoProducerHTML::Put(const TexoMono &piece) +{ + if (piece.closing) { + exporter.Put(""); + } else { + exporter.Put(""); + } +} + +void TexoProducerHTML::Put(const TexoBold &piece) +{ + if (piece.closing) { + exporter.Put(""); + } else { + exporter.Put(""); + } +} + +void TexoProducerHTML::Put(const TexoItalic &piece) +{ + if (piece.closing) { + exporter.Put(""); + } else { + exporter.Put(""); + } +} + +void TexoProducerHTML::Put(const TexoUnderline &piece) +{ + if (piece.closing) { + exporter.Put(""); + } else { + exporter.Put(""); + } +} + +void TexoProducerHTML::Put(const TexoStrike &piece) +{ + if (piece.closing) { + exporter.Put(""); + } else { + exporter.Put(""); + } +} + +void TexoProducerHTML::Put(const TexoImage &piece) +{ + if (piece.path != "") { + bool link = piece.link != ""; + bool title = piece.title != ""; + if (link) { + exporter.Put(""); + } + exporter.Put("");
+            exporter.Put(piece.alt);
+        }
+        if (title) {
+            exporter.Put(""); + if (link) { + exporter.Put(""); + } + } +} + +void TexoProducerHTML::Put(const TexoLink &piece) +{ + if (piece.text != "" && piece.link != "") { + exporter.Put(""); + exporter.Put(piece.text); + exporter.Put(""); + } +} + +void TexoProducerHTML::Put(const TexoLineBreak &piece) +{ + exporter.Put("
"); +} + +void TexoProducerHTML::Put(const TexoHorizontalRule &piece) +{ + exporter.Put("


"); +} + + +TexoImporterHTML::TexoImporterHTML(TexoProducer &producer): + TexoImporter(producer) +{} + +void TexoImporterHTML::Put(char c) +{ // TODO + producer.Put(Texo(c)); +} -- cgit v1.2.3