summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt1
-rw-r--r--src/main.cpp16
2 files changed, 15 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 496b2cd..947ebcd 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -51,6 +51,7 @@ target_include_directories(ahsi PRIVATE
${tomlplusplus_SOURCE_DIR}/include
${json_SOURCE_DIR}/include
${inja_SOURCE_DIR}/include
+ ${cmark_SOURCE_DIR}/include
)
target_link_libraries(ahsi PRIVATE cmark)
diff --git a/src/main.cpp b/src/main.cpp
index bffbe5f..0902b19 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -4,6 +4,7 @@
#include <toml++/toml.hpp>
#include <fstream>
#include <cassert>
+#include <cmark.h>
using namespace std::string_literals;
struct MainConfig {
@@ -18,6 +19,7 @@ struct FrontmatterConfig {
std::string categories;
std::string tags;
bool draft;
+ std::string body;
};
struct Config {
@@ -75,10 +77,19 @@ frontmatter(const std::string& filepath)
std::cerr << "parsing failed: " << err << std::endl;
throw;
}
+ cfg.frontmatter.body = content.substr(second_fence + 3);
}
return cfg;
}
+std::string
+markdown_processing(const std::string& md) {
+ char *raw = cmark_markdown_to_html(md.c_str(), md.size(),0);
+ std::string html(raw);
+ free(raw);
+ return html;
+}
+
int main(int argc, char *argv[]) {
try {
Config my_config = parse_config("config.toml");
@@ -89,11 +100,12 @@ int main(int argc, char *argv[]) {
Config front = frontmatter(argv[1]);
std::cout << "title page: " << front.frontmatter.title << std::endl;
- std::cout << "title date: " << front.frontmatter.title << std::endl;
+ std::cout << "title date: " << front.frontmatter.date << std::endl;
std::cout << "title categories: " << front.frontmatter.categories << std::endl;
std::cout << "title tags: " << front.frontmatter.tags << std::endl;
std::cout << "title draft: " << front.frontmatter.draft << std::endl;
-
+ std::cout << "title body: " << markdown_processing(front.frontmatter.body) << std::endl;
+
} catch (const std::exception& e) {
std::cerr << e.what() << std::endl;
return 1;