aboutsummaryrefslogtreecommitdiff
path: root/.gitlab-ci.yml
blob: 9211ec2352abef91f1c76bffb28642dc61562a76 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
pages:
  image: debian:buster
  script:
    - apt-get update
    - apt-get -qy install --no-install-recommends pandoc
    - test -d public || mkdir public
    - printf '<!DOCTYPE html>\n\n<html><body><h1>%s</h1><ul>' $CI_PROJECT_PATH > public/index.html
    - for f in *.txt; do
        set -x;
        name=`echo $f | sed s,\.txt$,,`;
        md=${name}.md;
        cat $f | sed --regexp-extended
            -e '0,/^ +/{s/^ +/# /}'
            -e 's/^ {1,3}([^ ])/\1/'
            -e '/^[0-9]+\. +http/! s/^([0-9]+\. )/## \1/'
            -e 's/^([0-9]+\.[0-9]+\. )/### \1/'
            -e 's/^([0-9]+\.[0-9]+\.[0-9]+\. )/#### \1/'
            -e 's/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\. )/##### \1/'
            > $md;
        printf "\n---\n\noriginal source\x3a [$f](https://gitweb.torproject.org/torspec.git/tree/$f)\n" >> $md;
        title=`sed -En '0,/^# /s/^# (.*)/\1/p' $md`;
        printf "<li><a href=\"${name}.html\"><tt>$name</tt>&colon; $title</a></li>" >> public/index.html;
        pandoc --from=markdown $md --output=public/${name}.html;
        mkdir public/$name;
        cp public/${name}.html public/$name/index.html;
      done
    - printf '</ul></body></html>' >> public/index.html
  artifacts:
    paths:
    - public
  only:
    - master