-
Notifications
You must be signed in to change notification settings - Fork 119
Expand file tree
/
Copy pathRefs.lean
More file actions
257 lines (210 loc) · 5.34 KB
/
Copy pathRefs.lean
File metadata and controls
257 lines (210 loc) · 5.34 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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
/-
Copyright (c) 2023 Lean FRO LLC. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: Rob Simmons
-/
import Verso
namespace Verso.RefsTest
set_option guard_msgs.diff true
/- ----- -/
#docs (.none) regularLink "Regular link" :=
:::::::
Here's [a link](http://example.com)
:::::::
/--
info: Verso.Doc.Part.mk
#[Verso.Doc.Inline.text "Regular link"]
"Regular link"
none
#[Verso.Doc.Block.para
#[Verso.Doc.Inline.text "Here's ",
Verso.Doc.Inline.link #[(Verso.Doc.Inline.text "a link")] "http://example.com"]]
#[]
-/
#guard_msgs in
#eval regularLink.force
/- ----- -/
#docs (.none) refLink "Ref link" :=
:::::::
Here's [a link][to here]
[to here]: http://example.com
:::::::
/--
info: Verso.Doc.Part.mk
#[Verso.Doc.Inline.text "Ref link"]
"Ref link"
none
#[Verso.Doc.Block.para
#[Verso.Doc.Inline.text "Here's ",
Verso.Doc.Inline.link #[(Verso.Doc.Inline.text "a link")] "http://example.com"]]
#[]
-/
#guard_msgs in
#eval refLink.force
/- ----- -/
#docs (.none) noteLink "Footnote" :=
:::::::
Here's something that needs context[^note]!
[^note]: The footnote text
:::::::
/--
info: Verso.Doc.Part.mk
#[Verso.Doc.Inline.text "Footnote"]
"Footnote"
none
#[Verso.Doc.Block.para
#[Verso.Doc.Inline.text "Here's something that needs context",
Verso.Doc.Inline.footnote "note" #[(Verso.Doc.Inline.text "The footnote text")], Verso.Doc.Inline.text "!"]]
#[]
-/
#guard_msgs in
#eval noteLink.force
/- ----- -/
instance : BEq (Doc.Part Doc.Genre.none) where
beq x y := BEq.beq (self := Doc.instBEqPart) x y
#docs (.none) refAndLink "Ref/link ordering" :=
:::::::
[to here]: http://example.com
Here's [a link][to here][^note]!
[^note]: The footnote text
:::::::
/--
info: Verso.Doc.Part.mk
#[Verso.Doc.Inline.text "Ref/link ordering"]
"Ref/link ordering"
none
#[Verso.Doc.Block.para
#[Verso.Doc.Inline.text "Here's ", Verso.Doc.Inline.link #[(Verso.Doc.Inline.text "a link")] "http://example.com",
Verso.Doc.Inline.footnote "note" #[(Verso.Doc.Inline.text "The footnote text")], Verso.Doc.Inline.text "!"]]
#[]
-/
#guard_msgs in
#eval refAndLink.force
#docs (.none) refAndLink2 "Ref/link ordering" :=
:::::::
Here's [a link][to here][^note]!
[to here]: http://example.com
[^note]: The footnote text
:::::::
#docs (.none) refAndLink3 "Ref/link ordering" :=
:::::::
[to here]: http://example.com
[^note]: The footnote text
Here's [a link][to here][^note]!
:::::::
#docs (.none) refAndLink4 "Ref/link ordering" :=
:::::::
[^note]: The footnote text
Here's [a link][to here][^note]!
[to here]: http://example.com
:::::::
/-- info: true -/
#guard_msgs in #eval refAndLink.force == refAndLink2.force
/-- info: true -/
#guard_msgs in #eval refAndLink.force == refAndLink3.force
/-- info: true -/
#guard_msgs in #eval refAndLink.force == refAndLink4.force
#docs (.none) refAndLinkRecursion "Ref/link recursion" :=
:::::::
[^nestedTwice]: C'mon, man.
[^nestedOnce]: A footnote?[^nestedTwice]
[to here]: http://example.com
[^plain]: Footnotes can have recursive footnotes[^nestedOnce] and [links][to here].
Example[^plain]
:::::::
/--
info: Verso.Doc.Part.mk
#[Verso.Doc.Inline.text "Ref/link recursion"]
"Ref/link recursion"
none
#[Verso.Doc.Block.para
#[Verso.Doc.Inline.text "Example",
Verso.Doc.Inline.footnote
"plain"
#[(Verso.Doc.Inline.text "Footnotes can have recursive footnotes"),
(Verso.Doc.Inline.footnote
"nestedOnce"
#[(Verso.Doc.Inline.text "A footnote?"),
(Verso.Doc.Inline.footnote "nestedTwice" #[(Verso.Doc.Inline.text "C'mon, man.")])]),
(Verso.Doc.Inline.text " and "),
(Verso.Doc.Inline.link #[(Verso.Doc.Inline.text "links")] "http://example.com"),
(Verso.Doc.Inline.text ".")]]]
#[]
-/
#guard_msgs in
#eval refAndLinkRecursion.force
/--
error: Already defined link [foo] as 'https://example.com'
-/
#guard_msgs in
#docs (.none) failDupLink "Fail" :=
:::::::
[foo]: https://example.com
[foo]: http://example.com
[Go to foo][foo]!
:::::::
/--
error: Already defined footnote [^note]
-/
#guard_msgs in
#docs (.none) failDupFoot "Fail" :=
:::::::
[^note]: Note
[^note]: Note2
There are no caveats.[^note]
:::::::
/--
error: Footnote reference [^bar] does not have a definition
-/
#guard_msgs in
#docs (.none) failForwardRefFootnote "Fail" :=
:::::::
[^foo]: Disallowing forward reference in footnotes[^bar]
[^bar]: Even though it's defined later
And used[^bar]
:::::::
/--
error: Link reference [bar] does not have a definition
-/
#guard_msgs in
#docs (.none) failForwardRefLink "Fail" :=
:::::::
[^foo]: Disallowing [forward reference in footnotes][bar]
[bar]: http://example.com
[And used][bar]
:::::::
/--
warning: Unused footnote [^hidden]
---
warning: Unused footnote [^baz]
-/
#guard_msgs in
#docs (.none) fail4 "Fail" :=
:::::::
[^baz]: Unused footnote
[^hidden]: Unused footnote
:::::::
/--
error: No definition for footnote [^caveat]
-/
#guard_msgs in
#docs (.none) fail "Fail" :=
:::::::
There's no caveat.[^caveat]
:::::::
/--
warning: Unused link [forlorn]
-/
#guard_msgs in
#docs (.none) warnForlorn "Fail" :=
:::::::
[forlorn]: http://example.com
:::::::
/--
error: No definition for link [fourOhFour]
-/
#guard_msgs in
#docs (.none) failHangingLink "Fail" :=
:::::::
There's no [destination][fourOhFour]
:::::::