#!/usr/bin/perl -w use strict; my($usage) = "Usage: pandox_fixer.pl org_md_files.lst"; ($#ARGV==0) or die $usage; sub pandoc_export { my($input)=shift(@_); ########### Git date ################# my($gitdate)=`git log --date=short $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($raw_path) = "https://gitlab.inria.fr/learninglab/mooc-rr/mooc-rr-ressources/raw/master/".$input_path; my($raw_path_percent) = $raw_path; $raw_path_percent =~ s/^http/%/g; my($tree_path) = "https://gitlab.inria.fr/learninglab/mooc-rr/mooc-rr-ressources/tree/master/".$input_path; my($pages_path) = "https://learninglab.gitlabpages.inria.fr/mooc-rr/mooc-rr-ressources/".$input_path; my($pages_path_percent) = $pages_path; $pages_path_percent =~ s/^http/%/g; 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 --mathjax -f $type -t html -o $output_temp $input`;open INPUT, $output_temp or die; open OUTPUT, "> ".$output or die; while(defined(my $line=)) { if($line =~ /
/) { if($output=~ /_fr.html/) { $line =~ s||Les sources de ce document sont disponibles sur gitlab.|g; $line .= "