Hello, I have sent this patch for the list last December (the 3th, I think).
This patch changes the file format by placing every paragraph parameter in its own line. This already happens for some and not for others. This patch makes it uniform. Any objection? -- José Abílio
? src/frontends/gtk/pch.h.gch ? src/frontends/gtk/pch.h.gch.dep Index: development/FORMAT =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/development/FORMAT,v retrieving revision 1.33 diff -u -p -r1.33 FORMAT --- development/FORMAT 3 Dec 2004 18:39:51 -0000 1.33 +++ development/FORMAT 6 Jan 2005 16:19:20 -0000 @@ -1,26 +1,43 @@ LyX file-format changes ----------------------- +2005-01-06 José Matos <[EMAIL PROTECTED]> + + * format incremented to 239. + * the paragraph parameters are displayed in their own line. This + change is consistent with the insets behaviour, and corresponds + to a more uniform treatment of the paragraphs since some of them + had already their own line. + + An example of a single paragraph follows: + +\begin_layout Standard +\paragraph_spacing single +\align left +Paragraph text. +\end_layout + + 2004-12-03 José Matos <[EMAIL PROTECTED]> - * format up to 238. - * The compatibility code to read old latex accents from 0.12.x in - InsetLatexAccent::checkContents has been removed. - The following translations are done: - "\i \x" -> "\i \x{}" - "\i \xy" -> "\i \x{y}" - "\i \x y" -> "\i \x{y}" - "\i \x\i" -> "\i \x{\i}" - "\i \x\j" -> "\i \x{\j}" - x is a latex accent command, y the base character. \, i and j are - literal. - lyx did these changes already from 0.12.x -> 215, but not lyx2lyx, - so formats 215 - 237 can have both versions. + * format incremented to 238. + * The compatibility code to read old latex accents from 0.12.x in + InsetLatexAccent::checkContents has been removed. + The following translations are done: + "\i \x" -> "\i \x{}" + "\i \xy" -> "\i \x{y}" + "\i \x y" -> "\i \x{y}" + "\i \x\i" -> "\i \x{\i}" + "\i \x\j" -> "\i \x{\j}" + x is a latex accent command, y the base character. \, i and j are + literal. + lyx did these changes already from 0.12.x -> 215, but not lyx2lyx, + so formats 215 - 237 can have both versions. 2004-10-10 José Matos <[EMAIL PROTECTED]> - * format up to 237. + * format incremented to 237. * In the header, the following statments use now booleans values, instead of 0, 1: - \use_geometry Index: lib/lyx2lyx/ChangeLog =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/lyx2lyx/ChangeLog,v retrieving revision 1.55 diff -u -p -r1.55 ChangeLog --- lib/lyx2lyx/ChangeLog 5 Jan 2005 18:52:59 -0000 1.55 +++ lib/lyx2lyx/ChangeLog 6 Jan 2005 16:19:21 -0000 @@ -1,3 +1,10 @@ +2005-01-06 José Matos <[EMAIL PROTECTED]> + + * lyx_1_4.py (normalize_paragraph_params): update file format to 239. + + * LyX.py (convert): simplify code and add running times + information for higher debug levels. + 2005-01-04 José Matos <[EMAIL PROTECTED]> * lyx_0_12.py: Index: lib/lyx2lyx/LyX.py =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/lyx2lyx/LyX.py,v retrieving revision 1.8 diff -u -p -r1.8 LyX.py --- lib/lyx2lyx/LyX.py 5 Jan 2005 18:52:59 -0000 1.8 +++ lib/lyx2lyx/LyX.py 6 Jan 2005 16:19:21 -0000 @@ -16,12 +16,14 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -from parser_tools import get_value, check_token, find_token, find_tokens, find_end_of, find_end_of_inset +from parser_tools import get_value, check_token, find_token,\ + find_tokens, find_end_of, find_end_of_inset import os.path import gzip import sys import re import string +import time version_lyx2lyx = "1.4.0cvs" default_debug_level = 2 @@ -44,7 +46,7 @@ format_relation = [("0_10", [210], ["0. ("1_1_6fix3", [218], ["1.1.6fix3","1.1.6fix4","1.1"]), ("1_2", [220], ["1.2.0","1.2.1","1.2.3","1.2.4","1.2"]), ("1_3", [221], ["1.3.0","1.3.1","1.3.2","1.3.3","1.3.4","1.3.5","1.3"]), - ("1_4", range(223,239), ["1.4.0cvs","1.4"])] + ("1_4", range(223,240), ["1.4.0cvs","1.4"])] def formats_list(): @@ -267,23 +269,23 @@ class LyX_Base: for step in convertion_chain: steps = getattr(__import__("lyx_" + step), mode) + self.warning("Convertion step: %s - %s" % (step, mode), default_debug_level + 1) if not steps: self.error("The convertion to an older format (%s) is not implemented." % self.format) - if len(steps) == 1: - version, table = steps[0] - for conv in table: - conv(self) - self.format = version - continue - + multi_conv = len(steps) != 1 for version, table in steps: - if self.format >= version and mode == "convert": - continue - if self.format <= version and mode == "revert": + if multi_conv and \ + (self.format >= version and mode == "convert") or\ + (self.format <= version and mode == "revert"): continue + for conv in table: + init_t = time.time() conv(self) + self.warning("%lf: Elapsed time on %s" % (time.time() - init_t, str(conv)), + default_debug_level + 1) + self.format = version if self.end_format == self.format: return Index: lib/lyx2lyx/lyx_1_4.py =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/lyx2lyx/lyx_1_4.py,v retrieving revision 1.20 diff -u -p -r1.20 lyx_1_4.py --- lib/lyx2lyx/lyx_1_4.py 5 Jan 2005 18:52:59 -0000 1.20 +++ lib/lyx2lyx/lyx_1_4.py 6 Jan 2005 16:19:21 -0000 @@ -1508,6 +1508,32 @@ def use_x_binary(file): file.header[i] = decompose[0] + ' ' + bool2bin[decompose[1]] ## +# Place all the paragraph parameters in their own line +# +def normalize_paragraph_params(file): + body = file.body + allowed_parameters = '\\paragraph_spacing', '\\noindent', '\\align', '\\labelwidthstring' + + i = 0 + while 1: + i = find_token(file.body, '\\begin_layout', i) + if i == -1: + return + + i = i + 1 + while 1: + if strip(body[i]) and split(body[i])[0] not in allowed_parameters: + break + + j = find(body[i],'\\', 1) + + if j != -1: + body[i:i+1] = [strip(body[i][:j]), body[i][j:]] + + i = i + 1 + + +## # Convertion hub # @@ -1529,9 +1555,11 @@ convert = [[223, [insert_tracking_change [236, [convert_bullets, add_begin_header, add_begin_body, normalize_papersize, strip_end_space]], [237, [use_x_boolean]], - [238, [update_latexaccents]]] + [238, [update_latexaccents]], + [239, [normalize_paragraph_params]]] -revert = [[237, []], +revert = [[238, []], + [237, []], [236, [use_x_binary]], [235, [denormalize_papersize, remove_begin_body,remove_begin_header, revert_bullets]], Index: src/ChangeLog =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ChangeLog,v retrieving revision 1.2076 diff -u -p -r1.2076 ChangeLog --- src/ChangeLog 6 Jan 2005 15:40:27 -0000 1.2076 +++ src/ChangeLog 6 Jan 2005 16:19:25 -0000 @@ -1,3 +1,9 @@ +2005-01-06 José Matos <[EMAIL PROTECTED]> + + * ParagraphParameters.C (write): put every parameter in its own line. + * paragraph.C (write): reduce number of consecutive empty lines exported. + * buffer.C (LYX_FORMAT): increase file format to 239. + 2005-01-06 Lars Gullik Bjonnes <[EMAIL PROTECTED]> * tabular.C: make all write_attributes templates, tostr -> convert @@ -182,7 +188,7 @@ * Makefile.am (BOOST_LIBS): use boost variables -2004-12-03 José Matos <[EMAIL PROTECTED]> +2004-12-03 José Matos <[EMAIL PROTECTED]> * buffer.C: format up to 238. Index: src/ParagraphParameters.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ParagraphParameters.C,v retrieving revision 1.45 diff -u -p -r1.45 ParagraphParameters.C --- src/ParagraphParameters.C 6 Jan 2005 13:48:07 -0000 1.45 +++ src/ParagraphParameters.C 6 Jan 2005 16:19:25 -0000 @@ -246,28 +246,25 @@ void ParagraphParameters::read(LyXLex & void ParagraphParameters::write(ostream & os) const { - ostringstream oss; - // Maybe the paragraph has special spacing - spacing().writeFile(oss, true); + spacing().writeFile(os, true); // The labelwidth string used in lists. if (!labelWidthString().empty()) - oss << "\\labelwidthstring " + os << "\\labelwidthstring " << labelWidthString() << '\n'; // Start of appendix? if (startOfAppendix()) - oss << "\\start_of_appendix "; + os << "\\start_of_appendix\n"; // Noindent? if (noindent()) - oss << "\\noindent "; + os << "\\noindent\n"; // Do we have a manual left indent? if (!leftIndent().zero()) - oss << "\\leftindent " << leftIndent().asString() - << ' '; + os << "\\leftindent " << leftIndent().asString() << '\n'; // Alignment? if (align() != LYX_ALIGN_LAYOUT) { @@ -278,9 +275,8 @@ void ParagraphParameters::write(ostream case LYX_ALIGN_CENTER: h = 3; break; default: h = 0; break; } - oss << "\\align " << string_align[h] << ' '; + os << "\\align " << string_align[h] << '\n'; } - os << rtrim(oss.str()); } @@ -301,7 +297,7 @@ void params2string(Paragraph const & par params.write(os); // Is alignment possible - os << '\n' << "\\alignpossible " << layout->alignpossible << '\n'; + os << "\\alignpossible " << layout->alignpossible << '\n'; /// set default alignment os << "\\aligndefault " << layout->align << '\n'; Index: src/buffer.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/buffer.C,v retrieving revision 1.599 diff -u -p -r1.599 buffer.C --- src/buffer.C 6 Jan 2005 15:40:28 -0000 1.599 +++ src/buffer.C 6 Jan 2005 16:19:25 -0000 @@ -136,7 +136,7 @@ extern BufferList bufferlist; namespace { -int const LYX_FORMAT = 238; +int const LYX_FORMAT = 239; } // namespace anon Index: src/paragraph.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/paragraph.C,v retrieving revision 1.397 diff -u -p -r1.397 paragraph.C --- src/paragraph.C 6 Jan 2005 15:40:30 -0000 1.397 +++ src/paragraph.C 6 Jan 2005 16:19:25 -0000 @@ -156,10 +156,6 @@ void Paragraph::write(Buffer const & buf int column = 0; for (pos_type i = 0; i < size(); ++i) { - if (!i) { - os << '\n'; - column = 0; - } Change change = pimpl_->lookupChangeFull(i); Changes::lyxMarkChange(os, column, curtime, running_change, change); @@ -185,7 +181,9 @@ void Paragraph::write(Buffer const & buf // the file inset->write(buf, os); } else { - os << "\n\\begin_inset "; + if (i) + os << '\n'; + os << "\\begin_inset "; inset->write(buf, os); os << "\n\\end_inset\n\n"; column = 0;