X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/d772fc6ad2fd2939789e3fc8a14742dda6bb07e5..62fd4c979e9aa6d55583a6057b4fb8541508cdd4:/doc/patchqueue/format_escape.mdwn?ds=inline diff --git a/doc/patchqueue/format_escape.mdwn b/doc/patchqueue/format_escape.mdwn index 25bbc2854..ba65b7072 100644 --- a/doc/patchqueue/format_escape.mdwn +++ b/doc/patchqueue/format_escape.mdwn @@ -19,29 +19,52 @@ escape parameter optional, and only call it if set. --[[Joey]] >> those. Assuming that escaping html embedded in the middle of a sentence >> works.. --[[Joey]] +>>> Revised again. I get around this by making another hook, htmlescapelink, +>>> which is called to generate links in whatever language. In addition, it +>>> doesn't (can't?) generate +>>> spans, and it doesn't handle inlineable image links. If these were +>>> desired, the approach to take would probably be to use substitution +>>> definitions, which would require generating two bits of code for each +>>> link/html snippet, and putting one at the end of the paragraph (or maybe +>>> the document?). +>>> To specify that (for example) Discussion links are meant to be HTML and +>>> not rst or whatever, I added a "genhtml" parameter to htmllink. It seems +>>> to work -- see for an example. +>>> --Ethan +
 Index: debian/changelog
 ===================================================================
---- debian/changelog	(revision 3158)
+--- debian/changelog	(revision 3197)
 +++ debian/changelog	(working copy)
-@@ -44,8 +44,11 @@
-   * Fix smiley plugin to scan smileys.mdwn after it's updated, which fixes
-     a bug caused by committing changes to smilies.mdwn.
-   * Fix display of escaped wikilinks containing anchors.
+@@ -24,6 +24,9 @@
+     than just a suggests, since OpenID is enabled by default.
+   * Fix a bug that caused link(foo) to succeed if page foo did not exist.
+   * Fix tags to page names that contain special characters.
 +  * Based on a patch by Ethan, add a new htmlescape hook, that is called
 +    when a preprocssor directive emits inline html. The rst plugin uses this
 +    hook to support inlined raw html.
  
-- -- Joey Hess   Fri, 06 Apr 2007 17:17:52 -0400
-+ -- Joey Hess   Fri, 06 Apr 2007 19:19:08 -0400
- 
- ikiwiki (1.48) unstable; urgency=low
- 
+   [ Josh Triplett ]
+   * Use pngcrush and optipng on all PNG files.
+Index: IkiWiki/Render.pm
+===================================================================
+--- IkiWiki/Render.pm	(revision 3197)
++++ IkiWiki/Render.pm	(working copy)
+@@ -96,7 +96,7 @@
+ 		if ($page !~ /.*\/\Q$discussionlink\E$/ &&
+ 		   (length $config{cgiurl} ||
+ 		    exists $links{$page."/".$discussionlink})) {
+-			$template->param(discussionlink => htmllink($page, $page, gettext("Discussion"), noimageinline => 1, forcesubpage => 1));
++			$template->param(discussionlink => htmllink($page, $page, gettext("Discussion"), noimageinline => 1, forcesubpage => 1, genhtml => 1));
+ 			$actions++;
+ 		}
+ 	}
 Index: IkiWiki/Plugin/rst.pm
 ===================================================================
---- IkiWiki/Plugin/rst.pm	(revision 3157)
+--- IkiWiki/Plugin/rst.pm	(revision 3197)
 +++ IkiWiki/Plugin/rst.pm	(working copy)
-@@ -30,15 +30,22 @@
+@@ -30,15 +30,36 @@
  html = publish_string(stdin.read(), writer_name='html', 
         settings_overrides = { 'halt_level': 6, 
                                'file_insertion_enabled': 0,
@@ -53,9 +76,23 @@ Index: IkiWiki/Plugin/rst.pm
  
  sub import { #{{{
  	hook(type => "htmlize", id => "rst", call => \&htmlize);
-+	hook(type => "htmlescape", id => "rst", call => \&htmlecape);
++	hook(type => "htmlescape", id => "rst", call => \&htmlescape);
++	hook(type => "htmlescapelink", id => "rst", call => \&htmlescapelink);
  } # }}}
  
++sub htmlescapelink ($$;@) { #{{{
++	my $url = shift;
++	my $text = shift;
++	my %params = @_;
++
++	if ($params{broken}){
++		return "`? <$url>`_\ $text";
++	}
++	else {
++		return "`$text <$url>`_";
++	}
++} # }}}
++
 +sub htmlescape ($) { #{{{
 +	my $html=shift;
 +	$html=~s/^/  /mg;
@@ -67,9 +104,9 @@ Index: IkiWiki/Plugin/rst.pm
  	my $content=$params{content};
 Index: doc/plugins/write.mdwn
 ===================================================================
---- doc/plugins/write.mdwn	(revision 3157)
+--- doc/plugins/write.mdwn	(revision 3197)
 +++ doc/plugins/write.mdwn	(working copy)
-@@ -121,6 +121,16 @@
+@@ -121,6 +121,26 @@
  The function is passed named parameters: "page" and "content" and should
  return the htmlized content.
  
@@ -82,13 +119,31 @@ Index: doc/plugins/write.mdwn
 +to the htmlize hook, and is called when ikiwiki detects that a preprocessor
 +directive is inserting raw html. It is passed the chunk of html in
 +question, and should return the escaped chunk.
++
++### htmlescapelink
++
++	hook(type => "htmlescapelink", id => "ext", call => \&htmlescapelink);
++
++Some markup languages have special syntax to link to other pages. This hook
++is a companion to the htmlize and htmlescape hooks, and it is called when a
++link is inserted. It is passed the target of the link and the text of the 
++link, and an optional named parameter "broken" if a broken link is being
++generated. It should return the correctly-formatted link.
 +
  ### pagetemplate
  
  	hook(type => "pagetemplate", id => "foo", call => \&pagetemplate);
+@@ -355,6 +375,7 @@
+ * forcesubpage  - set to force a link to a subpage
+ * linktext - set to force the link text to something
+ * anchor - set to make the link include an anchor
++* genhtml - set to generate HTML and not escape for correct format
+ 
+ #### `readfile($;$)`
+ 
 Index: doc/plugins/rst.mdwn
 ===================================================================
---- doc/plugins/rst.mdwn	(revision 3157)
+--- doc/plugins/rst.mdwn	(revision 3197)
 +++ doc/plugins/rst.mdwn	(working copy)
 @@ -10,10 +10,8 @@
  Note that this plugin does not interoperate very well with the rest of
@@ -105,23 +160,54 @@ Index: doc/plugins/rst.mdwn
    sync with the standard version, so is not used.
 Index: IkiWiki.pm
 ===================================================================
---- IkiWiki.pm	(revision 3158)
+--- IkiWiki.pm	(revision 3197)
 +++ IkiWiki.pm	(working copy)
-@@ -550,11 +550,11 @@
- 	$content =~ s{(\\?)$config{wiki_link_regexp}}{
- 		defined $2
- 			? ( $1 
--				? "[[$2|$3".(length $4 ? "#$4" : "")."]]" 
-+				? "[[$2|$3".($4 ? "#$4" : "")."]]" 
- 				: htmllink($lpage, $page, linkpage($3),
- 					anchor => $4, linktext => pagetitle($2)))
- 			: ( $1 
--				? "[[$3".(length $4 ? "#$4" : "")."]]"
-+				? "[[$3".($4 ? "#$4" : "")."]]"
- 				: htmllink($lpage, $page, linkpage($3),
- 					anchor => $4))
- 	}eg;
-@@ -628,6 +628,14 @@
+@@ -469,6 +469,10 @@
+ 	my $page=shift; # the page that will contain the link (different for inline)
+ 	my $link=shift;
+ 	my %opts=@_;
++	# we are processing $lpage and so we need to format things in accordance
++	# with the formatting language of $lpage. inline generates HTML so links
++	# will be escaped seperately.
++	my $type=pagetype($pagesources{$lpage});
+ 
+ 	my $bestlink;
+ 	if (! $opts{forcesubpage}) {
+@@ -494,12 +498,17 @@
+ 	}
+ 	if (! grep { $_ eq $bestlink } map { @{$_} } values %renderedfiles) {
+ 		return $linktext unless length $config{cgiurl};
+-		return " "create",
+-				page => pagetitle(lc($link), 1),
+-				from => $lpage
+-			).
++		my $url = cgiurl(
++				 do => "create",
++				 page => pagetitle(lc($link), 1),
++				 from => $lpage
++				);
++
++		if ($hooks{htmlescapelink}{$type} && ! $opts{genhtml}){
++			return $hooks{htmlescapelink}{$type}{call}->($url, $linktext,
++							       broken => 1);
++		}
++		return "?$linktext"
+ 	}
+ 	
+@@ -514,6 +523,9 @@
+ 		$bestlink.="#".$opts{anchor};
+ 	}
+ 
++	if ($hooks{htmlescapelink}{$type} && !$opts{genhtml}) {
++	  return $hooks{htmlescapelink}{$type}{call}->($bestlink, $linktext);
++	}
+ 	return "$linktext";
+ } #}}}
+ 
+@@ -628,6 +640,14 @@
  				preview => $preprocess_preview,
  			);
  			$preprocessing{$page}--;
@@ -130,7 +216,7 @@ Index: IkiWiki.pm
 +			if ($ret =~ /[<>]/ && $pagesources{$page}) {
 +				my $type=pagetype($pagesources{$page});
 +				if ($hooks{htmlescape}{$type}) {
-+					return $ret = $hooks{htmlize}{$type}{escape}->($ret);
++					return $hooks{htmlescape}{$type}{call}->($ret);
 +				}
 +			}
  			return $ret;