-
Notifications
You must be signed in to change notification settings - Fork 0
/
emojicite.sty
101 lines (92 loc) · 3.06 KB
/
emojicite.sty
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
%%
%% Copyright (C) 2020 by Leon Sixt <[email protected]>
%%
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either
%% version 1.3c of this license or (at your option) any later
%% version. The latest version of this license is in:
%%
%% http://www.latex-project.org/lppl.txt
%%
%% and version 1.3 or later is part of all distributions of
%% LaTeX version 2005/12/01 or later.
%%
%% This work has the LPPL maintenance status `maintained'.
%%
%% The Current Maintainer of this work is Leon Sixt.
%%
\NeedsTeXFormat{LaTeX2e}[2020/02/02]
\ProvidesExplPackage{emoji}{2020/05/13}{0.3}{Add Emojis to Citations (in LuaLaTeX)}
\usepackage{emoji}
\usepackage{natbib}
\usepackage{xparse}
\ExplSyntaxOn
\makeatletter
\NewDocumentCommand{\emojicite}{m}
{
\emojicite_multicitep:n { #1 }
}
\makeatother
\makeatletter
\NewDocumentCommand{\emojicitep}{m}
{
\NAT@open
\emojicite_multicitep:n { #1 }
\NAT@close
}
\makeatother
\seq_new:N \l_emojicite_multicite_in_seq
\seq_new:N \l_emojicite_multicite_out_seq
\seq_new:N \l_emojicite_cite_seq
\cs_new_protected:Npn \emojicite_multicitep:n #1
{
\seq_set_split:Nnn \l_emojicite_multicite_in_seq { ; } { #1 }
\seq_clear:N \l_emojicite_multicite_out_seq
\seq_map_inline:Nn \l_emojicite_multicite_in_seq
{
\emojicite_cite_process:n { ##1 }
}
\seq_use:Nn \l_emojicite_multicite_out_seq { ;~ }
}
\cs_new_protected:Npn \emojicite_cite_process:n #1
{
\seq_set_split:Nnn \l_emojicite_cite_seq { , } { #1 }
\int_compare:nTF { \seq_count:N \l_emojicite_cite_seq == 1 }
{
\seq_put_right:Nn \l_emojicite_multicite_out_seq
{ \citeauthor{#1},~\citeyear{#1} }
}
{
\int_compare:nTF { \seq_count:N \l_emojicite_cite_seq == 2 }
{
\seq_put_right:Nx \l_emojicite_multicite_out_seq
{
\exp_not:N \citeauthor{\seq_item:Nn \l_emojicite_cite_seq { 1 }},~
\exp_not:N \citeyear{\seq_item:Nn \l_emojicite_cite_seq { 1 }}~
\emoji{\seq_item:Nn \l_emojicite_cite_seq { 2 }}
}
}
% we can handle up to 2 emojis
{
\int_compare:nTF { \seq_count:N \l_emojicite_cite_seq == 3 }
{
\seq_put_right:Nx \l_emojicite_multicite_out_seq
{
\exp_not:N \citeauthor{\seq_item:Nn \l_emojicite_cite_seq { 1 }},~
\exp_not:N \citeyear{\seq_item:Nn \l_emojicite_cite_seq { 1 }}~
\emoji{\seq_item:Nn \l_emojicite_cite_seq { 2 }}
\emoji{\seq_item:Nn \l_emojicite_cite_seq { 3 }}
}
}
{
\seq_put_right:Nx \l_emojicite_multicite_out_seq
{
\exp_not:N \citeauthor{\seq_item:Nn \l_emojicite_cite_seq { 1 }},~
\exp_not:N \citeyear{\seq_item:Nn \l_emojicite_cite_seq { 1 }}~
\exp_not:N \textbf{emojicite~does~not~support~more~than~two~emojis}.
}
}
}
}
}
\ExplSyntaxOff