Skip to content

Commit

Permalink
APA-CV Sorting (#6887)
Browse files Browse the repository at this point in the history
* APA-CV Sorting

Simplifying this fixes some weird behavior reported in https://forums.zotero.org/discussion/comment/454358/#Comment_454358

* New date-bib sorting logic

* Copy new logic to other APA styles

* bug fix

---------

Co-authored-by: Brenton M. Wiernik <[email protected]>
  • Loading branch information
adam3smith and bwiernik authored Feb 11, 2024
1 parent 7575594 commit 403bdb3
Show file tree
Hide file tree
Showing 9 changed files with 569 additions and 251 deletions.
91 changes: 63 additions & 28 deletions apa-annotated-bibliography.csl
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@
</choose>
</macro>
<macro name="date-bib">
<!-- TODO: Add new item types -->
<group delimiter=" " prefix="(" suffix=")">
<choose>
<if is-uncertain-date="issued">
Expand All @@ -211,35 +212,38 @@
<group>
<choose>
<if variable="issued">
<date variable="issued">
<date-part name="year"/>
</date>
<text variable="year-suffix"/>
<choose>
<if type="article-magazine article-newspaper broadcast interview motion_picture pamphlet personal_communication post post-weblog song speech webpage" match="any">
<!-- Many video and audio examples in manual give full dates. Err on the side of too much information. -->
<date variable="issued">
<date-part prefix=", " name="month"/>
<date-part prefix=" " name="day"/>
</date>
</if>
<else-if type="paper-conference">
<!-- Capture 'speech' stored as 'paper-conference' -->
<choose>
<if variable="collection-editor editor editorial-director issue page volume" match="none">
<date variable="issued">
<date-part prefix=", " name="month"/>
<date-part prefix=" " name="day"/>
</date>
</if>
</choose>
</else-if>
<!-- Only year: article article-journal book chapter entry entry-dictionary entry-encyclopedia dataset figure graphic
manuscript map musical_score paper-conference[published] patent report review review-book thesis -->
</choose>
<group delimiter=", ">
<group>
<date variable="issued" date-parts="year" form="numeric"/>
<text variable="year-suffix"/>
</group>
<choose>
<if type="article-magazine article-newspaper broadcast interview motion_picture pamphlet personal_communication post post-weblog song speech webpage" match="any">
<!-- Many video and audio examples in manual give full dates. Err on the side of too much information. -->
<date variable="issued">
<date-part name="month"/>
<date-part name="day" prefix=" "/>
</date>
</if>
<else-if type="paper-conference">
<!-- Capture 'speech' stored as 'paper-conference' -->
<choose>
<if variable="collection-editor editor editorial-director issue page volume" match="none">
<date variable="issued">
<date-part name="month"/>
<date-part name="day" prefix=" "/>
</date>
</if>
</choose>
</else-if>
<!-- Only year: article article-journal book chapter entry entry-dictionary entry-encyclopedia dataset figure graphic
manuscript map musical_score paper-conference[published] patent report review review-book thesis -->
</choose>
</group>
</if>
<else-if variable="status">
<group>
<!-- TODO: Should I print status as-is, or should I print the in-press term? -->
<text variable="status" text-case="lowercase"/>
<text variable="year-suffix" prefix="-"/>
</group>
Expand All @@ -252,6 +256,37 @@
</group>
</group>
</macro>
<macro name="date-sort">
<choose>
<if type="article article-journal book chapter entry entry-dictionary entry-encyclopedia dataset figure graphic manuscript map musical_score patent report review review-book thesis" match="any">
<date variable="issued" date-parts="year" form="numeric"/>
<!-- <text value="0000"/> -->
</if>
<else-if type="paper-conference">
<!-- Capture 'speech' stored as 'paper-conference' -->
<choose>
<if variable="collection-editor editor editorial-director issue page volume" match="any">
<date variable="issued" date-parts="year" form="numeric"/>
<!-- <text value="0000"/> -->
</if>
<else>
<date variable="issued">
<date-part name="year" form="long"/>
<date-part name="month" form="numeric-leading-zeros"/>
<date-part name="day" form="numeric-leading-zeros"/>
</date>
</else>
</choose>
</else-if>
<else>
<date variable="issued">
<date-part name="year" form="long"/>
<date-part name="month" form="numeric-leading-zeros"/>
<date-part name="day" form="numeric-leading-zeros"/>
</date>
</else>
</choose>
</macro>
<macro name="date-sort-group">
<choose>
<if variable="issued">
Expand Down Expand Up @@ -1579,7 +1614,7 @@
<sort>
<key macro="author-bib" names-min="3" names-use-first="1"/>
<key macro="date-sort-group"/>
<key macro="date-bib" sort="ascending"/>
<key macro="date-sort" sort="ascending"/>
<key variable="status"/>
</sort>
<layout prefix="(" suffix=")" delimiter="; ">
Expand All @@ -1594,7 +1629,7 @@
<sort>
<key macro="author-bib"/>
<key macro="date-sort-group"/>
<key macro="date-bib" sort="ascending"/>
<key macro="date-sort" sort="ascending"/>
<key variable="status"/>
<key macro="title"/>
</sort>
Expand Down
98 changes: 69 additions & 29 deletions apa-cv.csl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<category citation-format="author-date"/>
<category field="psychology"/>
<category field="generic-base"/>
<updated>2022-01-31T14:30:00+00:00</updated>
<updated>2023-07-16T22:56:49+00:00</updated>
<rights license="http://creativecommons.org/licenses/by-sa/3.0/">This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License</rights>
</info>
<locale xml:lang="en">
Expand Down Expand Up @@ -148,6 +148,7 @@
</names>
</macro>
<macro name="date-bib">
<!-- TODO: Add new item types -->
<group delimiter=" " prefix="(" suffix=")">
<choose>
<if is-uncertain-date="issued">
Expand All @@ -157,35 +158,38 @@
<group>
<choose>
<if variable="issued">
<date variable="issued">
<date-part name="year"/>
</date>
<text variable="year-suffix"/>
<choose>
<if type="article-magazine article-newspaper broadcast interview motion_picture pamphlet personal_communication post post-weblog song speech webpage" match="any">
<!-- Many video and audio examples in manual give full dates. Err on the side of too much information. -->
<date variable="issued">
<date-part prefix=", " name="month"/>
<date-part prefix=" " name="day"/>
</date>
</if>
<else-if type="paper-conference">
<!-- Capture 'speech' stored as 'paper-conference' -->
<choose>
<if variable="collection-editor editor editorial-director issue page volume" match="none">
<date variable="issued">
<date-part prefix=", " name="month"/>
<date-part prefix=" " name="day"/>
</date>
</if>
</choose>
</else-if>
<!-- Only year: article article-journal book chapter entry entry-dictionary entry-encyclopedia dataset figure graphic
manuscript map musical_score paper-conference[published] patent report review review-book thesis -->
</choose>
<group delimiter=", ">
<group>
<date variable="issued" date-parts="year" form="numeric"/>
<text variable="year-suffix"/>
</group>
<choose>
<if type="article-magazine article-newspaper broadcast interview motion_picture pamphlet personal_communication post post-weblog song speech webpage" match="any">
<!-- Many video and audio examples in manual give full dates. Err on the side of too much information. -->
<date variable="issued">
<date-part name="month"/>
<date-part name="day" prefix=" "/>
</date>
</if>
<else-if type="paper-conference">
<!-- Capture 'speech' stored as 'paper-conference' -->
<choose>
<if variable="collection-editor editor editorial-director issue page volume" match="none">
<date variable="issued">
<date-part name="month"/>
<date-part name="day" prefix=" "/>
</date>
</if>
</choose>
</else-if>
<!-- Only year: article article-journal book chapter entry entry-dictionary entry-encyclopedia dataset figure graphic
manuscript map musical_score paper-conference[published] patent report review review-book thesis -->
</choose>
</group>
</if>
<else-if variable="status">
<group>
<!-- TODO: Should I print status as-is, or should I print the in-press term? -->
<text variable="status" text-case="lowercase"/>
<text variable="year-suffix" prefix="-"/>
</group>
Expand All @@ -198,6 +202,40 @@
</group>
</group>
</macro>
<macro name="date-year">
<date variable="issued" date-parts="year" form="numeric"/>
</macro>
<macro name="date-sort">
<choose>
<if type="article article-journal book chapter entry entry-dictionary entry-encyclopedia dataset figure graphic manuscript map musical_score patent report review review-book thesis" match="any">
<date variable="issued" date-parts="year" form="numeric"/>
<!-- <text value="0000"/> -->
</if>
<else-if type="paper-conference">
<!-- Capture 'speech' stored as 'paper-conference' -->
<choose>
<if variable="collection-editor editor editorial-director issue page volume" match="any">
<date variable="issued" date-parts="year" form="numeric"/>
<!-- <text value="0000"/> -->
</if>
<else>
<date variable="issued">
<date-part name="year" form="long"/>
<date-part name="month" form="numeric-leading-zeros"/>
<date-part name="day" form="numeric-leading-zeros"/>
</date>
</else>
</choose>
</else-if>
<else>
<date variable="issued">
<date-part name="year" form="long"/>
<date-part name="month" form="numeric-leading-zeros"/>
<date-part name="day" form="numeric-leading-zeros"/>
</date>
</else>
</choose>
</macro>
<macro name="date-sort-group">
<choose>
<if variable="issued">
Expand Down Expand Up @@ -1313,7 +1351,8 @@
<citation et-al-min="21" et-al-use-first="19" et-al-use-last="true">
<sort>
<key macro="date-sort-group" sort="descending"/>
<key macro="date-bib" sort="descending"/>
<key macro="date-year" sort="descending"/>
<key macro="date-sort" sort="ascending"/>
<key variable="status"/>
<key macro="author-bib"/>
<key macro="title"/>
Expand Down Expand Up @@ -1352,7 +1391,8 @@
<bibliography hanging-indent="true" et-al-min="21" et-al-use-first="19" et-al-use-last="true" entry-spacing="0" line-spacing="2">
<sort>
<key macro="date-sort-group" sort="descending"/>
<key macro="date-bib" sort="descending"/>
<key macro="date-year" sort="descending"/>
<key macro="date-sort" sort="ascending"/>
<key variable="status"/>
<key macro="author-bib"/>
<key macro="title"/>
Expand Down
Loading

0 comments on commit 403bdb3

Please sign in to comment.