+
+void sgml::openTag(odocstream & os, string const & name, string const & attribute)
+{
+ // FIXME UNICODE
+ // This should be fixed in layout files later.
+ string param = subst(attribute, "<", "\"");
+ param = subst(param, ">", "\"");
+
+ if (!name.empty() && name != "!-- --") {
+ os << '<' << from_ascii(name);
+ if (!param.empty())
+ os << ' ' << from_ascii(param);
+ os << '>';
+ }
+}
+
+
+void sgml::closeTag(odocstream & os, string const & name)
+{
+ if (!name.empty() && name != "!-- --")
+ os << "</" << from_ascii(name) << '>';
+}
+
+
+void sgml::openTag(Buffer const & buf, odocstream & os,
+ OutputParams const & runparams, Paragraph const & par)
+{
+ LyXLayout_ptr const & style = par.layout();
+ string const & name = style->latexname();
+ string param = style->latexparam();
+ Counters & counters = buf.params().getLyXTextClass().counters();
+
+ string id = par.getID(buf, runparams);
+
+ string attribute;
+ if(!id.empty()) {
+ if (param.find('#') != string::npos) {
+ string::size_type pos = param.find("id=<");
+ string::size_type end = param.find(">");
+ if( pos != string::npos && end != string::npos)
+ param.erase(pos, end-pos + 1);
+ }
+ attribute = id + ' ' + param;
+ } else {
+ if (param.find('#') != string::npos) {
+ // FIXME UNICODE
+ if(!style->counter.empty())
+ counters.step(style->counter);
+ else
+ counters.step(from_ascii(name));
+ int i = counters.value(from_ascii(name));
+ attribute = subst(param, "#", convert<string>(i));
+ } else {
+ attribute = param;
+ }
+ }
+ openTag(os, name, attribute);
+}
+
+
+void sgml::closeTag(odocstream & os, Paragraph const & par)
+{
+ LyXLayout_ptr const & style = par.layout();
+ closeTag(os, style->latexname());
+}
+
+
+} // namespace lyx