diff options
author | Gustav Eek <gustav.eek@fripost.org> | 2019-09-30 17:31:42 +0200 |
---|---|---|
committer | Gustav Eek <gustav.eek@fripost.org> | 2019-09-30 17:31:42 +0200 |
commit | 8c7611e5cae75c1bf448b74fcf2262f3e54642c6 (patch) | |
tree | 80232865a42c80d12a3942671d75b2dc18923d62 /.ikiwiki | |
parent | 4f13e2e782706c205e1a2129a15bb4ad80809f49 (diff) |
Further debug output from pandoc plugin
Diffstat (limited to '.ikiwiki')
-rwxr-xr-x | .ikiwiki/IkiWiki/Plugin/pandoc.pm | 115 |
1 files changed, 75 insertions, 40 deletions
diff --git a/.ikiwiki/IkiWiki/Plugin/pandoc.pm b/.ikiwiki/IkiWiki/Plugin/pandoc.pm index f6f3b02..a7def67 100755 --- a/.ikiwiki/IkiWiki/Plugin/pandoc.pm +++ b/.ikiwiki/IkiWiki/Plugin/pandoc.pm @@ -11,10 +11,26 @@ use File::Path qw/make_path/; use JSON; use Data::Dumper; -open(my $fh, '>', '/tmp/pandoc-verify') or die "Could not"; +my $fh = undef; +my $dh = undef; +my $fnm = undef; +my $f = undef; +my $next = 0; +my $base = '/tmp/pandoc'; + +mkdir($base); +opendir($dh, $base) || die "Can't open $base: $!"; +foreach $f (grep(/[0-9][0-9]*$/, readdir($dh))) { + $f =~ /^(.*)-([0-9][0-9]*)$/; + $next = $2 + 1 if ($2 >= $next); +} +closedir $dh; +$fnm = sprintf "%s/%s-%.3d", $base, "verify", $next; +open($fh, '>', $fnm) or die "Could not"; print $fh "Hej du glade på fil\n"; +print $fh "Detta är filen i '/home/gustav/git/fripost/wiki/.ikiwiki/IkiWiki/Plugin'\n"; close $fh; -print "Hej du glade på print\n"; +print "Closed $fnm\n"; # activate with 'generate_$format' in meta; turn on all with 'generate_all_formats'. my %extra_formats = ( @@ -29,12 +45,17 @@ my %extra_formats = ( sub import { - open(my $fh2, '>', '/tmp/pandoc-import') or die "Could not"; - print $fh2 "I import på fil\n"; - close $fh2; - - open(my $fh6, '>', '/tmp/pandoc-htmlize-end') or die "Could not"; - close $fh6; + opendir($dh, $base) || die "Can't open $base: $!"; + foreach $f (grep(/[0-9][0-9]*$/, readdir($dh))) { + $f =~ /^(.*)-([0-9][0-9]*)$/; + $next = $2 + 1 if ($2 >= $next); + } + closedir $dh; + $fnm = sprintf "%s/%s-%.3d", $base, "import", $next; + open($fh, '>', $fnm) or die "Could not open $fnm ."; + print $fh "Import.\n"; + close $fh; + print "Closed $fnm\n"; my $markdown_ext = $config{pandoc_markdown_ext} || "mdwn"; @@ -360,10 +381,11 @@ sub getsetup () { sub htmlize ($@) { - open(my $fh3, '>', '/tmp/pandoc-htmlize') or die "Could not"; - print $fh3 "I htmlize på fil\n"; - close $fh3; - print "I htmlize på print\n"; + opendir($dh, $base) || die "Can't open $base: $!"; + foreach $f (grep(/[0-9][0-9]*$/, readdir($dh))) { + $f =~ /^(.*)-([0-9][0-9]*)$/; + $next = $2 + 1 if ($2 >= $next); + } my $format = shift; my %params = @_; @@ -373,6 +395,12 @@ sub htmlize ($@) { local(*PANDOC_IN, *JSON_IN, *JSON_OUT, *PANDOC_OUT); my @args = (); + $fnm = sprintf "%s/%s-%.3d", $base, "htmlize", $next; + open($fh, '>', $fnm) or die "Could not"; + print $fh Dumper($page), "\n"; + close $fh; + print "Closed $fnm\n"; + # The default assumes pandoc is in PATH my $command = $config{pandoc_command} || "pandoc"; @@ -451,11 +479,9 @@ sub htmlize ($@) { $content =~ s{<div class="inline" id="(\d+)"></div>} {::INLINE::PLACEHOLDER::$1::}g; - open(my $fh9, '>>', '/tmp/pandoc-content'); - print $fh9 '-----------\n'; - print $fh9 Dumper($content); - print $fh9 '\n'; - close $fh9; + $fnm = sprintf "%s/%s-%.3d", $base, "content-1", $next; + open($fh, '>>', $fnm); + print $fh Dumper($content), "\n"; print PANDOC_OUT $content; close PANDOC_OUT; @@ -478,6 +504,12 @@ sub htmlize ($@) { warn "WARNING: Unexpected format for meta block. Incompatible version of Pandoc?\n"; } + print $fh Data::Dumper->Dump([$json_content], [qw(json_content)]), "\n"; + print $fh Data::Dumper->Dump([$decoded_json], [qw(decoded_json)]), "\n"; + print $fh Data::Dumper->Dump([$meta], [qw(meta)]), "\n"; + close $fh; + print "Closed $fnm\n"; + # Get some selected meta attributes, more specifically: # (title date bibliography csl subtitle abstract summary description # version lang locale references author [+ num_authors primary_author]), @@ -486,17 +518,23 @@ sub htmlize ($@) { my @format_keys = grep { $_ ne 'pdf' } keys %extra_formats; my %scalar_meta = map { ($_=>undef) } qw( title date bibliography csl subtitle abstract summary - description version lang locale); - - open(my $fh4, '>', '/tmp/pandoc-out') or die "Could not"; - print $fh4 "Dumpa här på fil\n"; - print $fh4 Dumper(\%scalar_meta); - close $fh4; + description version lang locale + titlesort tag tags + ); $scalar_meta{$_.'_template'} = undef for @format_keys; my %bool_meta = map { ("generate_$_"=>0) } keys %extra_formats; my %list_meta = map { ($_=>[]) } qw/author references/; $list_meta{$_.'_extra_options'} = [] for @format_keys; + + $fnm = sprintf "%s/%s-%.3d", $base, "meta", $next; + open($fh, '>', $fnm) or die "Could not"; + print $fh Data::Dumper->Dump([\%scalar_meta], [qw(scalar_meta)]), "\n"; + print $fh Data::Dumper->Dump([\%bool_meta], [qw(bool_meta)]), "\n"; + print $fh Data::Dumper->Dump([\%list_meta], [qw(list_meta)]), "\n"; + close $fh; + print "Closed $fnm\n"; + my $have_bibl = 0; foreach my $k (keys %scalar_meta) { next unless $meta->{$k}; @@ -618,12 +656,6 @@ sub htmlize ($@) { my @html = <PANDOC_IN>; - open(my $fh8, '>>', '/tmp/pandoc-pandocin') or die "Could not"; - print $fh8 "\n-------\n"; - print $fh8 Dumper(<PANDOC_IN>); - print $fh8 "\n"; - close $fh8; - close PANDOC_IN; waitpid $to_html_pid, 0; @@ -634,17 +666,20 @@ sub htmlize ($@) { $content =~ s{::INLINE::PLACEHOLDER::(\d+)::} {<div class="inline" id="$1"></div>}g; - open(my $fh5, '>>', '/tmp/pandoc-htmlize-end') or die "Could not"; - print $fh5 "\n-------\n"; - print $fh5 Dumper(\%scalar_meta); - print $fh5 "\n"; - close $fh5; - - open(my $fh0, '>>', '/tmp/pandoc-content-2'); - print $fh0 '-----------\n'; - print $fh0 Dumper($content); - print $fh0 '\n'; - close $fh0; + $fnm = sprintf "%s/%s-%.3d", $base, "meta", $next; + open($fh, '>>', $fnm) or die "Could not"; + print $fh "\n"; + print $fh Data::Dumper->Dump([\%scalar_meta], [qw(scalar_meta)]), "\n"; + print $fh Data::Dumper->Dump([\%bool_meta], [qw(bool_meta)]), "\n"; + print $fh Data::Dumper->Dump([\%list_meta], [qw(list_meta)]), "\n"; + close $fh; + print "Closed $fnm\n"; + + $fnm = sprintf "%s/%s-%.3d", $base, "content-2", $next; + open($fh, '>>', $fnm); + print $fh Dumper($content), "\n"; + close $fh; + print "Closed $fnm\n"; return $content; } |