You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by fm...@apache.org on 2012/05/22 10:10:42 UTC
svn commit: r1341343 - /sling/site/tools/conversion/convert_cwiki_markup.pl
Author: fmeschbe
Date: Tue May 22 08:10:41 2012
New Revision: 1341343
URL: http://svn.apache.org/viewvc?rev=1341343&view=rev
Log:
SLING-2002 Convert links to refs.pagename.path templates instead of real URL links (helps restructuring because view.pm will resolve the actual path).
- Requires Link handling to be after {{...}} to `...` conversion to prevent links to be converted to code
and break markdown processing
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=1341343&r1=1341342&r2=1341343&view=diff
==============================================================================
--- sling/site/tools/conversion/convert_cwiki_markup.pl (original)
+++ sling/site/tools/conversion/convert_cwiki_markup.pl Tue May 22 08:10:41 2012
@@ -32,8 +32,7 @@ sub convertURL {
$url =~ s/--/-/g;
$url =~ s/--/-/g;
$url =~ s/-$//g;
- $url = lc($url).".html";
- return $url;
+ return lc($url);
}
open(INP, "<$source");
@@ -145,6 +144,12 @@ foreach my $line (@contents) {
# $line = "<a name=\"$compressedPageName-$name\"></a>\n".$line;
}
+ # Old-style bold / italic
+ $line =~ s/\{\{(.*?)\}\}/`$1`/g;
+ $line =~ s/_(.*?)_/*$1*/g;
+ # $line =~ s/\{\{(.*?)\}\}/*$1*/g;
+ $line =~ s/\{\{\{(.*?)\}\}\}/**$1**/g;
+
# Links
if($line =~ /(\[(.*?)\])/) {
my ($all,$text,$link) = ($1,$2,"");
@@ -154,19 +159,13 @@ foreach my $line (@contents) {
my $newlink;
if($link) {
- $newlink = "[$text](".convertURL($link).")";
+ $newlink = "[$text]({{ refs.".convertURL($link).".path }})";
} else {
- $newlink = "[$text](".convertURL($text).")";
+ $newlink = "[$text]({{ refs.".convertURL($text).".path }})";
}
$line =~ s/\Q$all\E/$newlink/;
}
- # Old-style bold / italic
- $line =~ s/\{\{(.*?)\}\}/`$1`/g;
- $line =~ s/_(.*?)_/*$1*/g;
- # $line =~ s/\{\{(.*?)\}\}/*$1*/g;
- $line =~ s/\{\{\{(.*?)\}\}\}/**$1**/g;
-
# No-Format
if($line =~ /^\s*^{noformat}/) {
$in = "noformat";
@@ -199,11 +198,11 @@ foreach my $line (@contents) {
# $in = "table";
# }
- my $th = ($line =~ /\|\|/);
- $line =~ s/\|\|/\|/g;
- if ($th) {
- $line .= "|--|--|\n";
- }
+ my $th = ($line =~ /\|\|/);
+ if ($th) {
+ my $count = ($line =~ s/\|\|/\|/g) - 1;
+ $line .= "|" . ("--|" x $count) . "\n";
+ }
}
# Table of contents
@@ -230,13 +229,14 @@ foreach my $line (@contents) {
}
# referenced excerpts -- assume child nodes
- if($line =~ /\{excerpt-include:[^}]*\}/) {
+ if($line =~ /(\{excerpt-include:([^}|]*)[^}]*\})/) {
# {excerpt-include:Authentication - AuthenticationHandler|nopanel=true}
+ my ($all,$text) = ($1,$2);
+
my $label = $line;
$label =~ s/.*{excerpt-include:([^}|]*).*/$1/;
- $label = convertURL($label);
- $label =~ s/\.html//;
- $line =~s /\{excerpt-include:[^}]*\}/[{{ refs.$label.headers.excerpt }}]({{ refs.$label.path }})/;
+ $label = "{{ refs.".convertURL($label).".headers.excerpt }}";
+ $line =~ s/\Q$all\E/$label/;
}
print OUT $line;