mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-13 17:20:55 +00:00
Fix bug 6179 ("|" in index entries not embraced in ERT by lyx2lyx).
* OutputParams.{cpp,h}: - new param inIndexEntry * InsetIndex.cpp (latex): - set param. * InsetErt.cpp (plainText): - output active chars in IndexInsets * lib/lyx2lyx/lyx_1_6.py: - embrace "|" in ERT when converting old index entries to collapsables. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_6_X@31361 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
fb8a55bedc
commit
bd5d83a578
@ -209,7 +209,7 @@ def extract_argument(line):
|
|||||||
return (line[:pos + 1], line[pos + 1:])
|
return (line[:pos + 1], line[pos + 1:])
|
||||||
|
|
||||||
|
|
||||||
def latex2ert(line):
|
def latex2ert(line, isindex):
|
||||||
'''Converts LaTeX commands into ERT. line may well be a multi-line
|
'''Converts LaTeX commands into ERT. line may well be a multi-line
|
||||||
string when it is returned.'''
|
string when it is returned.'''
|
||||||
if not line:
|
if not line:
|
||||||
@ -246,6 +246,9 @@ def latex2ert(line):
|
|||||||
# put all remaining braces in ERT
|
# put all remaining braces in ERT
|
||||||
line = wrap_into_ert(line, '}', '}')
|
line = wrap_into_ert(line, '}', '}')
|
||||||
line = wrap_into_ert(line, '{', '{')
|
line = wrap_into_ert(line, '{', '{')
|
||||||
|
if isindex:
|
||||||
|
# active character that is not available in all font encodings
|
||||||
|
line = wrap_into_ert(line, '|', '|')
|
||||||
retval += line
|
retval += line
|
||||||
return retval
|
return retval
|
||||||
|
|
||||||
@ -257,10 +260,12 @@ unicode_reps = read_unicodesymbols()
|
|||||||
#end up inside ERT. That routine could be modified so that it returned
|
#end up inside ERT. That routine could be modified so that it returned
|
||||||
#a list of lines, and we could then skip ERT bits and only deal with
|
#a list of lines, and we could then skip ERT bits and only deal with
|
||||||
#the other bits.
|
#the other bits.
|
||||||
def latex2lyx(data):
|
def latex2lyx(data, isindex):
|
||||||
'''Takes a string, possibly multi-line, and returns the result of
|
'''Takes a string, possibly multi-line, and returns the result of
|
||||||
converting LaTeX constructs into LyX constructs. Returns a list of
|
converting LaTeX constructs into LyX constructs. Returns a list of
|
||||||
lines, suitable for insertion into document.body.'''
|
lines, suitable for insertion into document.body.
|
||||||
|
The bool isindex specifies whether we are in an index macro (which
|
||||||
|
has some specific active characters that need to be ERTed).'''
|
||||||
|
|
||||||
if not data:
|
if not data:
|
||||||
return [""]
|
return [""]
|
||||||
@ -309,14 +314,14 @@ def latex2lyx(data):
|
|||||||
g = m.group(3)
|
g = m.group(3)
|
||||||
if s:
|
if s:
|
||||||
# this is non-math!
|
# this is non-math!
|
||||||
s = latex2ert(s)
|
s = latex2ert(s, isindex)
|
||||||
subst = s.split('\n')
|
subst = s.split('\n')
|
||||||
retval += subst
|
retval += subst
|
||||||
retval.append("\\begin_inset Formula " + f)
|
retval.append("\\begin_inset Formula " + f)
|
||||||
retval.append("\\end_inset")
|
retval.append("\\end_inset")
|
||||||
m = mathre.match(g)
|
m = mathre.match(g)
|
||||||
# Handle whatever is left, which is just text
|
# Handle whatever is left, which is just text
|
||||||
g = latex2ert(g)
|
g = latex2ert(g, isindex)
|
||||||
subst = g.split('\n')
|
subst = g.split('\n')
|
||||||
retval += subst
|
retval += subst
|
||||||
return retval
|
return retval
|
||||||
@ -1097,7 +1102,7 @@ def convert_latexcommand_index(document):
|
|||||||
linelist = [""]
|
linelist = [""]
|
||||||
else:
|
else:
|
||||||
fullcontent = m.group(1)
|
fullcontent = m.group(1)
|
||||||
linelist = latex2lyx(fullcontent)
|
linelist = latex2lyx(fullcontent, True)
|
||||||
#document.warning(fullcontent)
|
#document.warning(fullcontent)
|
||||||
|
|
||||||
linelist = ["\\begin_inset Index", "status collapsed", "\\begin_layout Standard", ""] + \
|
linelist = ["\\begin_inset Index", "status collapsed", "\\begin_layout Standard", ""] + \
|
||||||
@ -2177,7 +2182,7 @@ def convert_subfig(document):
|
|||||||
addedLines -= 1
|
addedLines -= 1
|
||||||
subst = ['\\begin_inset Float figure', 'wide false', 'sideways false',
|
subst = ['\\begin_inset Float figure', 'wide false', 'sideways false',
|
||||||
'status open', '', '\\begin_layout Plain Layout', '\\begin_inset Caption',
|
'status open', '', '\\begin_layout Plain Layout', '\\begin_inset Caption',
|
||||||
'', '\\begin_layout Plain Layout'] + latex2lyx(caption) + \
|
'', '\\begin_layout Plain Layout'] + latex2lyx(caption, False) + \
|
||||||
[ '\\end_layout', '', '\\end_inset', '',
|
[ '\\end_layout', '', '\\end_inset', '',
|
||||||
'\\end_layout', '', '\\begin_layout Plain Layout']
|
'\\end_layout', '', '\\begin_layout Plain Layout']
|
||||||
document.body[i : i] = subst
|
document.body[i : i] = subst
|
||||||
|
@ -24,7 +24,8 @@ OutputParams::OutputParams(Encoding const * enc)
|
|||||||
use_japanese(false), linelen(0), depth(0),
|
use_japanese(false), linelen(0), depth(0),
|
||||||
exportdata(new ExportData),
|
exportdata(new ExportData),
|
||||||
inComment(false), inTableCell(NO), inFloat(NONFLOAT),
|
inComment(false), inTableCell(NO), inFloat(NONFLOAT),
|
||||||
inDeletedInset(0), changeOfDeletedInset(Change::UNCHANGED),
|
inIndexEntry(false), inDeletedInset(0),
|
||||||
|
changeOfDeletedInset(Change::UNCHANGED),
|
||||||
par_begin(0), par_end(0), isLastPar(false),
|
par_begin(0), par_end(0), isLastPar(false),
|
||||||
dryrun(false), verbatim(false)
|
dryrun(false), verbatim(false)
|
||||||
{
|
{
|
||||||
|
@ -147,6 +147,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
Float inFloat;
|
Float inFloat;
|
||||||
|
|
||||||
|
/** Whether we are inside an index inset.
|
||||||
|
* ERT needs to know this, due to the active chars.
|
||||||
|
*/
|
||||||
|
bool inIndexEntry;
|
||||||
|
|
||||||
/** Whether we are inside an inset that is logically deleted.
|
/** Whether we are inside an inset that is logically deleted.
|
||||||
* A value > 0 indicates a deleted inset.
|
* A value > 0 indicates a deleted inset.
|
||||||
*/
|
*/
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include "Lexer.h"
|
#include "Lexer.h"
|
||||||
#include "LyXAction.h"
|
#include "LyXAction.h"
|
||||||
#include "MetricsInfo.h"
|
#include "MetricsInfo.h"
|
||||||
|
#include "OutputParams.h"
|
||||||
#include "ParagraphParameters.h"
|
#include "ParagraphParameters.h"
|
||||||
#include "Paragraph.h"
|
#include "Paragraph.h"
|
||||||
#include "TextClass.h"
|
#include "TextClass.h"
|
||||||
@ -75,9 +76,33 @@ int InsetERT::latex(odocstream & os, OutputParams const & op) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int InsetERT::plaintext(odocstream &, OutputParams const &) const
|
int InsetERT::plaintext(odocstream & os, OutputParams const & rp) const
|
||||||
{
|
{
|
||||||
return 0; // do not output TeX code
|
if (!rp.inIndexEntry)
|
||||||
|
// do not output TeX code
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
ParagraphList::const_iterator par = paragraphs().begin();
|
||||||
|
ParagraphList::const_iterator end = paragraphs().end();
|
||||||
|
|
||||||
|
while (par != end) {
|
||||||
|
pos_type siz = par->size();
|
||||||
|
for (pos_type i = 0; i < siz; ++i) {
|
||||||
|
char_type const c = par->getChar(i);
|
||||||
|
// output the active characters
|
||||||
|
switch (c) {
|
||||||
|
case '|':
|
||||||
|
case '!':
|
||||||
|
case '@':
|
||||||
|
os.put(c);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
++par;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -48,8 +48,10 @@ InsetIndex::InsetIndex(Buffer const & buf)
|
|||||||
|
|
||||||
|
|
||||||
int InsetIndex::latex(odocstream & os,
|
int InsetIndex::latex(odocstream & os,
|
||||||
OutputParams const & runparams) const
|
OutputParams const & runparams_in) const
|
||||||
{
|
{
|
||||||
|
OutputParams runparams(runparams_in);
|
||||||
|
runparams.inIndexEntry = true;
|
||||||
os << "\\index";
|
os << "\\index";
|
||||||
os << '{';
|
os << '{';
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
@ -69,8 +69,12 @@ What's new
|
|||||||
|
|
||||||
- Do not unnecessarily enquote brackets in the LaTeX output (bug 5988).
|
- Do not unnecessarily enquote brackets in the LaTeX output (bug 5988).
|
||||||
|
|
||||||
- Remove the last '//' in the output of multiline equations. This caused
|
- Remove the last '\\' in the output of multiline equations. This caused
|
||||||
labels to appear double (bug 2969).
|
labels to appear double (bug 2969).
|
||||||
|
|
||||||
|
- Put "|" characters in index entries in ERT when converting old documents
|
||||||
|
to LyX 1.6.x format, to assure the character is treated verbatim
|
||||||
|
(bug 6179).
|
||||||
|
|
||||||
|
|
||||||
* USER INTERFACE
|
* USER INTERFACE
|
||||||
|
Loading…
Reference in New Issue
Block a user