diff --git a/basis/farkup/farkup-tests.factor b/basis/farkup/farkup-tests.factor
index abee7194a2..7d9c900ec2 100644
--- a/basis/farkup/farkup-tests.factor
+++ b/basis/farkup/farkup-tests.factor
@@ -96,7 +96,7 @@ link-no-follow? off
[ "
int main()
" ]
[ "[c{int main()}]" convert-farkup ] unit-test
-[ "
" ] [ "[[image:lol.jpg]]" convert-farkup ] unit-test
+[ "
" ] [ "[[image:lol.jpg]]" convert-farkup ] unit-test
[ "
" ] [ "[[image:lol.jpg|teh lol]]" convert-farkup ] unit-test
[ "http://lol.com
" ] [ "[[http://lol.com]]" convert-farkup ] unit-test
[ "haha
" ] [ "[[http://lol.com|haha]]" convert-farkup ] unit-test
@@ -207,3 +207,5 @@ link-no-follow? off
[ convert-farkup drop t ] [ drop print f ] recover
] all?
] unit-test
+
+[ "http://foo.com/~foo
" ] [ "[[http://foo.com/~foo]]" convert-farkup ] unit-test
diff --git a/basis/farkup/farkup.factor b/basis/farkup/farkup.factor
index c400457c0b..a008b1d049 100644
--- a/basis/farkup/farkup.factor
+++ b/basis/farkup/farkup.factor
@@ -70,11 +70,15 @@ DEFER: (parse-paragraph)
{ CHAR: % inline-code }
} at ;
+: or-simple-title ( url title/f quot: ( title -- title' ) -- url title' )
+ [ "" like dup simple-link-title ] if* ; inline
+
: parse-link ( string -- paragraph-list )
rest-slice "]]" split1-slice [
"|" split1
- [ "" like dup simple-link-title ] unless*
- [ "image:" ?head ] dip swap [ image boa ] [ parse-paragraph link boa ] if
+ [ "image:" ?head ] dip swap
+ [ [ ] or-simple-title image boa ]
+ [ [ parse-paragraph ] or-simple-title link boa ] if
] dip [ (parse-paragraph) cons ] [ 1list ] if* ;
: ?first ( seq -- elt ) 0 swap ?nth ;