#include "buffer.h"
#include "bufferparams.h"
#include "counters.h"
+#include "debug.h"
#include "lyxtext.h"
#include "paragraph.h"
#include "paragraph_funcs.h"
if (!style->latexparam().empty()) {
counters.step("para");
int i = counters.value("para");
- ls = "id=\"" + subst(style->latexparam(), "#", tostr(i)) + '"';
+ ls = subst(style->latexparam(), "#", tostr(i));
}
sgml::openTag(os, depth + command_depth,
false, style->latexname(), ls);
command_stack.push_back(string());
command_stack[command_depth] = command_name;
- if (!style->latexparam().empty()) {
+ if (style->latexparam().find('#') != string::npos) {
counters.step(style->counter);
}
// treat label as a special case for
// This is a hack while paragraphs can't have
// attributes, like id in this case.
if (par->size() && par->isInset(0)) {
- InsetOld * inset = par->getInset(0);
- InsetOld::Code lyx_code = inset->lyxCode();
- if (lyx_code == InsetOld::LABEL_CODE) {
+ InsetBase * inset = par->getInset(0);
+ if (inset->lyxCode() == InsetOld::LABEL_CODE) {
command_name += " id=\"";
command_name += (static_cast<InsetCommand *>(inset))->getContents();
command_name += '"';
labelid = true;
}
- } else {
- if (!style->latexparam().empty()) {
- ls = expandLabel(buf.params().getLyXTextClass(), style, false);
- ls = "id=\"" + subst(style->latexparam(), "#", ls) + '"';
- }
+ }
+ if (!labelid && !style->latexparam().empty()) {
+ ls = style->latexparam();
+ if (ls.find('#') != string::npos) {
+ string el = expandLabel(buf.params().getLyXTextClass(),
+ style, false);
+ ls = subst(ls, "#", el);
+ }
}
sgml::openTag(os, depth + command_depth, false, command_name, ls);