X-Git-Url: https://harishankar.org/repos/?p=biaweb2.git;a=blobdiff_plain;f=biawebdocument.hpp;h=b79b346c8fa05f273c7316412022d5995aba4704;hp=0c0b74ca33027d64b8043480156ade99a14b8a9c;hb=f56e2150cc79638c890ef23ef82097a4bdffd2ce;hpb=abd61eb094efbfca05e6fe0f1dd34a3e8e7de7a2 diff --git a/biawebdocument.hpp b/biawebdocument.hpp index 0c0b74c..b79b346 100644 --- a/biawebdocument.hpp +++ b/biawebdocument.hpp @@ -136,34 +136,7 @@ namespace biaweb { }; void Document::set_markdown_content (std::string str) { - // discount is a C library and it doesn't work well with C++ streams - // and there seems no way to get the output of any of these functions - // into an std::string. - // the only option seems to be to write the output of the markdown() - // function to a temporary working file and then read it back into C++ - // with the normal std::ifstream and feed it into the std::string - // till a cleaner solution can be found. - MMIOT *doc; - doc = mkd_string (str.c_str(), str.size(), 0); - FILE *f = fopen (".biaweb.tmp", "w"); - markdown (doc, f, 0); - fclose (f); - std::ifstream ftmp (".biaweb.tmp"); - std::string tmpl ( (std::istreambuf_iterator (ftmp)), - (std::istreambuf_iterator ()) - ); - - while (! ftmp.eof ()) - { - std::string line; - ftmp >> line; - tmpl.append (line); - tmpl.append (" "); - } - ftmp.close (); - remove (".biaweb.tmp"); - this->content.append (tmpl); - mkd_cleanup (doc); + this->content = convert_to_markdown (str); } void Document::output_to_html (std::string path)