diff options
Diffstat (limited to 'src/main.cpp')
| -rw-r--r-- | src/main.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
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; |
