Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 19 additions & 25 deletions inst/resources/cjfas.csl
Original file line number Diff line number Diff line change
Expand Up @@ -51,28 +51,21 @@
</names>
</macro>
<macro name="author-short">
<choose>
<if type="report" variable="genre" match="all">
<text variable="publisher"/>
</if>
<else>
<names variable="author">
<name form="short" and="text" delimiter=", " initialize-with=". "/>
<substitute>
<names variable="editor"/>
<names variable="translator"/>
<choose>
<if type="bill book graphic legal_case legislation motion_picture report song" match="any">
<text variable="title" form="short" font-style="italic"/>
</if>
<else>
<text variable="title" form="short" quotes="true"/>
</else>
</choose>
</substitute>
</names>
</else>
</choose>
<names variable="author">
<name form="short" and="text" delimiter=", " initialize-with=". "/>
<substitute>
<names variable="editor"/>
<names variable="translator"/>
<choose>
<if type="bill book graphic legal_case legislation motion_picture report song" match="any">
<text variable="title" form="short" font-style="italic"/>
</if>
<else>
<text variable="title" form="short" quotes="true"/>
</else>
</choose>
</substitute>
</names>
</macro>
<macro name="access">
<choose>
Expand Down Expand Up @@ -251,10 +244,11 @@
<choose>
<if type="report" variable="genre" match="all">
<group delimiter=". ">
<text variable="publisher"/>
<text macro="issued-month-year"/>
<text macro="author"/>
<text macro="issued-year"/>
<text variable="title"/>
<text variable="publisher-place"/>
<text variable="publisher"/>
<text variable="number-of-pages" suffix=" p."/>
<text macro="stock-assessment-access"/>
</group>
</if>
Expand Down
26 changes: 24 additions & 2 deletions tests/testthat/test-cjfas-csl.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,29 @@ test_that("cjfas CSL includes stock-assessment report formatting", {
)

expect_match(csl, '<if type="report" variable="genre" match="all">', fixed = TRUE)
expect_match(csl, '<text macro="issued-month-year"/>', fixed = TRUE)
expect_match(
csl,
paste(
c(
'<if type="report" variable="genre" match="all">',
' <group delimiter=". ">',
' <text macro="author"/>',
' <text macro="issued-year"/>',
' <text variable="title"/>',
' <text variable="publisher"/>',
' <text variable="number-of-pages" suffix=" p."/>',
' <text macro="stock-assessment-access"/>'
),
collapse = "\n"
),
fixed = TRUE
)
expect_match(csl, '<text value="Accessible at"/>', fixed = TRUE)
expect_match(csl, '<text variable="publisher"/>', fixed = TRUE)
expect_false(
grepl(
'<if type="report" variable="genre" match="all">\n <text variable="publisher"/>',
csl,
fixed = TRUE
)
)
})