-
Notifications
You must be signed in to change notification settings - Fork 15
/
utils.jl
66 lines (60 loc) · 1.65 KB
/
utils.jl
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
using BibTeX
function ref_item(ref, infos)
io = IOBuffer()
authors_aux = strip.(split(infos["author"], " and "))
m = size(authors_aux)[1]
authors = ""
for j in 1:m
a = authors_aux[j]
fullname = reverse(strip.(split(a, ",")))
n = size(fullname)[1]
for i in 1:n-1
authors *= fullname[i]*" "
end
authors *= fullname[n]
if j == m
authors *= ". "
else
authors *= ", "
end
end
url = replace(infos["url"], " " => "")
write(io, "<li id=\"#$ref\">")
write(io, """<a href="$url" class="publicationlink">""")
write(io, """$(infos["title"])""")
write(io, " </a><br>")
write(io, """$authors<br>""")
write(io, """$(infos["journal"]) ($(infos["year"])). """)
if haskey(infos, "doi")
write(io, """DOI:$(infos["doi"]). """)
end
write(io, "</li>")
write(io, "<br>")
return String(take!(io))
end
function hfun_show_refs(refs)
_, allrefs = parse_bibtex(read(joinpath("_assets", "julialab.bib"), String))
out = IOBuffer()
write(out, "<ul>")
for ref in refs
infos = get(allrefs, ref, nothing)
isnothing(infos) && continue
write(out, ref_item(ref, infos))
end
write(out, "</ul>")
return String(take!(out))
end
function hfun_bar(vname)
val = Meta.parse(vname[1])
return round(sqrt(val), digits=2)
end
function hfun_m1fill(vname)
var = vname[1]
return pagevar("index", var)
end
function lx_baz(com, _)
# keep this first line
brace_content = Franklin.content(com.braces[1]) # input string
# do whatever you want here
return uppercase(brace_content)
end