-
Notifications
You must be signed in to change notification settings - Fork 2
/
rentry_to_gh.sh
54 lines (41 loc) · 1.53 KB
/
rentry_to_gh.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
49
50
51
52
# Run with bash or zsh or similar, requires sed
# ./rentry_to_gh.sh <name of rentry file with hi3er markdown> [<optional output filename, defaults to rentry_to_gh_out.txt>]
if [ "$#" -gt 1 ]
then
output_file=$2
else
output_file="rentry_to_gh_out.txt"
fi
if [ "$#" -lt 1 ]
then
echo "Need input file argument, run with ./rentry_to_gh.sh <input filename>"
fi
cp $1 $output_file
# Change admonitions
# !!! note <info>
# !!!note <info>
# !!!note: <info>
# to:
# !!! note
# <info>
# the extra \l makes the admonition's first letter lowercase
sed -i -E 's/^\s*!!!\s*([[:alpha:]]+):*\s/!!! \l\1\n /gi' $output_file
# info did not have a colored box
#sed -i 's/!!! info/!!! note/gi' $output_file
# Removed centered # and ##
sed -i -E 's/^#\s*->(.*)\s*<-\s*$/# \1/g' $output_file
sed -i -E 's/^##\s*->(.*)\s*<-\s*$/## -- \1/g' $output_file
# Increase the # amounts
sed -i 's/^#/##/g' $output_file
# Remove a # for the title which should be the first occurance of #
sed -i '0,/^#/s/#//' $output_file
# Remove centered from images or links
sed -i -E 's/\s*->\s*(!*\s*\[.*\]\s*\(.*\))\s*<-\s*/\1/g' $output_file
# Replace ->&<- with <p align="center">&</p>
sed -i 's/\s*->\s*/\<p align="center"\>/g; s/\s*<-\s*$/\<\/p\>/g' $output_file
# Replace :-:, :--:, :---:, etc by :----:
sed -i 's/:-*:/:----:/g' $output_file
# Make Signets into Signet and then add a newline before signet tables
sed -i 's/Signets | Priority/Signet | Priority/gi' $output_file
sed -i 's/Signet | Priority/\n&/gi' $output_file
sed -i 's/time | sigil/\n&/gi' $output_file