-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathabnt.tmac
More file actions
177 lines (177 loc) · 5.48 KB
/
abnt.tmac
File metadata and controls
177 lines (177 loc) · 5.48 KB
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
.\" SPDX-FileCopyrightText: Copyright (c) 2025 Bento Borges Schirmer
.\" SPDX-License-Identifier: MIT
.\"
.\" Isso aqui tenta implementar parte do ABNT NBR 10520 : 2002
.\" Ver comentarios para entender funcionamento.
.\"
.\"
.\" Usage: .Referencia <Mnemonic> <Authorship> [e][u]
.\" [<UppercaseAuthorship> if u] <Year>
.\"
.\" TODO Version where <Authorship> is ommited (uses <Mnemonic>).
.\" TODO Make so that it checks that at least one citation otherwise
.\" abort or warn
.\" TODO Abort when mnemonic repeated namespace
.\" TODO Statistics proven ergonomy
.\" TODO Automated "A,B e C" and "A;B;C": cringe or based?
.\" Make it optional
.\"
.\" Mass replacing a mnemonic will be a PITA if it is also a word that
.\" appears in free text, or if it is the prefix of another mnemonic.
.\"
.\" e flag enables et al. which must NOT be present in <Authorship>.
.\" u flag allows to write custom uppercase version. (handles 6.1.2)
.\"
.\" Transparent output for actual bibliography entry must follow.
.\" Call many times to specify entries consecutively.
.\" The macro .<Mnemonic> [args] or \*[Mnemonic args] becomes available.
.\"
.\" Usage: .Referencia OFF|X|END|<anything>
.\" Must be called to "close" after last consecutive entry.
.\"
.\" Once you are done, the diversion .Bibliografia becomes available.
.\" Just like any other diversion, you can .rm Bibliografia to reset
.\" the list
.de Referencia
. ds SomeReferencia
.\". if '\\n[.z]'Bibliografia' .nop \!.SP
. if 1=\\n[.$] \{\
.\". nop \!.SP
. da
. return
. \}
. if dSomeReferencia .nop \!.SP
. als \\$1 Citacao
. ds \\$1_AUTOR \\$2
. if (4=\\n(.$):(5=\\n(.$) \{\
. if 'e'\\$3' \{\
. ds \\$1_ET_AL " et al.
. nr Localish_OKAY 1
. \}
. if 'u'\\$3' \{\
. ds \\$1_CUSTOM_UPPER \\$4
. nr Localish_OKAY 1
. \}
. if 'eu'\\$3' \{\
. ds \\$1_ET_AL " et al.
. ds \\$1_CUSTOM_UPPER \\$4
. nr Localish_OKAY 1
. \}
. if 'ue'\\$3' \{\
. ds \\$1_ET_AL " et al.
. ds \\$1_CUSTOM_UPPER \\$4
. nr Localish_OKAY 1
. \}
. if !r Localish_OKAY .ab \n(.F:\n(.c:Expected some option e or u
. rr Localish_OKAY
. \}
. ds \\$1_ANO \\$[\\n(.$]
. if !'\\n[.z]'Bibliografia' .da Bibliografia
. nop \!.PP
..
.\" Usage: .<Mnemonic> [i|[[a][m]][t][p|c][g|G]
.\" [<text before apud> if a]
.\" [<page number(s)> if p]
.\" [<custom location> if c]
.\"
.\" NOT directly called. Use the mnemonic provided to .Referencia.
.\" If interpolated without parameters, actually pass "" as parameter.
.\"
.\" Flags:
.\" t Adds ", traducao nossa" before closing parenthesis.
.\" i Means "inline" and will place <Authorship> "outside"
.\" without uppercase.
.\" p Prefixes "p.\~" before page numbers.
.\" c Is custom location such as "vol.\~3, p.\~78" or a
.\" percentage or a video timestamp.
.\" a Means that apud is in effect.
.\" m Fuses current citation with next citation
.\" this option is smartish, try and see it.
.\" g Adds ", grifo nosso" before closing parenthesis.
.\" G Adds ", grifo do autor" before closing parenthesis.
.\"
.\" Flags i and a don't make sense together.
.\" Flags i and m are mutually exclusive.
.\" Flags p and c are mutually exclusive.
.\" Flags g and G are mutually exclusive.
.\" Flag i can't be used if previous call used flag m
.\"
.\" If <text before apud> is empty (i.e. just ""), the opening
.\" parenthesis and the keyword apud are output together without
.\" interveining space.
.\"
.\" Invalid options are silently ignored, because I'm lazy.
.de Citacao
\c
. if 0=\\n[.$] .if !d \\$0_AUTOR \
. ab \n(.F:\n(.c:Pass "" as paramater when interpolating without parameters
. ds Localish_flags \\$1
. shift
. while !'\\*[Localish_flags]'' \{\
. ds Localish_flag \\*[Localish_flags]
. substring Localish_flag -1 -1
. nr Localish_\\*[Localish_flag] 1
. chop Localish_flags
. \}
. \" Checks
. if \\n[Localish_i]&\\n[Localish_m] \
. ab \n(.F:\n(.c:Flags i and m can't go together
. if \\n[Localish_i]&\\n[Localish_m_previous] \
. ab \n(.F:\n(.c:Can't use flag i if m was used in previous call
. if \\n[Localish_p]&\\n[Localish_c] \
. ab \n(.F:\n(.c:Flags p and c can't go together
. if \\n[Localish_g]&\\n[Localish_G] \
. ab \n(.F:\n(.c:Flags g and G can't go together
. \" Opening parenthesis
. if !\\n[Localish_i]:\\n[Localish_m_previous] .nop (\c
. \" Place apud
. if \\n[Localish_a] \{\
. if \\n[Localish_m_previous] .nop ;
. if !'\\$1'' .nop \\$1
. nop apud
. shift
. \}
. \" Place authorship
. ie \\n[Localish_m_previous]<=0:\\n[Localish_a] .PlaceAuthorship \\$0
. el \{.if !'\\*[\\$0_AUTOR]'\\*[Localish_previous_authorship]' \{\
. nop ;
. PlaceAuthorship \\$0
. \}\}
. \" Remainder
. ie \\n[Localish_i] .nop (\\*[\\$0_ANO]\c
. el . nop , \\*[\\$0_ANO]\c
. if \\n[Localish_p] , p.\~\\$1\c
. if \\n[Localish_c] , \\$1\c
. if \\n[Localish_t] , tradu\(,c\(~ao nossa\c
. if \\n[Localish_g] , grifo nosso\c
. if \\n[Localish_G] , grifo do autor\c
. if !\\n[Localish_m] .nop )\c
. \" Cleanup
. ie \\n[Localish_m] \{\
. nr Localish_m_previous 1
. ds Localish_previous_authorship \\*[\\$0_AUTOR]
. \}
. el \{\
. rr Localish_m_previous
. rm Localish_previous_authorship
. \}
. rr Localish_i
. rr Localish_a
. rr Localish_t
. rr Localish_p
. rr Localish_c
. rr Localish_m
. rr Localish_g
. rr Localish_G
..
.\" INTERNAL STUFF. Not intended to be used directly.
.de PlaceAuthorship
. ie \\n[Localish_i] .nop \\*[\\$1_AUTOR]\\*[\\$1_ET_AL]
. el \{\
. ie d \\$1_CUSTOM_UPPER .nop \\*[\\$1_CUSTOM_UPPER]\\*[\\$1_ET_AL]\c
. el \{\
. nop \*[UC]\\*[\\$1_AUTOR]\*[LC]\\*[\\$1_ET_AL]\c
. \}
. \}
..
.\" vim:syntax=groff tw=70