Write the current URL to a buffer or file - troyp/edbrowse GitHub Wiki

This simple function writes the URL (or file name) of the current buffer (or the URLs of the links on the current line) to a buffer or file. When writing to a buffer, the function writes the URL after the current line. When writing to a file, the function adds the URL to the end of the file.

#Write the current URL to a buffer or file.
#usage <u [buffer or file]
function:u {
db0
A
if(?) {
h
} else {
#Remove surrounding HTML code.
v/^<br><a href='/fd
,s/^<br><a href='//f
,s/'>$//f
#Replace a character entity reference.
g/^[a-z]+:\/\//fs/&amp;/\&/gf
#Percent encode some reserved characters.
g/^[a-z]+:\/\//fs/%\(?![0-9A-Fa-f]{2}\)/%25/gf
g/^[a-z]+:\/\//fs/!/%21/gf
g/^[a-z]+:\/\//fs/\$/%24/gf
g/^[a-z]+:\/\//fs/'/%27/gf
g/^[a-z]+:\/\//fs/(/%28/gf
g/^[a-z]+:\/\//fs/)/%29/gf
g/^[a-z]+:\/\//fs/*/%2A/gf
g/^[a-z]+:\/\//fs/;/%3B/gf
bw
e~1
if(*) {
eret
w~1@.
} else {
w+ ~0
}
^
}
}