moved all the file operation logic into io module

This commit is contained in:
2026-01-11 22:33:58 +01:00
parent 5fa62d64ee
commit 1668cb8563
10 changed files with 16 additions and 33 deletions

View File

@@ -1,6 +1,4 @@
#include "markdown/markdown.hpp"
#include <fstream>
#include <sstream>
#include <string>
static bool replace_once(std::string &str, const std::string &from,
@@ -11,20 +9,3 @@ static bool replace_once(std::string &str, const std::string &from,
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 "";
}