]> git.lyx.org Git - features.git/commitdiff
Fix display of BibTeX entries in the info field of the citation
authorEnrico Forestieri <forenr@lyx.org>
Fri, 12 Jun 2009 14:03:57 +0000 (14:03 +0000)
committerEnrico Forestieri <forenr@lyx.org>
Fri, 12 Jun 2009 14:03:57 +0000 (14:03 +0000)
dialog by only converting text mode latex macros to unicode points.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30070 a592a061-630c-0410-9148-cb99ea01b6c8

src/BiblioInfo.cpp
src/Encoding.cpp
src/Encoding.h

index c68e18ae4c2d00d871428b24427dc8543b9d9e90..92af3b5abae8457e572abcb1ef61f43d28de6377 100644 (file)
@@ -170,7 +170,8 @@ docstring convertLaTeXCommands(docstring const & str)
                        val.insert(2, from_ascii("{"));
                }
                docstring rem;
-               docstring const cnvtd = Encodings::fromLaTeXCommand(val, rem);
+               docstring const cnvtd = Encodings::fromLaTeXCommand(val, rem,
+                                                       Encodings::TEXT_CMD);
                if (!cnvtd.empty()) {
                        // it did, so we'll take that bit and proceed with what's left
                        ret += cnvtd;
index 9283e55fc8e8a1b9d6ea7637604a39376fe82638..6a59fe695c7240bceaaa889261f9577bae961628 100644 (file)
@@ -436,8 +436,11 @@ char_type Encodings::fromLaTeXCommand(docstring const & cmd, bool & combining)
 }
 
 
-docstring Encodings::fromLaTeXCommand(docstring const & cmd, docstring & rem)
+docstring Encodings::fromLaTeXCommand(docstring const & cmd, docstring & rem,
+                                     int cmdtype)
 {
+       bool const mathmode = cmdtype & MATH_CMD;
+       bool const textmode = cmdtype & TEXT_CMD;
        docstring symbols;
        size_t i = 0;
        size_t const cmdend = cmd.size();
@@ -468,8 +471,10 @@ docstring Encodings::fromLaTeXCommand(docstring const & cmd, docstring & rem)
                size_t unicmd_size = 0;
                char_type c = 0;
                for (; it != uniend; ++it) {
-                       docstring const math = it->second.mathcommand;
-                       docstring const text = it->second.textcommand;
+                       docstring const math = mathmode ? it->second.mathcommand
+                                                       : docstring();
+                       docstring const text = textmode ? it->second.textcommand
+                                                       : docstring();
                        size_t cur_size = max(math.size(), text.size());
                        // The current math or text unicode command cannot
                        // match, or we already matched a longer one
index 6a1e76ce9a0648a63c0a7b61a3ab43b06a0a83a1..f955fa966ace9f0585769aca497d2678c2bb24f0 100644 (file)
@@ -233,13 +233,23 @@ public:
         * point and set \p combining to true if it is a combining symbol
         */
        static char_type fromLaTeXCommand(docstring const & cmd, bool & combining);
+       ///
+       enum LatexCmd {
+               ///
+               MATH_CMD = 1,
+               ///
+               TEXT_CMD = 2
+       };
        /**
         * Convert the LaTeX commands in \p cmd and \return a docstring
         * of corresponding unicode points. The conversion stops at the
         * first command which could not be converted, and the remaining
-        * unconverted commands are returned in \p rem
+        * unconverted commands are returned in \p rem.
+        * The \p cmdtype parameter can be used to limit recognized
+        * commands to math or text mode commands only.
         */
-       static docstring fromLaTeXCommand(docstring const & cmd, docstring & rem);
+       static docstring fromLaTeXCommand(docstring const & cmd,
+                       docstring & rem, int cmdtype = MATH_CMD | TEXT_CMD);
        /**
         * Add the preamble snippet needed for the output of \p c to
         * \p features.