Georg Baum wrote:
Dov Feldstern wrote:

*** I now see what the problem is! What we need is *exactly* the change
of format 259; but in lyx2lyx, the \\lang property wasn't included for
some reason! The attached patch fixes this, and the output is now OK
(i.e., with this patch, a file created from before the change (also
attached), and in which the problem occurs, is output correctly and
displays correctly in the GUI even now!). But anyway, for the reasons
outlined above, I still think it's more correct to do this is a
separate, new file format, effective as of now.

Yes.

I guess that means duplicating normalize_font_whitespace(), but having it now act *only* on
the lang property (Georg, you may want to make sure there aren't any
other forgotten properties, once we're at it...), and applying the new
function as the converter to a new file format...

Instead of duplicating I would factor it out into a new function that takes
the attributes to look for as a parameter and then use that in the
conversion functions for both formats.

So Georg, does all this make sense? And if so, could you please take
care of it? I guess we also need Jose's OK for this...

Yes, it makes sense. It looks like I and Jose are to be blamed for
forgetting the \lang attribute in lyx2lyx.
Unfortunetaly I have to meet a deadline soon and no time to work on this, so
somebody else has to step in.


Georg



Attached is a patch, using Georg's suggestion (refactoring). This is the first time I'm doing a format change, so please make sure that I'm doing everything which should be done in this case...

Jose -- OK?

Thanks!
Dov

Index: src/Buffer.cpp
===================================================================
--- src/Buffer.cpp      (revision 18743)
+++ src/Buffer.cpp      (working copy)
@@ -142,7 +142,7 @@
 
 namespace {
 
-int const LYX_FORMAT = 271;
+int const LYX_FORMAT = 272;
 
 } // namespace anon
 
Index: lib/lyx2lyx/LyX.py
===================================================================
--- lib/lyx2lyx/LyX.py  (revision 18743)
+++ lib/lyx2lyx/LyX.py  (working copy)
@@ -77,7 +77,7 @@
                    ("1_2",     [220], generate_minor_versions("1.2" , 4)),
                    ("1_3",     [221], generate_minor_versions("1.3" , 7)),
                    ("1_4", range(222,246), generate_minor_versions("1.4" , 4)),
-                   ("1_5", range(246,272), generate_minor_versions("1.5" , 0))]
+                   ("1_5", range(246,273), generate_minor_versions("1.5" , 0))]
 
 
 def formats_list():
Index: lib/lyx2lyx/lyx_1_5.py
===================================================================
--- lib/lyx2lyx/lyx_1_5.py      (revision 18743)
+++ lib/lyx2lyx/lyx_1_5.py      (working copy)
@@ -1099,22 +1099,41 @@
         document.body[i] = unicodedata.normalize("NFKC", document.body[i])
 
 
-def normalize_font_whitespace(document):
+def normalize_font_whitespace_259(document):
     """ Before format 259 the font changes were ignored if a
     whitespace was the first or last character in the sequence, this function
     transfers the whitespace outside."""
+       
+    char_properties = {"\\series": "default",
+                       "\\emph": "default",
+                       "\\color": "none",
+                       "\\shape": "default",
+                       "\\bar": "default",
+                       "\\family": "default"}
+    return normalize_font_whitespace(document, char_properties)
 
+def normalize_font_whitespace_272(document):
+    """ Before format 259 (sic) the font changes were ignored if a
+    whitespace was the first or last character in the sequence. This was 
+    corrected for most font properties in format 259, but the language 
+    was forgotten then. This function applies the same conversion done
+    there (namely, transfers the whitespace outside) for font language
+    changes, as well."""
+
+    char_properties = {"\\lang": "default"}
+    return normalize_font_whitespace(document, char_properties)
+
+def normalize_font_whitespace(document, char_properties):
+    """ Before format 259 the font changes were ignored if a
+    whitespace was the first or last character in the sequence, this function
+    transfers the whitespace outside. Only a change in one of the properties
+       in the provided char_properties is handled by this function."""
+
     if document.backend != "latex":
         return
 
     lines = document.body
 
-    char_properties = {"\\series": "default",
-                       "\\emph": "default",
-                       "\\color": "none",
-                       "\\shape": "default",
-                       "\\bar": "default",
-                       "\\family": "default"}
     changes = {}
 
     i = 0
@@ -1675,7 +1694,7 @@
            [256, []],
            [257, [convert_caption]],
            [258, [convert_lyxline]],
-           [259, [convert_accent, normalize_font_whitespace]],
+           [259, [convert_accent, normalize_font_whitespace_259]],
            [260, []],
            [261, [convert_changes]],
            [262, []],
@@ -1687,10 +1706,12 @@
            [268, []],
            [269, []],
            [270, []],
-           [271, [convert_ext_font_sizes]]
+           [271, [convert_ext_font_sizes]],
+           [272, [normalize_font_whitespace_272]]
           ]
 
 revert =  [
+           [271, []],
            [270, [revert_ext_font_sizes]],
            [269, [revert_beamer_alert, revert_beamer_structure]],
            [268, [revert_preamble_listings_params, revert_listings_inset, 
revert_include_listings]],
Index: development/FORMAT
===================================================================
--- development/FORMAT  (revision 18743)
+++ development/FORMAT  (working copy)
@@ -1,5 +1,10 @@
 LyX file-format changes
 -----------------------
+
+2007-06-12 Dov Feldstern <[EMAIL PROTECTED]>
+       * format incremented to 272: applying the conversion done in format 259
+        to the \lang property, which was forgotten back then...
+
 2007-05-15 José Matos <[EMAIL PROTECTED]>
        * format incremented to 271: extended textclasses accept the
         normal font sizes: 10, 11 and 12pt.

Reply via email to