Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mooc-rr-ressources
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Learning Lab
mooc-rr-ressources
Commits
d96f0eae
Commit
d96f0eae
authored
Mar 22, 2019
by
Arnaud Legrand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Have a single script to handle both org and md conversion
parent
42a2a7dd
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
25 deletions
+35
-25
.gitlab-ci.yml
.gitlab-ci.yml
+6
-10
pandoc_fixer.pl
bin/pandoc_fixer.pl
+29
-15
No files found.
.gitlab-ci.yml
View file @
d96f0eae
...
@@ -3,19 +3,15 @@ pages:
...
@@ -3,19 +3,15 @@ pages:
stage
:
deploy
stage
:
deploy
script
:
script
:
-
pandoc --version
-
pandoc --version
-
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")
$(find -name "*.org")
; 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}
;
bin/pandoc_fixer.pl ${file} > ${file}.new;
mkdir -p public/`dirname ${file}`
mv ${file
}.new ${file%.*}.html;
mv ${file
%.*}.html public/`dirname ${file}`
done
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
-
shopt -s extglob
-
mv !(public) public
#
- mv !(public) public
artifacts
:
artifacts
:
paths
:
paths
:
-
public
-
public
...
...
bin/pandoc_fixer.pl
View file @
d96f0eae
#!/usr/bin/perl -w
#!/usr/bin/perl -w
use
strict
;
use
strict
;
if
(
$#ARGV
!=
0
)
{
my
(
$usage
)
=
"Usage: pandox_fixer.pl input.md"
;
die
"Usage: pandox_fixer.pl input.md"
;
(
$#ARGV
==
0
)
or
die
$usage
;
}
my
(
$input
)
=
shift
(
@ARGV
);
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`
;
my
(
$gitdate
)
=
`git log $input | grep Date | head -n 1`
;
chomp
(
$gitdate
);
chomp
(
$gitdate
);
$gitdate
=~
s/Date: *//g
;
$gitdate
=~
s/Date: *//g
;
$gitdate
=~
s/\s*\+.*$//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/
;
########### URL Fixing ###############
open
INPUT
,
$input
or
die
;
my
(
$input_path
)
=
$input
;
my
(
$input_path
)
=
$input
;
$input_path
=~
s
|
/[^/
]
*
$|
|
g
;
$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
(
$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/"
;
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!
# $line =~ s|https://gitlab.inria.fr/learninglab/|https://learninglab.gitlabpages.inria.fr/|g; ## Not such a good idea!
if
(
$input
=~
/_fr.html/
)
{
if
(
$input
=~
/_fr.html/
)
{
$line
=~
s
|<
body
>|<
body
>
Les
<
a
href
=
'$gitlab_origin/$input'
>
sources
de
ce
document
sont
disponibles
sur
gitlab
</
a
>.|
g
;
$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>)) {
...
@@ -48,6 +62,6 @@ while(defined($line=<INPUT>)) {
# $line = "\t".$line;
# $line = "\t".$line;
# }
# }
if
(
$line
=~
/<p>AUTHOR:/
)
{
next
;
}
if
(
$line
=~
/<p>AUTHOR:/
)
{
next
;
}
print
$line
;
print
OUTPUT
$line
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment