Skip to content

Commit

Permalink
Fix compatibility with csquotes (close #21)
Browse files Browse the repository at this point in the history
  • Loading branch information
zepinglee committed Aug 12, 2022
1 parent 42daa92 commit a5f17a4
Show file tree
Hide file tree
Showing 11 changed files with 2,690 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Fix an infinite loop error when bib entry keys contain hyphens or undercores ([#18](https://github.com/zepinglee/citeproc-lua/issues/18)).
- Fix incorrect item position in note style ([#20](https://github.com/zepinglee/citeproc-lua/issues/20)).
- Fix compatibility with `\blockquote` of `csquotes` ([#21](https://github.com/zepinglee/citeproc-lua/issues/21)).

## [v0.1.1] - 2022-03-21

Expand Down
11 changes: 10 additions & 1 deletion citeproc/citeproc-latex.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ csl.uncited_id_list = {}
csl.uncited_id_map = {}
csl.citations_pre = {}

csl.preview_mode = false -- Whether to use citeproc:preview_citation


function csl.error(str)
luatexbase.module_error("csl", str)
Expand Down Expand Up @@ -89,7 +91,14 @@ function csl.cite(citation_info)

local citation = core.make_citation(citation_info)

local citation_str = csl.engine:process_citation(citation)
local citation_str
if csl.preview_mode then
-- TODO: preview mode in first pass of \blockquote of csquotes
-- citation_str = csl.engine:preview_citation(citation)
citation_str = ""
else
citation_str = csl.engine:process_citation(citation)
end

tex.sprint(string.format("{%s}{%s}", csl.style_class, citation_str))
-- tex.sprint(citation_str)
Expand Down
13 changes: 13 additions & 0 deletions latex/citation-style-language.sty
Original file line number Diff line number Diff line change
Expand Up @@ -1025,6 +1025,19 @@
}


% csquotes

\AtEndOfPackageFile* { csquotes }
{
\BlockquoteDisable
{
\cs_set_eq:NN \__csl_make_citation:NN \use_none:nn
% \sys_if_engine_luatex:T
% { \lua_now:n { csl.preview_mode = true } }
}
}


% hyperref

% The hyperref package also patches \bibcite but it cannot provide hyperlinks
Expand Down
37 changes: 37 additions & 0 deletions test/latex/luatex-1-csquotes.lvt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
\input{regression-test}

\documentclass{article}

\input{csl-test}
\pagestyle{empty}

\usepackage{citation-style-language}

\usepackage{csquotes}

\cslsetup{style = chicago-note-bibliography}
\addbibresource{test.bib}


\begin{document}

\START
\showoutput

% https://github.com/zepinglee/citeproc-lua/issues/21

\enquote{Lorem ipsum.\cite{ITEM-1}}

\blockquote{Lorem ipsum.\cite{ITEM-2}}

\blockquote{%
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis.
Curabitur dictum gravida mauris.
Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna.
Donec vehicula augue eu neque.\cite{ITEM-2}
}

\clearpage

\end{document}
Loading

0 comments on commit a5f17a4

Please sign in to comment.