@@ -26,6 +26,12 @@ local function is_empty(s)
26
26
return s == nil or s == ' '
27
27
end
28
28
29
+ local function github_uri (text , uri )
30
+ if not is_empty (uri ) and not is_empty (text ) then
31
+ return pandoc .Link (text , uri )
32
+ end
33
+ end
34
+
29
35
local github_repository = nil
30
36
31
37
function get_repository (meta )
@@ -75,7 +81,7 @@ function issues(elem)
75
81
end
76
82
end
77
83
78
- return uri , text
84
+ return github_uri ( text , uri )
79
85
end
80
86
81
87
function commits (elem )
@@ -117,18 +123,39 @@ function commits(elem)
117
123
end
118
124
end
119
125
120
- return uri , text
126
+ return github_uri ( text , uri )
121
127
end
122
128
123
- function github (elem )
124
- uri , text = issues (elem )
125
- if not is_empty (uri ) and not is_empty (text ) then
126
- return pandoc .Link (text , uri )
129
+ function mentions (elem )
130
+ local uri = nil
131
+ local text = nil
132
+ if elem .text :match (" ^@(%w+)$" ) then
133
+ local mention = elem .text :match (" ^@(%w+)$" )
134
+ uri = " https://github.com/" .. mention
135
+ text = pandoc .utils .stringify (elem .text )
127
136
end
128
137
129
- uri , text = commits (elem )
130
- if not is_empty (uri ) and not is_empty (text ) then
131
- return pandoc .Link (text , uri )
138
+ return github_uri (text , uri )
139
+ end
140
+
141
+ function github (elem )
142
+ local link = nil
143
+ if is_empty (link ) then
144
+ link = issues (elem )
145
+ end
146
+
147
+ if is_empty (link ) then
148
+ link = commits (elem )
149
+ end
150
+
151
+ -- if is_empty(link) then
152
+ -- link = mentions(elem)
153
+ -- end
154
+
155
+ if is_empty (link ) then
156
+ return elem
157
+ else
158
+ return link
132
159
end
133
160
end
134
161
0 commit comments