arthur.bebou

Le site arthur.bebou.netlib.re - retour accueil

git clone git://bebou.netlib.re/arthur.bebou
Log | Files | Refs |

page (1391B)


      1 #! /usr/bin/env dash
      2 
      3 . ./common
      4 
      5 STYLE=/style.css
      6 
      7 TARGET="${2:-html}"
      8 
      9 file="$1"
     10 destfile=$(echo "$file" | sed -E "s/\.sh/.html/" | cut -c10-)
     11 
     12 save_md() {
     13 	cat > $tmpd/md
     14 	count=$(wc -w < $tmpd/md)
     15 	time=$(dc -e "2k $count 160 / p" | sed 's/\..*//')
     16 	cat | case "$TARGET" in
     17 		(html) cat $tmpd/md | lowdown        >> "$tmpd/$1" ;;
     18 		(term) cat $tmpd/md | lowdown -tterm >> "$tmpd/$1" ;;
     19 		(md)   cat $tmpd/md |
     20 			sed -E "s,\]\(/,]($url/," |
     21 			sed -E "s,($url[^.]*)\.html,\1.md," >> "$tmpd/$1" ;;
     22 		(roff) cat $tmpd/md | lowdown -tms   >> "$tmpd/$1" ;;
     23 	esac
     24 }
     25 
     26 save_html() cat >> "$tmpd/$1"
     27 save() cat >> "$tmpd/$1"
     28 
     29 alias sectionmd:='<<\endsection save_md'
     30 alias section:='<<\endsection save'
     31 alias sectionhtml:='<<\endsection save_html'
     32 
     33 alias title:="title"
     34 title() title="$*"
     35 
     36 alias author:="author"
     37 author() author="$*"
     38 
     39 alias description:="description"
     40 description() description="$*"
     41 
     42 alias publication:=":"
     43 
     44 grep -E "^##+" "$file" > $tmpd/titles
     45 < $tmpd/titles lowdown |
     46 	grep -v '^$' |
     47 	cut -d'"' -f2 |
     48 	sed -E 's/^/(#/;s/$/)/' > $tmpd/slugs
     49 sed -E 's/^##/  /g;' $tmpd/titles |
     50 	sed -E 's/#/  /g' |
     51 	sed -E 's/ (\w)/[\1/;s/$/]/' |
     52 	sed -E 's/([^* ])/* \1/' |
     53 	paste - $tmpd/slugs |
     54 	sed '$ a - - -' |
     55 	save_md tdm
     56 
     57 case "$TARGET" in
     58 	(html) . layouts/html ;;
     59 	(term) . layouts/plain ;;
     60 	(md)   . layouts/md ;;
     61 	(roff) . layouts/plain ;;
     62 esac
     63 
     64 [ "$1" ] || set -
     65 
     66 . "$@"
     67 
     68 layout