]> git.lyx.org Git - features.git/commitdiff
Fix encoding in aa class, which is preset via class options
authorJuergen Spitzmueller <spitz@lyx.org>
Fri, 30 Aug 2019 06:09:57 +0000 (08:09 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 18 Jun 2020 13:48:44 +0000 (15:48 +0200)
Hook into nearby file format change.

development/FORMAT
lib/layouts/aa.layout
lib/lyx2lyx/lyx_2_4.py

index 93c0043f3571f767111e6ca4fb9a18d14e9b6d52..73d80650d9dd19291a335a41583ed5e571912fcd 100644 (file)
@@ -160,12 +160,15 @@ changes happened in particular if possible. A good example would be
          This builds on an extension of the natbib CiteEngine by tufte.
 
 2018-05-10  Jürgen Spitzmüller <spitz@lyx.org>
-       * format incremented to 552: support for float alignment
+       Format incremented to 552: 
+       * support for float alignment
          - add buffer param \float_alignment [class|left|center|right]
          - add buffer param \float_placement class
          - add float param alignment [class|document|left|center|right]
          - add float param placement class (=> new param)
          - add float param placement document(=> like formerly empty param)
+       * adapt class options in aa class documents to latin9 > utf8 default
+          encoding change.
 
 2018-05-06  Jürgen Spitzmüller <spitz@lyx.org>
        * format incremented to 551: add font info param \nospellcheck that prevents
index 62b73b78591460abf91d6214f744ee04c6d03a82..ce5ac2e77ba7e0d60e87103216b4d756c226d212 100644 (file)
@@ -30,7 +30,7 @@ Provides inputenc     1
 Provides natbib                1
 
 ClassOptions
-       Other           latin9
+       Other           utf8
 End
 
 Style Standard
index 40a1f3dfdb19dc766cef25a586534c039651da22..5cdcc3c692ce83f0bb1277a1a995ad522735e66b 100644 (file)
@@ -792,6 +792,57 @@ def revert_tuftecite(document):
         i = j
 
 
+def convert_aaencoding(document):
+    " Convert default document option due to encoding change in aa class. "
+
+    if document.textclass != "aa":
+        return
+
+    i = 0
+
+    i = find_token(document.header, "\\use_default_options true", i)
+    if i == -1:
+        return
+    j = find_token(document.header, "\\inputencoding", 0)
+    if j == -1:
+        document.warning("Malformed LyX Document! Missing \\inputencoding header.")
+        return
+    val = get_value(document.header, "\\inputencoding", j)
+    if val == "auto" or val == "latin9":
+        document.header[i] = "\\use_default_options false"
+        k = find_token(document.header, "\\options", 0)
+        if k == -1:
+            document.header.insert(i, "\\options latin9")
+        else:
+            document.header[k] = document.header[k] + ",latin9"
+
+
+def revert_aaencoding(document):
+    " Revert default document option due to encoding change in aa class. "
+
+    if document.textclass != "aa":
+        return
+
+    i = 0
+
+    i = find_token(document.header, "\\use_default_options true", i)
+    if i == -1:
+        return
+    j = find_token(document.header, "\\inputencoding", 0)
+    if j == -1:
+        document.warning("Malformed LyX Document! Missing \\inputencoding header.")
+        return
+    val = get_value(document.header, "\\inputencoding", j)
+    if val == "utf8":
+        document.header[i] = "\\use_default_options false"
+        k = find_token(document.header, "\\options", 0)
+        if k == -1:
+            document.header.insert(i, "\\options utf8")
+        else:
+            document.header[k] = document.header[k] + ",utf8"
+            
+
+
 def revert_stretchcolumn(document):
     " We remove the column varwidth flags or everything else will become a mess. "
     i = 0
@@ -3598,7 +3649,7 @@ convert = [
            [549, []],
            [550, [convert_fontenc]],
            [551, []],
-           [552, []],
+           [552, [convert_aaencoding]],
            [553, []],
            [554, []],
            [555, []],
@@ -3675,7 +3726,7 @@ revert =  [[588, [revert_totalheight]],
            [554, [revert_vcolumns]],
            [553, [revert_stretchcolumn]],
            [552, [revert_tuftecite]],
-           [551, [revert_floatpclass, revert_floatalignment]],
+           [551, [revert_floatpclass, revert_floatalignment, revert_aaencoding]],
            [550, [revert_nospellcheck]],
            [549, [revert_fontenc]],
            [548, []],# dummy format change