使用pandoc迁移文档,从trac到github

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
#!/bin/zsh


file=$1
[[ -f $file ]] || {
print "PLEASE SPECIF FILE"
exit 250
}

content=$(< $file)
local -a _chunks
_chunks=(${(@f)content})


content=($(< $file))

for ((i=1; i<=$#_chunks; ++i)); do
_line=$_chunks[i]
# process head
if [[ $_line =~ '^([=])+s(.*)' ]]; then
head=${match[1]}
head=${head:gs/=/#}
print -- "$head $match[2]"
# process block
elif [[ $_line =~ '^}}}.*' ]]; then
print "```"
# process block
elif [[ $_line =~ '^{{{.*' ]]; then
print "```"
else
print -- $_line
fi
done