]> git.lyx.org Git - features.git/commitdiff
update fileformat and fix output of paperfontsize
authorGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Sun, 6 Feb 2005 09:32:52 +0000 (09:32 +0000)
committerGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Sun, 6 Feb 2005 09:32:52 +0000 (09:32 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9593 a592a061-630c-0410-9148-cb99ea01b6c8

src/tex2lyx/ChangeLog
src/tex2lyx/context.C
src/tex2lyx/preamble.C
src/tex2lyx/text.C

index a87da6af1fa713d55e4597b1931c8466d22f9f2e..c113b3de3de3936f3eb019b548632edb7c7e41d1 100644 (file)
@@ -1,3 +1,14 @@
+2005-02-05  Georg Baum  <Georg.Baum@post.rwth-aachen.de>
+
+       * context.C (begin_deeper, end_deeper): adjust output to LyX
+       * preamble.C (h_output_changes): new
+       * preamble.C (end_preamble): output paperfontsize without unit
+       * preamble.C (end_preamble): change file format from 237 to 241
+       * text.C (parse_environment, parse_text): adjust paragraph parameters
+       to new file format
+       * text.C (handle_ert, handle_comment): adjust newlines to new file
+       format
+
 2005-02-03  Angus Leeming  <leeming@lyx.org>
 
        * Makefile.am: make -lz conditional on USE_COMPRESSION.
index b980b3e695fcbb82ba2b07b65076eea70976e11a..882637d4800b5584b98072023b66de76254c6f1c 100644 (file)
@@ -36,13 +36,13 @@ void end_layout(ostream & os)
 
 void begin_deeper(ostream & os)
 {
-       os << "\n\\begin_deeper\n";
+       os << "\n\\begin_deeper";
 }
 
 
 void end_deeper(ostream & os)
 {
-       os << "\n\\end_deeper\n";
+       os << "\n\\end_deeper";
 }
 
 }
@@ -73,7 +73,10 @@ void Context::check_layout(ostream & os)
                // are we in a list-like environment?
                if (layout->isEnvironment()
                    && layout->latextype != LATEX_ENVIRONMENT) {
+                       // A list-like environment
                        if (has_item) {
+                               // a new item. If we had a standard
+                               // paragraph before, we have to end it.
                                if (deeper_paragraph) {
                                        end_deeper(os);
                                        deeper_paragraph = false;
@@ -94,6 +97,7 @@ void Context::check_layout(ostream & os)
                                deeper_paragraph = true;
                        }
                } else {
+                       // No list-like environment
                        begin_layout(os, layout);
                        need_layout=false;
                        need_end_layout = true;
@@ -119,6 +123,8 @@ void Context::check_end_layout(ostream & os)
 void Context::check_deeper(ostream & os)
 {
        if (parent_layout->isEnvironment()) {
+               // We start a nested environment.
+               // We need to increase the depth.
                if (need_end_deeper) {
                        // no need to have \end_deeper \begin_deeper
                        need_end_deeper = false;
index 449d9b9c26460068709a68257a8fae4d431b654c..37ed7b06220c7c6fda506b8029ac88e94cbcc208 100644 (file)
@@ -85,6 +85,7 @@ string h_papercolumns            = "1";
 string h_papersides              = string();
 string h_paperpagestyle          = "default";
 string h_tracking_changes        = "false";
+string h_output_changes          = "false";
 
 
 void handle_opt(vector<string> & opts, char const * const * what, string & target)
@@ -225,7 +226,7 @@ void handle_package(string const & name, string const & opts)
 void end_preamble(ostream & os, LyXTextClass const & /*textclass*/)
 {
        os << "#LyX file created by  tex2lyx 0.1.2\n"
-          << "\\lyxformat 237\n"
+          << "\\lyxformat 241\n"
           << "\\begin_document\n"
           << "\\begin_header\n"
           << "\\textclass " << h_textclass << "\n"
@@ -255,6 +256,7 @@ void end_preamble(ostream & os, LyXTextClass const & /*textclass*/)
           << "\\papersides " << h_papersides << "\n"
           << "\\paperpagestyle " << h_paperpagestyle << "\n"
           << "\\tracking_changes " << h_tracking_changes << "\n"
+          << "\\output_changes " << h_output_changes << "\n"
           << "\\end_header\n\n"
           << "\\begin_body\n";
        // clear preamble for subdocuments
@@ -365,6 +367,10 @@ LyXTextClass const parse_preamble(Parser & p, ostream & os, string const & force
                        split(p.getArg('[', ']'), opts, ',');
                        handle_opt(opts, known_languages, h_language);
                        handle_opt(opts, known_fontsizes, h_paperfontsize);
+                       // delete "pt" at the end
+                       string::size_type i = h_paperfontsize.find("pt");
+                       if (i != string::npos)
+                               h_paperfontsize.erase(i);
                        h_quotes_language = h_language;
                        h_options = join(opts, ",");
                        h_textclass = p.getArg('{', '}');
@@ -393,8 +399,8 @@ LyXTextClass const parse_preamble(Parser & p, ostream & os, string const & force
                        ss << p.getOpt();
                        ss << '{' << p.verbatim_item() << '}';
                        ss << '{' << p.verbatim_item() << '}';
-                       if (name != "lyxcode" && name != "lyxlist"
-                                       && name != "lyxrightadress" && name != "lyxaddress")
+                       if (name != "lyxcode" && name != "lyxlist" &&
+                           name != "lyxrightadress" && name != "lyxaddress")
                                h_preamble << ss.str();
                }
 
@@ -402,7 +408,8 @@ LyXTextClass const parse_preamble(Parser & p, ostream & os, string const & force
                        string name = p.get_token().cs();
                        while (p.next_token().cat() != catBegin)
                                name += p.get_token().asString();
-                       h_preamble << "\\def\\" << name << '{' << p.verbatim_item() << "}";
+                       h_preamble << "\\def\\" << name << '{'
+                                  << p.verbatim_item() << "}";
                }
 
                else if (t.cs() == "newcolumntype") {
index 312ddbf99b56976c536fac83aa24b62897bdeb23..f1dfebf91a2ab9db63f4ef9dc450ddb30e49e47b 100644 (file)
@@ -197,7 +197,7 @@ map<string, string> split_map(string const & s)
  * The latter can be a real unit like "pt", or a latex length variable
  * like "\textwidth". The unit may contain additional stuff like glue
  * lengths, but we don't care, because such lengths are ERT anyway.
- * \return true if \param value and \param unit are valid.
+ * \returns true if \p value and \p unit are valid.
  */
 bool splitLatexLength(string const & len, string & value, string & unit)
 {
@@ -283,10 +283,10 @@ string translate_len(string const & length)
 
 
 /*!
- * Translates a LaTeX length into \param value, \param unit and
- * \param special parts suitable for a box inset.
+ * Translates a LaTeX length into \p value, \p unit and
+ * \p special parts suitable for a box inset.
  * The difference from translate_len() is that a box inset knows about
- * some special "units" that are stored in \param special.
+ * some special "units" that are stored in \p special.
  */
 void translate_box_len(string const & length, string & value, string & unit, string & special)
 {
@@ -362,9 +362,10 @@ void handle_ert(ostream & os, string const & s, Context & context, bool check_la
        for (string::const_iterator it = s.begin(), et = s.end(); it != et; ++it) {
                if (*it == '\\')
                        os << "\n\\backslash\n";
-               else if (*it == '\n')
-                       os << "\n\\newline\n";
-               else
+               else if (*it == '\n') {
+                       newcontext.new_paragraph(os);
+                       newcontext.check_layout(os);
+               } else
                        os << *it;
        }
        newcontext.check_end_layout(os);
@@ -386,7 +387,8 @@ void handle_comment(ostream & os, string const & s, Context & context)
                        os << *it;
        }
        // make sure that our comment is the last thing on the line
-       os << "\n\\newline";
+       newcontext.new_paragraph(os);
+       newcontext.check_layout(os);
        newcontext.check_end_layout(os);
        end_inset(os);
 }
@@ -687,11 +689,11 @@ void parse_environment(Parser & p, ostream & os, bool outer,
                        parent_context.new_paragraph(os);
                }
                if (name == "flushleft" || name == "raggedright")
-                       parent_context.add_extra_stuff("\\align left ");
+                       parent_context.add_extra_stuff("\\align left\n");
                else if (name == "flushright" || name == "raggedleft")
-                       parent_context.add_extra_stuff("\\align right ");
+                       parent_context.add_extra_stuff("\\align right\n");
                else
-                       parent_context.add_extra_stuff("\\align center ");
+                       parent_context.add_extra_stuff("\\align center\n");
                parse_text(p, os, FLAG_END, outer, parent_context);
                // Just in case the environment is empty ..
                parent_context.extra_stuff.erase();
@@ -1141,12 +1143,12 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
 
                else if (t.cs() == "noindent") {
                        p.skip_spaces();
-                       context.add_extra_stuff("\\noindent ");
+                       context.add_extra_stuff("\\noindent\n");
                }
 
                else if (t.cs() == "appendix") {
                        p.skip_spaces();
-                       context.add_extra_stuff("\\start_of_appendix ");
+                       context.add_extra_stuff("\\start_of_appendix\n");
                }
 
                // Must attempt to parse "Section*" before "Section".
@@ -1347,6 +1349,8 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
                }
 
                else if (t.cs() == "makeindex" || t.cs() == "maketitle") {
+                       // FIXME: Somehow prevent title layouts if
+                       // "maketitle" was not found
                        p.skip_spaces();
                        skip_braces(p); // swallow this
                }
@@ -1471,8 +1475,8 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
                else if (use_natbib &&
                         is_known(t.cs(), known_natbib_commands) &&
                         ((t.cs() != "citefullauthor" &&
-                          t.cs() != "citeyear" &&
-                          t.cs() != "citeyearpar") ||
+                          t.cs() != "citeyear" &&
+                          t.cs() != "citeyearpar") ||
                          p.next_token().asInput() != "*")) {
                        context.check_layout(os);
                        // tex                       lyx
@@ -1541,12 +1545,12 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
                        string const citation = p.verbatim_item();
                        if (!before.empty() && argumentOrder == '\0') {
                                cerr << "Warning: Assuming argument order "
-                                    << "of jurabib version 0.6 for\n'"
+                                       "of jurabib version 0.6 for\n'"
                                     << command << before << after << '{'
                                     << citation << "}'.\n"
-                                    << "Add 'jurabiborder' to the jurabib "
-                                    << "package options if you used an\n"
-                                    << "earlier jurabib version." << endl;
+                                       "Add 'jurabiborder' to the jurabib "
+                                       "package options if you used an\n"
+                                       "earlier jurabib version." << endl;
                        }
                        begin_inset(os, "LatexCommand ");
                        os << command << after << before