aboutsummaryrefslogtreecommitdiff
path: root/web/mkdemos.sh
blob: 83490f8372eef3fd901f1b9c529a90932ae06cbc (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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/sh -e
# creates example page for pandoc
# argument #1 is the destination directory
# argument #2 is the directory containing pandoc, html2markdown, markdown2pdf

DEST=$1
PROGPATH=$2

NEWLINE='
'
EXAMPLES='HTML fragment:
pandoc README -o example0.html
Standalone HTML file:
pandoc -s -S README -o example0.html
HTML with smart quotes, CSS, and custom header and footer:
pandoc -s -S -c main.css -B header.html -A footer.html README -o example0.html
LaTeX:
pandoc -s README -o example0.tex
From LaTeX to markdown:
pandoc -s README.tex -o example0.txt
reStructuredText:
pandoc -s -w rst README -o example0.txt
Rich text format (RTF):
pandoc -s README -o example0.rtf 
S5 HTML slide show (all in one file):
pandoc -s -m -i -w s5 S5DEMO -o example0.html
Docbook XML:
pandoc -s -w docbook README -o example0.db
Converting a web page to markdown:
html2markdown http://www.gnu.org/software/make/ -o example0.txt
From markdown to PDF:
markdown2pdf README -o example0.pdf
Using a custom LaTeX header to change the font style of the PDF:
markdown2pdf -C myheader.tex README -o example0.pdf'

oldifs=$IFS
IFS=$NEWLINE
set -- $EXAMPLES
IFS=$oldifs

cd $DEST

echo '% Pandoc examples

To see the output created by each of the commands below,
click on the name of the output file:

'
num=0
while [ $# -gt 0 ]; do
    description="$1"
    command="$2"
    num=$(($num + 1))
    command=$(echo $command | sed -e "s/0/$num/")
    firstpart=$(echo $command | sed -e 's/\(.*\) [^ ]* -o.*/\1/')
    input=$(echo $command | sed -e 's/.* \([^ ]*\) -o.*/\1/') 
    output=$(echo $command | sed -e 's/.*-o \(.*\)/\1/')
    echo "1. $description"
    echo
    echo "    <code>$firstpart <a href=\""$input"\" title=\""View input file"\">$input</a> -o <a href=\""$output"\" title=\""View pandoc output"\">$output</a></code>"
    echo $command >&2
    result=$(PATH=$PROGPATH:$PATH $command) # run the command and create output file
    shift
    shift
done