Skip to content
Browse files

Refactored filename munger, fixed a bug with single page output where…

… ordering was not being respected.
  • Loading branch information...
1 parent d41c74a commit b64f9841e95eedcbdfaf3cb2e9817e6a00a032e2 @davebalmer committed Nov 3, 2010
Showing with 24 additions and 10 deletions.
  1. +24 −10 jodoc
View
34 jodoc
@@ -19,6 +19,7 @@ my $template_html = do { local $/; <DATA> };
my %h1s = ();
my %processed = ();
my %files_to_h1s = ();
+my @fileset = ();
my $result = GetOptions(
"markdown|m=s" => \$markdown_bin,
@@ -257,19 +258,26 @@ sub toclinker {
sub munge {
my %munged_processed = ();
for my $file ( keys %processed ) {
- my @path_parts = split( m{/}, $file );
- s{^\.+}{}g for @path_parts;
-
- # Remove empty path parts, looks prettier that way
- @path_parts = grep { $_ ne "" } @path_parts;
- my $path = join( '_', @path_parts );
- my $munged = $path . '.html';
- $munged_processed{$munged} = $processed{$file};
+ $munged_processed{munge_filename($file)} = $processed{$file};
}
%processed = %munged_processed;
return;
}
+sub munge_filename {
+ my $file = shift;
+
+ my @path_parts = split( m{/}, $file );
+ s{^\.+}{}g for @path_parts;
+
+ # Remove empty path parts, looks prettier that way
+ @path_parts = grep { $_ ne "" } @path_parts;
+ my $path = join( '_', @path_parts );
+ my $munged = $path . '.html';
+
+ return $munged;
+}
+
# Create a JSON output of the index
sub index_to_json {
my @keywords = keys %h1s;
@@ -293,7 +301,7 @@ sub main {
if ( $use_tidy && !( -x $tidy_bin ) );
# Slurp all the files and process them
- # recurse current directory if no input arguments
+ # recurse current directory if no input arguments
my @files = @ARGV;
@files = glob("./*") unless ( $ARGV[0] );
for my $file (@files) {
@@ -322,6 +330,7 @@ sub main {
$content = markdown_pipe($content);
}
$processed{$file} = $content;
+ push(@fileset, munge_filename($file));
}
}
@@ -374,7 +383,12 @@ sub main {
# Print to stdout
else {
- my $tempout = join( "", values %processed );
+ my $tempout = '';
+
+ for my $i (@fileset) {
+ $tempout .= $processed{$i};
+ }
+# my $tempout = join( "", values %processed );
$tempout = html_head($tempout) . indexer;
if ($use_tidy) {
$tempout = tidy_pipe($tempout);

0 comments on commit b64f984

Please sign in to comment.
Something went wrong with that request. Please try again.