summaryrefslogtreecommitdiffstats
path: root/.ikiwiki
diff options
context:
space:
mode:
Diffstat (limited to '.ikiwiki')
-rwxr-xr-x.ikiwiki/IkiWiki/Plugin/pandoc.pm76
1 files changed, 71 insertions, 5 deletions
diff --git a/.ikiwiki/IkiWiki/Plugin/pandoc.pm b/.ikiwiki/IkiWiki/Plugin/pandoc.pm
index cbc9cb7..f6f3b02 100755
--- a/.ikiwiki/IkiWiki/Plugin/pandoc.pm
+++ b/.ikiwiki/IkiWiki/Plugin/pandoc.pm
@@ -9,6 +9,12 @@ use FileHandle;
use IPC::Open2;
use File::Path qw/make_path/;
use JSON;
+use Data::Dumper;
+
+open(my $fh, '>', '/tmp/pandoc-verify') or die "Could not";
+print $fh "Hej du glade på fil\n";
+close $fh;
+print "Hej du glade på print\n";
# activate with 'generate_$format' in meta; turn on all with 'generate_all_formats'.
my %extra_formats = (
@@ -22,6 +28,14 @@ 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;
+
my $markdown_ext = $config{pandoc_markdown_ext} || "mdwn";
# May be both a string with a single value, a string containing commas or an arrayref
@@ -96,6 +110,13 @@ sub getsetup () {
safe => 1,
rebuild => 1,
},
+ pandoc_markdown_fmt => {
+ type => "string",
+ example => "markdown",
+ description => "Format string to use when processing files handled by Pandoc.",
+ safe => 1,
+ rebuild => 1,
+ },
pandoc_latex => {
type => "boolean",
example => 0,
@@ -338,6 +359,12 @@ 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";
+
my $format = shift;
my %params = @_;
my $page = $params{page};
@@ -409,10 +436,11 @@ sub htmlize ($@) {
# can be parsed out
# We must omit the 'bibliography' parameter here, otherwise the list of
# references will be doubled.
+ my $markdown_fmt = $config{pandoc_markdown_fmt} || 'markdown';
my $to_json_pid = open2(*JSON_OUT, *PANDOC_OUT, $command,
- '-f', $format,
+ '-f', $markdown_fmt,
'-t', 'json',
- @args, '--normalize');
+ @args);
error("Unable to open $command") unless $to_json_pid;
# Workaround for perl bug (#376329)
@@ -423,6 +451,12 @@ 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;
+
print PANDOC_OUT $content;
close PANDOC_OUT;
@@ -435,8 +469,8 @@ sub htmlize ($@) {
my $meta = undef;
my $decoded_json = decode_json($json_content);
# The representation of the meta block changed in pandoc version 1.18
- if (ref $decoded_json eq 'HASH' && $decoded_json->{'Meta'}) {
- $meta = $decoded_json->{'Meta'} || {}; # post-1.18 version
+ if (ref $decoded_json eq 'HASH' && $decoded_json->{'meta'}) {
+ $meta = $decoded_json->{'meta'} || {}; # post-1.18 version
} elsif (ref $decoded_json eq 'ARRAY') {
$meta = $decoded_json->[0]->{'unMeta'} || {}; # pre-1.18 version
}
@@ -452,7 +486,13 @@ 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 sortas titlesort tag tags);
+ 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;
+
$scalar_meta{$_.'_template'} = undef for @format_keys;
my %bool_meta = map { ("generate_$_"=>0) } keys %extra_formats;
my %list_meta = map { ($_=>[]) } qw/author references/;
@@ -577,6 +617,13 @@ sub htmlize ($@) {
close JSON_IN;
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;
@@ -587,11 +634,24 @@ 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;
+
return $content;
}
sub pagetemplate (@) {
+
my %params = @_;
my $page = $params{page};
my $template = $params{template};
@@ -602,6 +662,7 @@ sub pagetemplate (@) {
}
sub pageactions {
+
my %args = @_;
my $page = $args{page};
my @links = ();
@@ -624,6 +685,7 @@ sub pageactions {
}
sub export_file {
+
my ($page, $ext, $json_content, $command, @args) = @_;
my ($export_path, $export_url) = _export_file_path_and_url($page, $ext);
my $subdir = $1 if $export_path =~ /(.*)\//;
@@ -708,6 +770,7 @@ sub export_file {
}
sub remove_exported_file {
+
my ($page, $ext) = @_;
my ($export_path, $export_url) = _export_file_path_and_url($page, $ext);
if (-f $export_path) {
@@ -719,6 +782,7 @@ sub remove_exported_file {
}
sub _export_file_path_and_url {
+
my ($page, $ext) = @_;
# the html file will end up in "$destdir/$page/index.html",
# while e.g. a pdf will be in "$destdir/$page/$page_minus_dirs.pdf".
@@ -738,6 +802,7 @@ sub _export_file_path_and_url {
## easier to work with for perl.
sub compile_string {
+
# Partially represents an item from the data structure in meta as a string.
my @uncompiled = @_;
return $uncompiled[0] if @uncompiled==1 && !ref($uncompiled[0]);
@@ -753,6 +818,7 @@ sub compile_string {
return $compiled_string;
}
sub unwrap_c {
+
# Unwrap pandoc's MetaLists, MetaInlines, etc.
# Finds the deepest-level scalar value for 'c' in the data structure.
# Lists with one element are replaced with the scalar, lists with more