btool
A parser/converter/transpiler for .bib files
HtmlGenerator.hpp
Go to the documentation of this file.
1 #ifndef BIBPARSER_SRC_HTMLGENERATOR_HPP_
2 #define BIBPARSER_SRC_HTMLGENERATOR_HPP_
3 
4 #include <AbstractGenerator.hpp>
5 #include <unordered_map>
6 #include <ctml.hpp>
7 
12 
16  enum class HtmlTag {
17  TABLE,
18  TABLE_BODY,
21  TABLE_ROW,
22  LINK,
23  SCRIPT,
24  META,
25  TITLE,
26  H1,
27  H5,
28  DIV,
29  BUTTON
30  };
31 
32  [[noreturn]] auto fail(const std::string &message, const std::string &type) -> void override;
33 
34  auto write() -> std::string override;
35 
36  auto fillContainer(
37  CTML::Node &parent
38  ) const noexcept -> void;
39 
40  static auto appendCard(
41  CTML::Node &parent,
42  const BibElement &element
43  ) noexcept -> void;
44 
45  static auto appendTable(
46  CTML::Node &parent,
47  const BibElement &element
48  ) noexcept -> void;
49 
50  explicit HtmlGenerator(const std::vector<BibElement> &elements);
51 };
52 
53 template<HtmlGenerator::HtmlTag> inline char const * const name = "Invalid HTML-Tag";
54 template<> inline char const * const name<HtmlGenerator::HtmlTag::TABLE> = "table";
55 template<> inline char const * const name<HtmlGenerator::HtmlTag::TABLE_BODY> = "tbody";
56 template<> inline char const * const name<HtmlGenerator::HtmlTag::TABLE_HEADING> = "th";
57 template<> inline char const * const name<HtmlGenerator::HtmlTag::TABLE_ENTRY> = "td";
58 template<> inline char const * const name<HtmlGenerator::HtmlTag::TABLE_ROW> = "tr";
59 template<> inline char const * const name<HtmlGenerator::HtmlTag::LINK> = "link";
60 template<> inline char const * const name<HtmlGenerator::HtmlTag::SCRIPT> = "script";
61 template<> inline char const * const name<HtmlGenerator::HtmlTag::META> = "meta";
62 template<> inline char const * const name<HtmlGenerator::HtmlTag::TITLE> = "title";
63 template<> inline char const * const name<HtmlGenerator::HtmlTag::H1> = "h1";
64 template<> inline char const * const name<HtmlGenerator::HtmlTag::H5> = "h5";
65 template<> inline char const * const name<HtmlGenerator::HtmlTag::DIV> = "div";
66 template<> inline char const * const name<HtmlGenerator::HtmlTag::BUTTON> = "button";
67 
68 #endif
AbstractGenerator
Definition: AbstractGenerator.hpp:14
HtmlGenerator::appendTable
static auto appendTable(CTML::Node &parent, const BibElement &element) noexcept -> void
Definition: HtmlGenerator.cpp:145
HtmlGenerator::HtmlTag::TITLE
@ TITLE
HtmlGenerator::HtmlTag::LINK
@ LINK
HtmlGenerator::HtmlTag::BUTTON
@ BUTTON
HtmlGenerator::fail
auto fail(const std::string &message, const std::string &type) -> void override
Definition: HtmlGenerator.cpp:8
HtmlGenerator::HtmlTag::TABLE_HEADING
@ TABLE_HEADING
AbstractGenerator.hpp
HtmlGenerator::fillContainer
auto fillContainer(CTML::Node &parent) const noexcept -> void
Definition: HtmlGenerator.cpp:84
HtmlGenerator::HtmlTag::META
@ META
HtmlGenerator::write
auto write() -> std::string override
Definition: HtmlGenerator.cpp:17
HtmlGenerator::HtmlTag::SCRIPT
@ SCRIPT
name
char const *const name
Definition: HtmlGenerator.hpp:53
HtmlGenerator
Definition: HtmlGenerator.hpp:11
HtmlGenerator::HtmlTag::H5
@ H5
HtmlGenerator::HtmlTag::H1
@ H1
HtmlGenerator::HtmlTag
HtmlTag
Definition: HtmlGenerator.hpp:16
HtmlGenerator::HtmlTag::TABLE_ROW
@ TABLE_ROW
HtmlGenerator::HtmlTag::TABLE_ENTRY
@ TABLE_ENTRY
HtmlGenerator::HtmlGenerator
HtmlGenerator(const std::vector< BibElement > &elements)
Definition: HtmlGenerator.cpp:78
HtmlGenerator::appendCard
static auto appendCard(CTML::Node &parent, const BibElement &element) noexcept -> void
Definition: HtmlGenerator.cpp:99
HtmlGenerator::HtmlTag::TABLE
@ TABLE
HtmlGenerator::HtmlTag::DIV
@ DIV
HtmlGenerator::HtmlTag::TABLE_BODY
@ TABLE_BODY
AbstractGenerator::elements
std::vector< BibElement > elements
Elements to write.
Definition: AbstractGenerator.hpp:16
BibElement
bib-element-Container
Definition: BibElement.hpp:14