Adds beginnings of BlogPageBuilder and associated classes
This commit is contained in:
parent
65aefe46ce
commit
1506f661c9
114 changed files with 4740 additions and 518 deletions
|
@ -3,34 +3,28 @@
|
|||
|
||||
|
||||
|
||||
void BlogParser::saveTextToFile(const MD_CHAR* text, MD_SIZE size, void* userDataVoid)
|
||||
void BlogParser::writeTextToString(const MD_CHAR* text, MD_SIZE size, void* userDataVoid)
|
||||
{
|
||||
std::string fileUrl = ((UserData*)userDataVoid)->outputFileName;
|
||||
std::string* output = ((UserData*)userDataVoid)->output;
|
||||
|
||||
std::ofstream file;
|
||||
file.open(fileUrl, std::ios_base::app);
|
||||
file.write(text, size);
|
||||
file.close();
|
||||
output->append(text, size);
|
||||
|
||||
text = 0;
|
||||
#ifdef DEBUG
|
||||
printf("Parsed code produced:\n")
|
||||
printf("%.*s", size, text);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
int BlogParser::parse(std::string inputFileName, std::string outputFileName)
|
||||
std::string BlogParser::parse(std::string text)
|
||||
{
|
||||
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;
|
||||
|
||||
userData->output = new std::string();
|
||||
void* userDataVoid = userData;
|
||||
|
||||
return md_html(text.c_str(), length, saveTextToFile, userDataVoid, 0, 1);
|
||||
md_html(text.c_str(), text.length(), writeTextToString, userDataVoid, 0, 1);
|
||||
|
||||
return *(userData->output);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue