diff options
| author | Pinapelz <yukais@pinapelz.com> | 2025-10-28 01:46:22 -0700 |
|---|---|---|
| committer | Pinapelz <yukais@pinapelz.com> | 2025-10-28 01:46:22 -0700 |
| commit | 9c00965a149b2f9697f5c07a390cf2b0bc675d4d (patch) | |
| tree | a3a8825f4e0d0fcf15a3d4d1efc226629f888c0f /include/markdown_translator.hpp | |
| parent | 84459bd663f62c2d1e83c7f47aa8bc96eb6543e2 (diff) | |
create helper functions for creating header and footer
Diffstat (limited to 'include/markdown_translator.hpp')
| -rw-r--r-- | include/markdown_translator.hpp | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/include/markdown_translator.hpp b/include/markdown_translator.hpp index 6a3b91f..6eb32f8 100644 --- a/include/markdown_translator.hpp +++ b/include/markdown_translator.hpp @@ -36,7 +36,41 @@ private: void generateSideBar(std::stringstream& output, const std::vector<std::string>& headers); std::string createAnchorId(const std::string& text); // Utility functions - std::string getCurrentDateTime(); + + std::string getCurrentDateTime() { + std::time_t now = std::time(nullptr); + std::tm* localTime = std::localtime(&now); + + char buffer[80]; + std::strftime(buffer, sizeof(buffer), "%Y-%m-%d %H:%M:%S", localTime); + + return std::string(buffer); + } + + // HTML builders + std::string buildHTMLHeader(const std::string& title, const std::string& cssPath){ + return R"(<!DOCTYPE html> + <html lang="en"> + <head> + <meta charset="UTF-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + <title>)" + title + R"(</title> + <link rel="stylesheet" href=")" + cssPath + R"("> + </head> + <body> + )"; + } + + std::string buildHTMLFooter(){ + return R"( <div class="article-meta"> + <p>Last updated: )" + getCurrentDateTime() + R"(</p> + </div> + </div> + </div> + </body> + </html> + )"; + } // Member variables std::string title; |
