]> git.lyx.org Git - features.git/commitdiff
Extend endnotes support
authorJuergen Spitzmueller <spitz@lyx.org>
Mon, 12 Aug 2019 11:00:54 +0000 (13:00 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 18 Jun 2020 13:48:43 +0000 (15:48 +0200)
Support native solution for Endnotes list rather than having to use
\\theendnotes via ERT

File format change

development/FORMAT
lib/layouts/endnotes.module
lib/layouts/foottoend.module
lib/lyx2lyx/lyx_2_4.py
src/tex2lyx/text.cpp
src/version.h

index 77d681357537887ba5ba84f4c30d3b32a9701239..8bb4a3ae3e311b095c88c6b151565d811018e360 100644 (file)
@@ -7,6 +7,10 @@ changes happened in particular if possible. A good example would be
 
 -----------------------
 
+2019-08-12 Jürgen Spitzmüller <spitz@lyx.org>
+       * Format incremented to 588: Support \theendnotes of endnotes package via a faked
+          float list.
+
 2019-08-07 Jürgen Spitzmüller <spitz@lyx.org>
        * Format incremented to 587: Use more generic paper names as LyX names
           (rather than LaTeXisms; e.g., "a4" rather than "a4paper").
index c63e935879127199efb97d8bca8b9f787257b09e..5ab73c9333c5576a80169888955cfe118bdba355 100644 (file)
@@ -1,8 +1,9 @@
 #\DeclareLyXModule[endnotes.sty]{Endnotes}
 #\DeclareCategory{Foot- and Endnotes}
 #DescriptionBegin
-#Adds an endnote inset, in addition to footnotes. You will need to add 
-#\theendnotes in TeX-code where you want the endnotes to appear.
+#Adds an endnote inset, in addition to footnotes. You will need to add an
+#endnotes list (Insert > List/Contents/References > Endnotes) where you
+#want the endnotes to appear.
 #DescriptionEnd
 
 Format 79
@@ -24,3 +25,13 @@ InsetLayout Flex:Endnote
    LabelString endnote
    Requires    endnotes
 End
+
+# We are only interested in the list
+Float
+   Type          endnote
+   ListName      "Endnotes"
+   IsPredefined  true
+   UsesFloatPkg  false
+   ListCommand   theendnotes
+   Requires      endnotes
+End
index 9bbc5af18c8dd0d5b75f86fed1d30ecdbd66a1f2..ab28844478ad41647b53a51a7bd029d5297a0cc4 100644 (file)
@@ -1,8 +1,9 @@
 #\DeclareLyXModule[endnotes.sty]{Footnotes as Endnotes}
 #\DeclareCategory{Foot- and Endnotes}
 #DescriptionBegin
-#Sets all footnotes as endnotes. You will need to add \theendnotes 
-#in TeX-code where you want the endnotes to appear.
+#Sets all footnotes as endnotes. You will need to add an
+#endnotes list (Insert > List/Contents/References > Endnotes) where you
+#want the endnotes to appear.
 #DescriptionEnd
 
 Format 79
@@ -12,3 +13,13 @@ Requires     endnotes
 AddToPreamble
   \let\footnote=\endnote
 EndPreamble
+
+# We are only interested in the list
+Float
+   Type          endnote
+   ListName      "Endnotes"
+   IsPredefined  true
+   UsesFloatPkg  false
+   ListCommand   theendnotes
+   Requires      endnotes
+End
index 90ce08eca3935a9a256b3932a4f0772ad36ba77c..147ff91da8139420af81587f4e68fec379530570 100644 (file)
@@ -3389,6 +3389,25 @@ def revert_pagesizenames(document):
     if val in newnames:
         newval = val + "paper"
         document.header[i] = "\\papersize " + newval
+
+
+def revert_theendnotes(document):
+    " Reverts native support of \\theendnotes to TeX-code "
+
+    if not "endnotes" in document.get_module_list() and not "foottoend" in document.get_module_list():
+        return
+
+    i = 0
+    while True:
+        i = find_token(document.body, "\\begin_inset FloatList endnote", i + 1)
+        if i == -1:
+            return
+        j = find_end_of_inset(document.body, i)
+        if j == -1:
+            document.warning("Malformed LyX document: Can't find end of FloatList inset")
+            continue
+
+        document.body[i : j + 1] = put_cmd_in_ert("\\theendnotes")
     
 
 ##
@@ -3439,10 +3458,12 @@ convert = [
            [584, []],
            [585, [convert_pagesizes]],
            [586, []],
-           [587, [convert_pagesizenames]]
+           [587, [convert_pagesizenames]],
+           [588, []]
           ]
 
-revert =  [[586, [revert_pagesizenames]],
+revert =  [[587, [revert_theendnotes]],
+           [586, [revert_pagesizenames]],
            [585, [revert_dupqualicites]],
            [584, [revert_pagesizes,revert_komafontsizes]],
            [583, [revert_vcsinfo_rev_abbrev]],
index b66ef7f44a206f2abe6854dc75872f2b80f105cc..abc25f274fd6adf4fd3bd78f058f5332ce2eeeb6 100644 (file)
@@ -3931,6 +3931,14 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
                        continue;
                }
 
+               if (t.cs() == "theendnotes") {
+                       context.check_layout(os);
+                       begin_inset(os, "FloatList endnote\n");
+                       end_inset(os);
+                       skip_spaces_braces(p);
+                       continue;
+               }
+
                if ((where = is_known(t.cs(), known_text_font_families))) {
                        parse_text_attributes(p, os, FLAG_ITEM, outer,
                                context, "\\family", context.font.family,
index 13f06a39cdc9aefa44189fc5f2d68ff3f7fa5eca..110ba804cb4dc48654b5beba60f73ea3f9394dcf 100644 (file)
@@ -32,8 +32,8 @@ extern char const * const lyx_version_info;
 
 // Do not remove the comment below, so we get merge conflict in
 // independent branches. Instead add your own.
-#define LYX_FORMAT_LYX 587 // spitz: generic paper size names
-#define LYX_FORMAT_TEX2LYX 587
+#define LYX_FORMAT_LYX 588 // spitz: support \theendnotes
+#define LYX_FORMAT_TEX2LYX 588
 
 #if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX
 #ifndef _MSC_VER