forked from openpreserve/jpylyzer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmdToDeliveryFormats.sh
executable file
·48 lines (34 loc) · 1.3 KB
/
mdToDeliveryFormats.sh
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
#!/bin/bash
# Convert source file of jpylyzer documentation (markdown) to delivery formats:
#
# 1. userManual.html - add this to root of jpylyzer website (includes Jekyll headers)
# 2. Self-contained HTML file for offline use (replaces PDF)
#
# Requires Pandoc and xmllint
# Base name
baseName=jpylyzerUserManual
# Source file
mdSource=$baseName.md
# Style sheet
styleSheet=jpylyzer.css
# Delivery formats
# Website
outWeb=userManual.html
# Self-contained HTML
outHtmlSC=${baseName}.html
# Create file that replaces userManual page on website
# Step 1: convert to HTML
pandoc -s --columns 1000 --toc --toc-depth=2 --ascii -N -c $styleSheet -w html5 -o tmp.html $mdSource
# Step 2: generate file with Jekyll headers
echo "---" > $outWeb
echo "layout: page" >> $outWeb
echo "title: User Manual" >> $outWeb
echo "---" >> $outWeb
echo "{% include JB/setup %}" >> $outWeb
# Step 3: extract everything inside body element of HTML and add to output file
# This results in a flood of xmllint error messages, but they can be ignored.
xmllint --html --htmlout --xpath "//body/node()" tmp.html >> $outWeb
# Create self-contained HTML file (mainly useful for offline use; replaces PDF)
pandoc -s --columns 1000 --toc --toc-depth=2 --ascii -N -c $styleSheet -w html5 --self-contained -o $outHtmlSC $mdSource
# Clean-up
rm tmp.html