]> git.lyx.org Git - lyx.git/blobdiff - src/Paragraph.cpp
Make the fake sequence for braces highly unlikely (addressing #6478).
[lyx.git] / src / Paragraph.cpp
index 23d0ca34a4331a8e15023e9d7f7f896f369200ff..7d1ef37f250ce3325a91bcfb668b800527d00345 100644 (file)
@@ -1656,7 +1656,21 @@ void Paragraph::setLabelWidthString(docstring const & s)
 }
 
 
-docstring Paragraph::expandLabel(Layout const & layout,
+docstring Paragraph::expandLabel(Layout const & layout, 
+               BufferParams const & bparams) const
+{ 
+       return expandParagraphLabel(layout, bparams, true); 
+}
+
+
+docstring Paragraph::expandDocBookLabel(Layout const & layout, 
+               BufferParams const & bparams) const
+{
+       return expandParagraphLabel(layout, bparams, false);
+}
+
+
+docstring Paragraph::expandParagraphLabel(Layout const & layout,
                BufferParams const & bparams, bool process_appendix) const
 {
        DocumentClass const & tclass = bparams.documentClass();
@@ -1677,7 +1691,7 @@ docstring Paragraph::expandLabel(Layout const & layout,
                        docstring parent(fmt, i + 1, j - i - 1);
                        docstring label = from_ascii("??");
                        if (tclass.hasLayout(parent))
-                               docstring label = expandLabel(tclass[parent], bparams,
+                               docstring label = expandParagraphLabel(tclass[parent], bparams,
                                                      process_appendix);
                        fmt = docstring(fmt, 0, i) + label 
                                + docstring(fmt, j + 1, docstring::npos);
@@ -1990,8 +2004,10 @@ bool Paragraph::latex(BufferParams const & bparams,
        unsigned int column = 0;
 
        if (body_pos > 0) {
-               os << '[';
-               column += 1;
+               // the optional argument is kept in curly brackets in
+               // case it contains a ']'
+               os << "[{";
+               column += 2;
                basefont = getLabelFont(bparams, outerfont);
        } else {
                basefont = getLayoutFont(bparams, outerfont);
@@ -2037,8 +2053,8 @@ bool Paragraph::latex(BufferParams const & bparams,
                                                runparams);
                                runningChange = Change(Change::UNCHANGED);
 
-                               os << "] ";
-                               column +=2;
+                               os << "}] ";
+                               column +=3;
                        }
                        if (style.isCommand()) {
                                os << '{';
@@ -2231,7 +2247,7 @@ bool Paragraph::latex(BufferParams const & bparams,
 
        // Needed if there is an optional argument but no contents.
        if (body_pos > 0 && body_pos == size()) {
-               os << "]~";
+               os << "}]~";
                return_value = false;
        }