]> git.lyx.org Git - features.git/commitdiff
Support memoir's builtin endnotes
authorJuergen Spitzmueller <spitz@lyx.org>
Tue, 13 Aug 2019 08:38:26 +0000 (10:38 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 18 Jun 2020 13:48:43 +0000 (15:48 +0200)
lib/layouts/memoir.layout
lib/lyx2lyx/lyx_2_4.py

index 7a1404aef8ccf39abb88cba06f4e431305b6ac26..ef4685328d3ba317879e86eceaae485a928f576b 100644 (file)
@@ -290,3 +290,50 @@ Style Legend
        ParSkip             0.4
        Align               Center
 End
+
+#
+# Endnotes (called "pagenotes" in memoir)
+#
+
+Counter endnotes
+    PrettyFormat "Endnote ##"
+End
+
+InsetLayout Flex:Endnote
+   LyXType     custom
+   LatexName   pagenote
+   LatexType   command
+   Counter     endnotes
+   Decoration  classic
+   Font
+     Size Small
+   EndFont
+   MultiPar    true
+   LabelString endnote
+   Preamble
+      \makepagenote
+   EndPreamble
+   LangPreamble
+     \providecommand{\notesname}{_(Notes[[Endnotes]])}
+   EndLangPreamble
+   BabelPreamble
+     \addto\captions$$lang{\renewcommand{\notesname}{_(Notes[[Endnotes]])}}
+   EndBabelPreamble
+End
+
+# We are only interested in the list
+Float
+   Type          pagenote
+   ListName      "Endnotes (all)"
+   IsPredefined  true
+   UsesFloatPkg  false
+   ListCommand   printpagenotes
+End
+
+Float
+   Type          pagenote*
+   ListName      "Endnotes (sectioned)"
+   IsPredefined  true
+   UsesFloatPkg  false
+   ListCommand   printpagenotes*
+End
index 064a07b085459f240afaf3cd952bfacdd7062139..65b8df5560e1dd205466d807e1d4a731c4c02a95 100644 (file)
@@ -3440,6 +3440,36 @@ def revert_enotez(document):
         add_to_preamble(document, ["\\usepackage{enotez}"])
     document.del_module("enotez")
     document.del_module("foottoenotez")
+
+
+def revert_memoir_endnotes(document):
+    " Reverts native support of memoir endnotes to TeX-code "
+
+    if document.textclass != "memoir":
+        return
+
+    encommand = "\\pagenote"
+    modules = document.get_module_list()
+    if "enotez" in modules or "foottoenotez" in modules or "endnotes" in modules or "foottoend" in modules:
+        encommand = "\\endnote"
+
+    revert_flex_inset(document.body, "Endnote", encommand)
+
+    i = 0
+    while True:
+        i = find_token(document.body, "\\begin_inset FloatList pagenote", i + 1)
+        if i == -1:
+            break
+        j = find_end_of_inset(document.body, i)
+        if j == -1:
+            document.warning("Malformed LyX document: Can't find end of FloatList inset")
+            continue
+
+        if document.body[i] == "\\begin_inset FloatList pagenote*":
+            document.body[i : j + 1] = put_cmd_in_ert("\\printpagenotes*")
+        else:
+            document.body[i : j + 1] = put_cmd_in_ert("\\printpagenotes")
+        add_to_preamble(document, ["\\makepagenote"])
     
 
 ##
@@ -3494,7 +3524,7 @@ convert = [
            [588, []]
           ]
 
-revert =  [[587, [revert_enotez,revert_theendnotes]],
+revert =  [[587, [revert_memoir_endnotes,revert_enotez,revert_theendnotes]],
            [586, [revert_pagesizenames]],
            [585, [revert_dupqualicites]],
            [584, [revert_pagesizes,revert_komafontsizes]],