]> git.lyx.org Git - lyx.git/commitdiff
Support MLA's \autocite variants
authorJuergen Spitzmueller <spitz@lyx.org>
Sat, 13 Jul 2024 15:32:54 +0000 (17:32 +0200)
committerJuergen Spitzmueller <spitz@lyx.org>
Sat, 13 Jul 2024 15:32:54 +0000 (17:32 +0200)
lib/citeengines/biblatex-natbib.citeengine
lib/citeengines/biblatex.citeengine
lib/lyx2lyx/lyx_2_5.py

index c487810b904717e9e08e4aecb23cef70a7654af8..7baf77aa614bb938c4758a46c21f5b95077e5962 100644 (file)
@@ -92,7 +92,8 @@ CiteEngine authoryear
        citeyear[][]=cite*
        citebyear[][]=citeyear
        Footcite$[][]=smartcite
-       Autocite$[][]
+       !mla,mla-strict,mla-new,mla7@Autocite$|mlaautocite[][]
+       mla,mla-strict,mla-new,mla7@Mlaautocite|autocite*<!_mlaautocitestar!_mlaautocitetooltip>$[][]=autocite
        citetitle*<!_citetitlestar!_citetitlestartooltip>[][]
        !mla,mla-strict,mla-new,mla7@fullcite[][]
        footfullcite[][]
@@ -154,6 +155,8 @@ CiteFormat default
        # GUI strings for the starred commands
        _citetitlestar F&orce full title[[Possible substitute to All aut&hors]]
        _citetitlestartooltip Use full title even if shorttitle exists
+       _mlaautocitestar Omit aut&hors[[Possible substitute to All aut&hors]]
+       _mlaautocitestartooltip Omit authors or editors in the citation
        # The following are handled by BiblioInfo
        B_etal  et al.
        B_namesep , [[separate author names in citation, except for last name]]
@@ -314,6 +317,9 @@ CiteFormat authoryear
        # 1. APA
        # "cf. Author A Year; Author B Year, p. xx"
        nptextcite %!textbefore%%!makepcite%%!textafter%
+       # 2. MLA
+       # "Auto: (cf. Author A Year; Author B Year, p. xx)"
+       mlaautocite {%dialog%[[%_autocite%]][[%_auto%]]}: %!open%%!textbefore%%!makepcite%%!textafter%%!close%
 End
 
 CiteFormat numerical
index 92199df9fc0bf110f9c7a0356f30271808cadeed..f039962a404d9d7d92623b3105a148a0425de2e2 100644 (file)
@@ -84,7 +84,8 @@ CiteEngine authoryear
        citeyear[][]=cite*
        citebyear[][]=citeyear
        Footcite$[][]=smartcite
-       Autocite$[][]
+       !mla,mla-strict,mla-new,mla7@Autocite$|mlaautocite[][]
+       mla,mla-strict,mla-new,mla7@Mlaautocite|autocite*<!_mlaautocitestar!_mlaautocitetooltip>$[][]=autocite
        citetitle*<!_citetitlestar!_citetitlestartooltip>[][]
        !mla,mla-strict,mla-new,mla7@fullcite[][]
        footfullcite[][]
@@ -146,6 +147,8 @@ CiteFormat default
        _citeauthorstartooltip Force a short author list (using et al.)
        _citetitlestar F&orce full title[[Possible substitute to All aut&hors]]
        _citetitlestartooltip Use full title even if shorttitle exists
+       _mlaautocitestar Omit aut&hors[[Possible substitute to All aut&hors]]
+       _mlaautocitestartooltip Omit authors or editors in the citation
        # The following are handled by BiblioInfo
        B_etal  et al.
        B_namesep , [[separate author names in citation, except for last name]]
@@ -300,6 +303,9 @@ CiteFormat authoryear
        # 1. APA
        # "cf. Author A Year; Author B Year, p. xx"
        nptextcite %!textbefore%%!makepcite%%!textafter%
+       # 2. MLA
+       # "Auto: (cf. Author A Year; Author B Year, p. xx)"
+       mlaautocite {%dialog%[[%_autocite%]][[%_auto%]]}: %!open%%!textbefore%%!makepcite%%!textafter%%!close%
 End
 
 CiteFormat numerical
index 3550464cae21868608e8dececf99cc6f42b78324..e76bed5d370906d187e379120e9c9199b69f5a67 100644 (file)
@@ -379,7 +379,7 @@ def revert_biblatex_chicago(document):
 
 
 def revert_nptextcite(document):
-    """Revert \\nptextcite to ERT"""
+    """Revert \\nptextcite and MLA's autocite variants to ERT"""
 
     # 1. Get cite engine
     engine = "basic"
@@ -400,6 +400,13 @@ def revert_nptextcite(document):
         return
 
     # 4. Convert \nptextcite to ERT
+    new_citations = {
+        "nptextcite": "nptextcite",
+        "mlaautocite": "autocite",
+        "Mlaautocite": "Autocite",
+        "mlaautocite*": "autocite*",
+        "Mlaautocite*": "Autocite*",
+    }
     i = 0
     while True:
         i = find_token(document.body, "\\begin_inset CommandInset citation", i)
@@ -416,7 +423,7 @@ def revert_nptextcite(document):
             i = j + 1
             continue
         cmd = get_value(document.body, "LatexCommand", k)
-        if cmd == "nptextcite":
+        if cmd in list(new_citations.keys()):
             pre = get_quoted_value(document.body, "before", i, j)
             post = get_quoted_value(document.body, "after", i, j)
             key = get_quoted_value(document.body, "key", i, j)
@@ -424,7 +431,7 @@ def revert_nptextcite(document):
                 document.warning("Citation inset at line %d does not have a key!" % (i))
                 key = "???"
             # Replace known new commands with ERT
-            res = "\\nptextcite"
+            res = "\\" + new_citations[cmd]
             if pre:
                 res += "[" + pre + "]"
             if post: