create modules

This commit is contained in:
2026-01-11 20:59:50 +01:00
parent dd2c6ca810
commit fe02a16416
9 changed files with 0 additions and 14 deletions

30
src/format/format.cpp Normal file
View File

@@ -0,0 +1,30 @@
#include "markdown.hpp"
#include <fstream>
#include <sstream>
#include <string>
static bool replace_once(std::string &str, const std::string &from,
const std::string &to) {
size_t start_pos = str.find(from);
if (start_pos == std::string::npos)
return false;
str.replace(start_pos, from.length(), to);
return true;
}
std::string inject_html_into_template(const std::string &FILE_NAME,
const std::string &TEMPLATE,
const std::string &HTML) {
std::string result;
std::ifstream file(FILE_NAME);
if (!file.is_open()) {
return "";
}
std::ostringstream ss;
ss << file.rdbuf();
result = ss.str();
if (replace_once(result, TEMPLATE, HTML)) {
return result;
}
return "";
}

7
src/format/format.hpp Normal file
View File

@@ -0,0 +1,7 @@
#include <string>
// Change template from file into html
// Return html in string
std::string inject_html_into_template(const std::string &FILE_NAME,
const std::string &TEMPLATE,
const std::string &HTML);