Use MarkdownParser on WebsiteBuilder
This commit is contained in:
parent
333f59131a
commit
d0c30d4ea7
|
@ -32,6 +32,7 @@
|
||||||
#include "ConfigUtils.hxx"
|
#include "ConfigUtils.hxx"
|
||||||
// #include "Blog.h"
|
// #include "Blog.h"
|
||||||
#include "Common.hxx"
|
#include "Common.hxx"
|
||||||
|
#include "MarkdownParser.hxx"
|
||||||
|
|
||||||
std::string blog_relative_path(std::string const &pathPrefix, std::string const &path) {
|
std::string blog_relative_path(std::string const &pathPrefix, std::string const &path) {
|
||||||
return path.substr(pathPrefix.length() - 1);
|
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.
|
// Now create the article file.
|
||||||
oad /= getFilename(a);
|
oad /= getFilename(a);
|
||||||
FILE *articleOutput = fopen(oad.string().c_str(), "w");
|
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;
|
std::string articleContents;
|
||||||
|
|
||||||
|
@ -154,14 +155,15 @@ void build_blog_structure(std::string const &path, std::string const &prefix, st
|
||||||
articleContents += buf;
|
articleContents += buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(articleFile);
|
fclose(articleFile);*/
|
||||||
|
|
||||||
std::string htmlTemplate = get_template(path);
|
std::string htmlTemplate = get_template(path);
|
||||||
// NOTE: std::regex requires the C++11 standard.
|
// NOTE: std::regex requires the C++11 standard.
|
||||||
std::regex contentPlaceholder("<!--\\[_SWG: \\$CONTENT\\]-->");
|
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);
|
fclose(articleOutput);
|
||||||
} catch (std::filesystem::filesystem_error const &e) {
|
} catch (std::filesystem::filesystem_error const &e) {
|
||||||
|
|
Loading…
Reference in New Issue