Author: baum
Date: Sat Jan 22 13:00:33 2011
New Revision: 37297
URL: http://www.lyx.org/trac/changeset/37297
Log:
The roundtrip of the math manual produces a compilable document now:
- translate the arguments of \texorpdfstring, so that the floating footnote
code gets enabled
- honor the ForcePlainLayout flag of insets like the Index inset
- remove hardcoded \url support, this is handled by the general Flex inset code
Modified:
lyx-devel/trunk/lib/syntax.default
lyx-devel/trunk/src/tex2lyx/tex2lyx.h
lyx-devel/trunk/src/tex2lyx/text.cpp
Modified: lyx-devel/trunk/lib/syntax.default
==============================================================================
--- lyx-devel/trunk/lib/syntax.default Sat Jan 22 12:48:39 2011 (r37296)
+++ lyx-devel/trunk/lib/syntax.default Sat Jan 22 13:00:33 2011 (r37297)
@@ -358,8 +358,18 @@
%
% Arguments whose text is "translate" will have regular LaTeX in them (as
% opposed to commands with special syntax) which should be translated by
-% reLyX like regular LaTeX. \mbox{} is an obvious example. LyX doesn't
+% tex2lyx like regular LaTeX. \mbox{} is an obvious example. LyX doesn't
% support it, but only the "\mbox{" and the "}" need to be in TeX mode.
+% "translate" should be specified for as many arguments aspossible.
+% Besides the better on-screen display of the contents (a math inset looks
+% better than a formula in ERT), it enables LyX to apply some fixes to LaTeX
+% limitations: For example, footnotes in section headings do not work in
+% LaTeX, but LyX produces preamble code to fix that. Of course this works only
+% for footnote insets and not for footnotes in ERT. Example:
+% \section{title \texorpdfstring{\footnote{foo}}{bar}}
+% is some code that may occur in a .tex file created by LyX. The re-import
+% works only because the first argument of \texorpdfstring is specified as
+% translatable in this file.
\abstractname
\Acrobatmenu{}{} % from the hyperref package
@@ -640,7 +650,7 @@
\tableofcontents
\tabularnewline[]
\telephone{translate}
-\texorpdfstring{}{} % from the hyperref package
+\texorpdfstring{translate}{translate} % from the hyperref package
\textcircled{translate}
\textcolor[]{,,}{translate}
%\textcolor{}{}
Modified: lyx-devel/trunk/src/tex2lyx/tex2lyx.h
==============================================================================
--- lyx-devel/trunk/src/tex2lyx/tex2lyx.h Sat Jan 22 12:48:39 2011
(r37296)
+++ lyx-devel/trunk/src/tex2lyx/tex2lyx.h Sat Jan 22 13:00:33 2011
(r37297)
@@ -63,7 +63,8 @@
* Therefore this may only be used to parse text in insets or table cells.
*/
void parse_text_in_inset(Parser & p, std::ostream & os, unsigned flags,
- bool outer, Context const & context);
+ bool outer, Context const & context,
+ InsetLayout const * layout = 0);
/// in math.cpp
Modified: lyx-devel/trunk/src/tex2lyx/text.cpp
==============================================================================
--- lyx-devel/trunk/src/tex2lyx/text.cpp Sat Jan 22 12:48:39 2011
(r37296)
+++ lyx-devel/trunk/src/tex2lyx/text.cpp Sat Jan 22 13:00:33 2011
(r37297)
@@ -41,10 +41,15 @@
void parse_text_in_inset(Parser & p, ostream & os, unsigned flags, bool outer,
- Context const & context)
+ Context const & context, InsetLayout const * layout)
{
+ bool const forcePlainLayout =
+ layout ? layout->forcePlainLayout() : false;
Context newcontext(true, context.textclass);
- newcontext.font = context.font;
+ if (forcePlainLayout)
+ newcontext.layout = &context.textclass.plainLayout();
+ else
+ newcontext.font = context.font;
parse_text(p, os, flags, outer, newcontext);
newcontext.check_end_layout(os);
}
@@ -52,6 +57,17 @@
namespace {
+void parse_text_in_inset(Parser & p, ostream & os, unsigned flags, bool outer,
+ Context const & context, string const & name)
+{
+ InsetLayout const * layout = 0;
+ DocumentClass::InsetLayouts::const_iterator it =
+ context.textclass.insetLayouts().find(from_ascii(name));
+ if (it != context.textclass.insetLayouts().end())
+ layout = &(it->second);
+ parse_text_in_inset(p, os, flags, outer, context, layout);
+}
+
/// parses a paragraph snippet, useful for example for \\emph{...}
void parse_text_snippet(Parser & p, ostream & os, unsigned flags, bool outer,
Context & context)
@@ -2419,7 +2435,7 @@
context.check_layout(os);
begin_inset(os, "Index\n");
os << "status collapsed\n";
- parse_text_in_inset(p, os, FLAG_ITEM, false, context);
+ parse_text_in_inset(p, os, FLAG_ITEM, false, context,
"Index");
end_inset(os);
}
@@ -2457,14 +2473,6 @@
skip_spaces_braces(p);
}
- else if (t.cs() == "url") {
- context.check_layout(os);
- begin_inset(os, "Flex URL\n");
- os << "status collapsed\n";
- parse_text_in_inset(p, os, FLAG_ITEM, false, context);
- end_inset(os);
- }
-
else if (LYX_FORMAT >= 408 &&
(t.cs() == "textsuperscript" || t.cs() ==
"textsubscript")) {
context.check_layout(os);
@@ -3149,7 +3157,7 @@
begin_inset(os, "Flex ");
os << to_utf8(newinsetlayout->name()) << '\n'
<< "status collapsed\n";
- parse_text_in_inset(p, os, FLAG_ITEM, false, context);
+ parse_text_in_inset(p, os, FLAG_ITEM, false, context,
newinsetlayout);
end_inset(os);
}