avoid linkifying escaped wikilinks
authorjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Mon, 13 Mar 2006 18:45:38 +0000 (18:45 +0000)
committerjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Mon, 13 Mar 2006 18:45:38 +0000 (18:45 +0000)
doc/bugs.mdwn
doc/todo.mdwn
doc/wikilink.mdwn
ikiwiki

index 2c712de6d33b59afe9b9c41a75ccce32eb94ae63..c9b175453dd3c81714cc50cb9bfc64729c94bf9b 100644 (file)
   replaced with a link to the [[CGI]]?
 * [[ikiwiki]] should go to the same place as [[index]] (on this wiki).
 * There's no way to escape a [[WikiLink]] when discussing one on a wiki.
   replaced with a link to the [[CGI]]?
 * [[ikiwiki]] should go to the same place as [[index]] (on this wiki).
 * There's no way to escape a [[WikiLink]] when discussing one on a wiki.
-* Wikilinks are even expanded in the middle of [[MarkDown]] code blocks,
-  and probably shouldn't be (nor in blockquotes?)
-
-  Hmm, the best way to fix this would be to add WikiLink support into
-  markdown, but that will probably be a bear. I guess the question is how
-  common "[[ ]]" is, and maybe we should just provide a way to escape a
-  wikilink..
index 23ade8cbdca65c9fb0359bb44fcd118ecf72f227..d65991542ce394a324478d571b55e5da2108e674 100644 (file)
@@ -56,16 +56,16 @@ Make the html valid. Add css.
 
 ## sigs
 
 
 ## sigs
 
-Need a way to sign name in page that's easier to type than "-- [[ Joey ]]"
+Need a way to sign name in page that's easier to type than "--\[[Joey]]"
 and that includes the date.
 
 and that includes the date.
 
-What syntax do other wikis use for this? I'm considering "[[ -- ]]" (with
+What syntax do other wikis use for this? I'm considering "\[[--]]" (with
 spaces removed) as it has a nice nmemonic.
 
 OTOH, adding additional syntax for this would be counter to one of the
 design goals for ikiwiki: keeping as much markup as possible out of the
 wiki and not adding nonstandard markup. And it's not significantly hard to
 spaces removed) as it has a nice nmemonic.
 
 OTOH, adding additional syntax for this would be counter to one of the
 design goals for ikiwiki: keeping as much markup as possible out of the
 wiki and not adding nonstandard markup. And it's not significantly hard to
-type "--[[Joey]]", and as to the date, we do have page history.
+type "--\[[Joey]]", and as to the date, we do have page history.
 
 ## recentchanges links to commit diffs
 
 
 ## recentchanges links to commit diffs
 
index 03cb2b3c39f63acd89d5fd2bf814371e11f28c5d..dab5d3ac4c0fdc849cefec715dcf628a9c71651f 100644 (file)
@@ -1,6 +1,9 @@
 WikiLinks provide easy linking between pages of the wiki. To create a
 WikiLinks provide easy linking between pages of the wiki. To create a
-WikiLink, just put the name of the page to link to in double brackets. For
-examples "[[ WikiLink ]]" (without the added whitespace). 
+[[WikiLink]], just put the name of the page to link to in double brackets.
+For example "\[[WikiLink]]".
+
+If you ever need to write something like "\[[WikiLink]] without creating a
+wikilink, just prefix it with a "\", like "\\\\[[WikiLink]]".
 
 Note that there are some special [[SubPage/LinkingRules]] that come into
 play when linking between [[SubPage]]s.
 
 Note that there are some special [[SubPage/LinkingRules]] that come into
 play when linking between [[SubPage]]s.
@@ -8,4 +11,4 @@ play when linking between [[SubPage]]s.
 WikiLinks can be entered in any case you like, the page they link to is
 always lowercased.
 
 WikiLinks can be entered in any case you like, the page they link to is
 always lowercased.
 
-Note that if the file linked to by a WikiLink looks like an image, it will be displayed inline on the page.
\ No newline at end of file
+Note that if the file linked to by a WikiLink looks like an image, it will be displayed inline on the page.
diff --git a/ikiwiki b/ikiwiki
index 4e64e4031d0d5996f68d072d4bac06e6a3aa4da4..111ef54fce0a5c19d3f1ec68da9f2894269eadaf 100755 (executable)
--- a/ikiwiki
+++ b/ikiwiki
@@ -172,7 +172,7 @@ sub findlinks ($) { #{{{
        my $content=shift;
 
        my @links;
        my $content=shift;
 
        my @links;
-       while ($content =~ /$config{wiki_link_regexp}/g) {
+       while ($content =~ /(?<!\\)$config{wiki_link_regexp}/g) {
                push @links, lc($1);
        }
        return @links;
                push @links, lc($1);
        }
        return @links;
@@ -247,7 +247,9 @@ sub linkify ($$) { #{{{
        my $content=shift;
        my $file=shift;
 
        my $content=shift;
        my $file=shift;
 
-       $content =~ s/$config{wiki_link_regexp}/htmllink(pagename($file), $1)/eg;
+       $content =~ s{(\\?)$config{wiki_link_regexp}}{
+               $1 ? "[[$2]]" : htmllink(pagename($file), $2)
+       }eg;
        
        return $content;
 } #}}}
        
        return $content;
 } #}}}