Skip to content

Commit

Permalink
fix typst citations
Browse files Browse the repository at this point in the history
  • Loading branch information
wjschne committed May 11, 2024
1 parent 2801374 commit 0fff720
Show file tree
Hide file tree
Showing 15 changed files with 427 additions and 192 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This article template creates [APA Style 7th Edition
documents](https://apastyle.apa.org/) in .docx, .html. and .pdf. The
.pdf format can be rendered via Latex (i.e., apaquarto-pdf) or via Typst
(apaquarto-typst). The Typst output for this extension is still
experimental and requires Typst version 0.11.0 or greater.
experimental and requires Quarto 1.5 or greater.

Because the .docx format is still widely used—and often required—my main
priority was to ensure compatibility for .docx. This is still a work in
Expand Down
2 changes: 1 addition & 1 deletion README.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ engine: knitr
---
<img loading="lazy" alt="any text: you like" src="https://img.shields.io/badge/lifecycle-experimental-orange">

This article template creates [APA Style 7th Edition documents](https://apastyle.apa.org/) in .docx, .html. and .pdf. The .pdf format can be rendered via Latex (i.e., apaquarto-pdf) or via Typst (apaquarto-typst). The Typst output for this extension is still experimental and requires Typst version 0.11.0 or greater.
This article template creates [APA Style 7th Edition documents](https://apastyle.apa.org/) in .docx, .html. and .pdf. The .pdf format can be rendered via Latex (i.e., apaquarto-pdf) or via Typst (apaquarto-typst). The Typst output for this extension is still experimental and requires Quarto 1.5 or greater.

Because the .docx format is still widely used---and often required---my main priority was to ensure compatibility for .docx. This is still a work in progress, and I encourage filing a "New Issue" on GitHub if something does not work of if there is a feature missing.

Expand Down
4 changes: 1 addition & 3 deletions _extensions/apaquarto/_extension.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
title: My Document in APA Style, Seventh Edition
author: W. Joel Schneider
version: 4.0.2
version: 4.0.3
quarto-required: ">=1.4.549"
contributes:
formats:
Expand Down Expand Up @@ -89,7 +89,6 @@ contributes:
pdf:
documentclass: apa7
pdf-engine: xelatex
link-citations: false
suppress-bibliography: false
hyperrefoptions:
- linktoc=none
Expand All @@ -116,7 +115,6 @@ contributes:
filters:
- at: post-quarto
path: typst/formattypst.lua
citeproc: true
template-partials:
- typst/typst-template.typ
- typst/typst-show.typ
16 changes: 14 additions & 2 deletions _extensions/apaquarto/apaandcite.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
-- Schneider's (2021) primary findings were replicated in our study.

local andreplacement = "and"
local makelinks = false

-- make string, if it exists, else return default
local stringify = function(s, default)
Expand All @@ -33,6 +34,9 @@ local function get_and(m)
m.language["citation-last-author-separator"],
andreplacement)
end
if m["link-citations"] then
makelinks = true
end
end

local function replace_and(ct)
Expand Down Expand Up @@ -68,8 +72,16 @@ local function replace_and(ct)
end
end
end
end
return ct.content
end
if FORMAT == "typst" then
return ct.content
else
return ct
end

end
if FORMAT == "typst" then
return ct.content
end
end

Expand Down
6 changes: 5 additions & 1 deletion _extensions/apaquarto/citeprocr.lua
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,11 @@ return {
end
end
end
return pandoc.utils.citeproc(doc)
local d = pandoc.utils.citeproc(doc)
if FORMAT == "typst" then
d.meta.citeproc = true
end
return d
end

}
Expand Down
11 changes: 11 additions & 0 deletions _extensions/apaquarto/docxlinenumber.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ if FORMAT ~= "docx" then
return
end

function Math(eq)
if eq.mathtype == "InlineMath" then
if eq.text == "\\LaTeX" then
return pandoc.Str("LaTeX")
end
if eq.text == "\\TeX" then
return pandoc.Str("TeX")
end
end
end


function Pandoc(doc)
if doc.meta["numbered-lines"] then
Expand Down
Loading

0 comments on commit 0fff720

Please sign in to comment.