#!/usr/bin/perl -w use strict; my($usage) = "Usage: pandox_fixer.pl input.md"; ($#ARGV==0) or die $usage; my($input)=shift(@ARGV); ########### Git date ################# my($gitdate)=`git log $input | grep Date | head -n 1`; chomp($gitdate); $gitdate =~ s/Date: *//g; $gitdate =~ s/\s*\+.*$//g; ########### Input file ############### my($type) = ""; my($output) = $input; if($input =~ /.md$/) { $type = "gfm"; $output =~ s/.md$/.html/; } elsif ($input =~ /.org$/) { $type = "org"; $output =~ s/.org$/.html/; } else { die "Usage: pandox_fixer.pl input.md"; } my($output_temp) = $output."tmp"; ########### URL Fixing ############### my($input_path)=$input; $input_path =~ s|/[^/]*$||g; my($url_path) = "https://gitlab.inria.fr/learninglab/mooc-rr/mooc-rr-ressources/raw/master/".$input_path; my($gitlab_origin)= "https://gitlab.inria.fr/learninglab/mooc-rr/mooc-rr-ressources/blob/master/"; ########### Pandoc ################# print "Exporting $input\n"; my($pandoc_output) = `LANG=C ; pandoc -s -f $type -t html -o $output_temp $input`; open INPUT, $output_temp or die; open OUTPUT, "> ".$output or die; while(defined(my $line=)) { # $line =~ s|https://gitlab.inria.fr/learninglab/|https://learninglab.gitlabpages.inria.fr/|g; ## Not such a good idea! if($input=~ /_fr.html/) { $line =~ s||Les sources de ce document sont disponibles sur gitlab.|g; } else { $line =~ s||The source of this this document is available on gitlab.|g; } $line =~ s|---

|
|g; $line =~ s|Date:.*Date: $gitdateTITLE:\(.*\)TITLE:$1AUTHOR:/) { next; } print OUTPUT $line; }