Use MarkdownParser on WebsiteBuilder

This commit is contained in:
luca0N! 2022-02-25 18:53:11 -03:00
parent 333f59131a
commit d0c30d4ea7
Signed by: luca0N
GPG Key ID: 2E7B4655CF16D7D6
1 changed files with 6 additions and 4 deletions

View File

@ -32,6 +32,7 @@
#include "ConfigUtils.hxx"
// #include "Blog.h"
#include "Common.hxx"
#include "MarkdownParser.hxx"
std::string blog_relative_path(std::string const &pathPrefix, std::string const &path) {
return path.substr(pathPrefix.length() - 1);
@ -143,7 +144,7 @@ void build_blog_structure(std::string const &path, std::string const &prefix, st
// Now create the article file.
oad /= getFilename(a);
FILE *articleOutput = fopen(oad.string().c_str(), "w");
FILE *articleFile = fopen(a.c_str(), "r");
/*FILE *articleFile = fopen(a.c_str(), "r");
std::string articleContents;
@ -154,14 +155,15 @@ void build_blog_structure(std::string const &path, std::string const &prefix, st
articleContents += buf;
}
fclose(articleFile);
fclose(articleFile);*/
std::string htmlTemplate = get_template(path);
// NOTE: std::regex requires the C++11 standard.
std::regex contentPlaceholder("<!--\\[_SWG: \\$CONTENT\\]-->");
articleContents = std::regex_replace(htmlTemplate, contentPlaceholder, articleContents);
//articleContents = std::regex_replace(htmlTemplate, contentPlaceholder, articleContents);
std::string articleHtml = MarkdownParser::make_html(a);
fputs(articleContents.c_str(), articleOutput);
fputs(articleHtml.c_str(), articleOutput);
fclose(articleOutput);
} catch (std::filesystem::filesystem_error const &e) {