// Feeping Creaturism // // Douglas Thrift // // $Id$ #include #include #include "Jargon.hpp" Jargon::Jargon(const cse::String &path, const cse::String &jargon, bool include, const cse::String &relative) : include(include) { args.InsertLast(_B("--stringparam")); args.InsertLast(_B("jargon")); args.InsertLast(jargon); args.InsertLast(_B("--param")); args.InsertLast(("include")); args.InsertLast(_S() << include << _B("()")); if (!relative.IsEmpty()) { args.InsertLast(_B("--stringparam")); args.InsertLast(_B("relative")); args.InsertLast(relative); } args.InsertLast(_B("jargon.xsl")); args.InsertLast(_S() << path << _B("/") << jargon); } ios::PrintWriter &operator<<(ios::PrintWriter &output, const Jargon &jargon) { _S xslt(_B("/usr/local/bin/xsltproc"), jargon.args); if (jargon.include) ios::ReadLine(*xslt.GetReader()); if (jargon.include) { ext::Buffer line; api::Pcre::RegEx matcher(_B("^(.*) xmlns=\"http://www.w3.org/1999/xhtml\"(.*)$")); while (ios::ReadLine(*xslt.GetReader(), line)) { while (api::Pcre::RegEx::Match match = matcher(line)) line = _S() << match[1] << match[2]; output << line << ios::NewLine; } } else ios::ReadToWrite(*xslt.GetReader(), output); return output; }