Commit 14a8e33e authored by Arnaud Legrand's avatar Arnaud Legrand

Move the processing/sed into a clean perl script

parent 9e816cab
...@@ -6,12 +6,9 @@ pages: ...@@ -6,12 +6,9 @@ pages:
- pandoc --help - pandoc --help
# - pandoc --list-input-formats # Broken as pandoc dates from 2013 on this image! :( # - pandoc --list-input-formats # Broken as pandoc dates from 2013 on this image! :(
- for file in $(find -name "*.md"); do - for file in $(find -name "*.md"); do
pandoc -s -f markdown_github -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"; 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";
sed -i 's|https://gitlab.inria.fr/learninglab/|https://learninglab.gitlabpages.inria.fr/|g' ${file%.*}.html; bin/pandoc_fixer.pl ${file} > ${file}.new;
sed -i "s|<body>|<body>The <a href='https://gitlab.inria.fr/learninglab/mooc-rr/mooc-rr-ressources/blob/master/$file'>original version of this document is available on gitlab</a>.|g" ${file%.*}.html; mv ${file}.new ${file};
sed -i "s|\-\-\-</p>|<hr/>|g" ${file%.*}.html;
sed -i "s|<p>TITLE:\(.*\)<br|<b>TITLE:\1</b><br|g" ${file%.*}.html;
sed -i "s|Date\(.*\)<br|<i>Date\1</i><br|g" ${file%.*}.html;
done done
# The next part is broken because pandoc is way too old on this image :( # The next part is broken because pandoc is way too old on this image :(
# - for file in $(find -name "*.org"); do # - for file in $(find -name "*.org"); do
......
#!/usr/bin/perl -w
use strict;
if($#ARGV!=0) {
die "Usage: pandox_fixer.pl input.md";
}
my($input)=shift(@ARGV);
if(!($input =~ /.md$/)) {
die "Usage: pandox_fixer.pl input.md";
}
my($line);
my($gitdate)=`git log $input | grep Date | head -n 1`;
chomp($gitdate);
$gitdate =~ s/Date: *//g;
$gitdate =~ s/\s*\+.*$//g;
$input =~ s/.md/.html/;
open INPUT, $input or die;
while(defined($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='https://gitlab.inria.fr/learninglab/mooc-rr/mooc-rr-ressources/blob/master/$input'>sources de ce document sont disponibles sur gitlab</a>.|g;
} else {
$line =~ s|<body>|<body>The <a href='https://gitlab.inria.fr/learninglab/mooc-rr/mooc-rr-ressources/blob/master/$input'>source of this this document is available on gitlab</a>.|g;
}
$line =~ s|---</p>|<hr/>|g;
$line =~ s|Date:.*<br|<i>Date: $gitdate</i><br|g;
$line =~ s|<p>TITLE:\(.*\)<br|<b>TITLE:$1</b><br|g;
$line =~ s|href=" ---</p>|<hr/>|g;
if($line =~ /<p>AUTHOR:/) { next; }
print $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