Commit d96f0eae authored by Arnaud Legrand's avatar Arnaud Legrand

Have a single script to handle both org and md conversion

parent 42a2a7dd
......@@ -3,19 +3,15 @@ pages:
stage: deploy
script:
- pandoc --version
- pandoc --help
# - pandoc --help
# - pandoc --list-input-formats # Broken as pandoc dates from 2013 on this image! :(
- for file in $(find -name "*.md"); do
pandoc -s -f gfm -t html -o ${file%.*}.html $file && echo "Exported ${file%.*}.html" && echo "<li><a href='https://learninglab.gitlabpages.inria.fr/mooc-rr/mooc-rr-ressources/${file%.*}.html'>${file%.*}.html</a></li>" >> index.html || echo "ERROR $file";
bin/pandoc_fixer.pl ${file} > ${file}.new;
mv ${file}.new ${file%.*}.html;
- for file in $(find -name "*.md") $(find -name "*.org"); do
bin/pandoc_fixer.pl ${file};
mkdir -p public/`dirname ${file}`
mv ${file%.*}.html public/`dirname ${file}`
done
# The next part is broken because pandoc is way too old on this image :(
# - for file in $(find -name "*.org"); do
# pandoc -s -f org -t html -o ${file%.*}.html $file && echo "Exported ${file%.*}.html" || echo "ERROR $file";
# done
- shopt -s extglob
- mv !(public) public
# - mv !(public) public
artifacts:
paths:
- public
......
#!/usr/bin/perl -w
use strict;
if($#ARGV!=0) {
die "Usage: pandox_fixer.pl input.md";
}
my($usage) = "Usage: pandox_fixer.pl input.md";
($#ARGV==0) or die $usage;
my($input)=shift(@ARGV);
if(!($input =~ /.md$/)) {
die "Usage: pandox_fixer.pl input.md";
}
my($line);
########### 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";
$input =~ s/.md/.html/;
open INPUT, $input or die;
########### URL Fixing ###############
my($input_path)=$input;
$input_path =~ s|/[^/]*$||g;
# print $input."\n\n";
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/";
while(defined($line=<INPUT>)) {
########### 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=<INPUT>)) {
# $line =~ s|https://gitlab.inria.fr/learninglab/|https://learninglab.gitlabpages.inria.fr/|g; ## Not such a good idea!
if($input=~ /_fr.html/) {
$line =~ s|<body>|<body>Les <a href='$gitlab_origin/$input'>sources de ce document sont disponibles sur gitlab</a>.|g;
......@@ -48,6 +62,6 @@ while(defined($line=<INPUT>)) {
# $line = "\t".$line;
# }
if($line =~ /<p>AUTHOR:/) { next; }
print $line;
print OUTPUT $line;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment