From 7bf20758b5373ea6637a8dd58242316edf7cae5c Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=BCrgen=20Spitzm=C3=BCller?= Date: Thu, 8 May 2008 09:43:27 +0000 Subject: [PATCH] fix bug 4837. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@24682 a592a061-630c-0410-9148-cb99ea01b6c8 --- lib/lyx2lyx/lyx_1_6.py | 2 +- src/insets/InsetIndex.cpp | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/lyx2lyx/lyx_1_6.py b/lib/lyx2lyx/lyx_1_6.py index c8bc593777..f96d9d8696 100644 --- a/lib/lyx2lyx/lyx_1_6.py +++ b/lib/lyx2lyx/lyx_1_6.py @@ -788,7 +788,7 @@ def convert_latexcommand_index(document): document.body.insert(i + 4, "\\end_inset") i += 2 # Generic, \\ -> \backslash: - g = wrap_into_ert(g, r'\\', '\\backslash{}') + g = wrap_into_ert(g, r'\\', '\\backslash') g = wrap_into_ert(g, '{', '{') g = wrap_into_ert(g, '}', '}') document.body.insert(i + 3, g) diff --git a/src/insets/InsetIndex.cpp b/src/insets/InsetIndex.cpp index 76d31ca26e..da82e7e64a 100644 --- a/src/insets/InsetIndex.cpp +++ b/src/insets/InsetIndex.cpp @@ -49,17 +49,26 @@ int InsetIndex::latex(odocstream & os, os << "\\index"; os << '{'; odocstringstream ods; - InsetText::latex(ods, runparams); + int i = InsetText::latex(ods, runparams); + bool sorted = false; // correctly sort macros and formatted strings // if we do find a command, prepend a plain text // version of the content to get sorting right, // e.g. \index{LyX@\LyX}, \index{text@\textbf{text}} // Don't do that if the user entered '@' himself, though. if (contains(ods.str(), '\\') && !contains(ods.str(), '@')) { - if (InsetText::plaintext(os, runparams) > 0) + if (InsetText::plaintext(os, runparams) > 0) { os << '@'; + sorted = true; + } } - int i = InsetText::latex(os, runparams); + // if a hierarchy tag '!' is used, ommit this in the post-@ part. + if (sorted && contains(ods.str(), '!')) { + string dummy; + // FIXME unicode + os << from_utf8(rsplit(to_utf8(ods.str()), dummy, '!')); + } else + i = InsetText::latex(os, runparams); os << '}'; return i; } -- 2.39.2