+ // convert markdown
+
+ std::string convert_to_markdown (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<char> (ftmp)),
+ (std::istreambuf_iterator<char> ())
+ );
+ ftmp.close ();
+ mkd_cleanup (doc);
+ remove (".biaweb.tmp");
+ return tmpl;
+ }
+