incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r1345725 - /sling/site/tools/conversion/convert_cwiki_markup.pl
Date Sun, 03 Jun 2012 17:55:48 GMT
Author: fmeschbe
Date: Sun Jun  3 17:55:48 2012
New Revision: 1345725

URL: http://svn.apache.org/viewvc?rev=1345725&view=rev
Log:
SLING-2002 Fix link conversion (don't convert http[s]: links to refs....path links)

Modified:
    sling/site/tools/conversion/convert_cwiki_markup.pl

Modified: sling/site/tools/conversion/convert_cwiki_markup.pl
URL: http://svn.apache.org/viewvc/sling/site/tools/conversion/convert_cwiki_markup.pl?rev=1345725&r1=1345724&r2=1345725&view=diff
==============================================================================
--- sling/site/tools/conversion/convert_cwiki_markup.pl (original)
+++ sling/site/tools/conversion/convert_cwiki_markup.pl Sun Jun  3 17:55:48 2012
@@ -23,16 +23,21 @@ unless($dest) {
 }
 
 sub convertURL {
-   my $url = shift;
+   my ($url, $type) = @_;
+
    if($url =~ /^http/) {
       return $url;
    }
+
    $url =~ s/\s/-/g;
    $url =~ s/\W/-/g;
    $url =~ s/--/-/g;
    $url =~ s/--/-/g;
    $url =~ s/-$//g;
-   return lc($url);
+
+    $type = "path" unless $type;
+       
+   return "{{ refs.".lc($url).".$type }}";
 }
 
 open(INP, "<$source");
@@ -159,9 +164,9 @@ foreach my $line (@contents) {
 
       my $newlink;
       if($link) {
-         $newlink = "[$text]({{ refs.".convertURL($link).".path }})";
+         $newlink = "[$text](".convertURL($link).")";
       } else {
-         $newlink = "[$text]({{ refs.".convertURL($text).".path }})";
+         $newlink = "[$text](".convertURL($text).")";
       }
       $line =~ s/\Q$all\E/$newlink/;
    }
@@ -235,7 +240,7 @@ foreach my $line (@contents) {
       
       my $label = $line;
       $label =~ s/.*{excerpt-include:([^}|]*).*/$1/;
-      $label = "{{ refs.".convertURL($label).".headers.excerpt }}";
+      $label = convertURL($label, "headers.excerpt");
       $line =~ s/\Q$all\E/$label/;
    }
    



Mime
View raw message