diff options
author | Sigrid <ftrvxmtrx@gmail.com> | 2021-01-19 15:04:40 +0100 |
---|---|---|
committer | Sigrid <ftrvxmtrx@gmail.com> | 2021-01-19 15:04:40 +0100 |
commit | 67c15c1e4794103dc3eeb8d76ed0b5e39b321780 (patch) | |
tree | 5f7fb77a117141fd9f85d787ae1b98be80de09a1 | |
parent | 8781283fbdffc5f362c64791d5c0f0f641010b34 (diff) | |
download | plan9front-67c15c1e4794103dc3eeb8d76ed0b5e39b321780.tar.xz |
mothra: linkify text starting with gemini:// and ftp://
-rw-r--r-- | sys/src/cmd/mothra/rdhtml.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/sys/src/cmd/mothra/rdhtml.c b/sys/src/cmd/mothra/rdhtml.c index 4a6456fc3..7c02182e0 100644 --- a/sys/src/cmd/mothra/rdhtml.c +++ b/sys/src/cmd/mothra/rdhtml.c @@ -35,6 +35,16 @@ struct Fontdata{ "lucidasans/typeunicode.16", 0, 0, }; +static struct{ + char *prefix; + int len; +}links[]={ + {"http://", 7}, + {"https://", 8}, + {"gemini://", 9}, + {"ftp://", 6}, +}; + Font *pl_whichfont(int f, int s, int *space){ char name[NNAME]; @@ -296,12 +306,12 @@ int entchar(int c){ /* return url if text token looks like a hyperlink */ char *linkify(char *s){ + int i; if(s == 0 && s[0] == 0) return 0; - if(!cistrncmp(s, "http://", 7)) - return strdup(s); - if(!cistrncmp(s, "https://", 8)) - return strdup(s); + for(i = 0; i < nelem(links); i++) + if(!cistrncmp(s, links[i].prefix, links[i].len)) + return strdup(s); if(!cistrncmp(s, "www.", 4)){ int d, i; |