#How to wrap the URL in the bibliography part
15 messages · Page 1 of 1 (latest)
See my answer on https://github.com/typst/typst/issues/1271
Ah, thank you. Ofcourse I should've checked the github issues ❤️
After putting #let mylink(url) = link(url,url.replace("/", "/" + str(sym.zws)).replace("-", "-"+ str(sym.zws)).replace(".", "."+ str(sym.zws)).replace("?", "?"+ str(sym.zws))) in my main it, and putting it in my .bib file it doesn't show the url in the pdf.
As pointed out in the comment below you can achieve the same effect with a show rule
Though I haven't tried
Unfortunately the bibliography block doesn't allow to iterate through the entries, or their url's yet. So I think until then a #show argument won't work
Yeah it’s kinda unfortunate
I think there should be some sort of bibliography.entry thing
Not sure if there is an issue for this already
you can always add the zero width spaces in the bib file, but then the links would presumably not be clickable anymore, which wouldn't be great
unless you have really weird names in there, #show regex("https://[^\s]+") might work
I think I'm almost there. I'm using this, combining some of the info I found, but it doesn't seem to work:
link(url.text,url.text.replace("/", "/" + str(sym.zws)).replace("-", "-"+ str(sym.zws)).replace(".", "."+ str(sym.zws)).replace("?", "?"+ str(sym.zws)))
}```
This does add the extra zero width space, afaik. But that doesn't seem to help with breaking the lines.
I found the solution. I thought it wasn't working but it was, I just had some non https sources. By adding a second regex operator I fixed it :).
#show regex("http://[^\s]+"): url => {
link(url.text,url.text.replace("/", "/" + sym.zws).replace("-", "-"+ sym.zws).replace(".", "."+ sym.zws).replace("?", "?"+ sym.zws))
}
After some cleaning up, I made this function so it adds a zero width space after every letter. But only for the display text, the url destination stays the same:
#let breaklink(url) = link(url, for c in url [#c.replace(c,c+sym.zws)])
#show regex("https://[^\s]+"): url => {
breaklink(url.text)
}
#show regex("http://[^\s]+"): url => {
breaklink(url.text)
}