Adds wrapper to md4c code, fixes issues with previous commit

This commit is contained in:
Rosia E Evans 2023-09-16 15:21:12 +01:00
parent 6d98202f38
commit d19c822764
31 changed files with 175 additions and 1722 deletions

View file

@ -1,18 +1,36 @@
#include "BlogParser.h"
BlogParser::BlogParser()
{
void BlogParser::saveTextToFile(const MD_CHAR* text, MD_SIZE size, void* userDataVoid)
{
std::string fileUrl = ((UserData*)userDataVoid)->outputFileName;
std::ofstream file;
file.open(fileUrl, std::ios_base::app);
file.write(text, size);
file.close();
text = 0;
}
std::string BlogParser::ParseText(std::string text)
{
std::string result;
std::string currentTag;
// for (char c : text)
// {
// if (c is first)
// }
return "";
int BlogParser::parse(std::string inputFileName, std::string outputFileName)
{
std::ifstream file(inputFileName);
std::stringstream buffer;
buffer << file.rdbuf();
file.close();
std::string text = buffer.str();
int length = text.length();
UserData* userData = new UserData();
userData->outputFileName = outputFileName;
void* userDataVoid = userData;
return md_html(text.c_str(), length, saveTextToFile, userDataVoid, 0, 1);
}