-
Notifications
You must be signed in to change notification settings - Fork 71
/
orgtomarkdowndots
executable file
·35 lines (29 loc) · 1.04 KB
/
orgtomarkdowndots
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
#!/bin/sh
# Convert OrgMode to Markdown
export MARKDOWNNAME="`echo "$1" | sed 's/$/.markdown/'`"
export HTMLNAME="`echo "$1" | sed 's/$/.html/'`"
# Syntax of OrgMode
# * for first level bullet -> H1
# ** for second level bullet -> first level markdown bullet
# == for codeblock becomes `
#| tr -d '^ :[:alpha:]:$' \
#| tr -d '^ :[:alpha:]:[:blank:][:alnum:]$' \
# Convert OrgMode to Markdown
cat "$1" \
| sed "s/#\+BEGIN_SRC/<pre><code>/" \
| sed "s/#\+END_SRC/<\/code><\/pre>/" \
| sed "s/ :PROPERTIES://" \
| sed "s/ :Effort:.*//" \
| sed "s/ :END://" \
| sed "s/ =/ \`/" \
| sed "s/= /\` /" \
| sed "s/=\./\`./" \
| sed "s/^=/\`/" \
| sed "s/=$/\`/" \
| sed "s/^\* /# /" \
| sed "s/^\*\* /## /" \
| sed "s/^\*\*\* /\* /" \
| sed "s/^\*\*\*\* /\ \* /" \
| sed "s/^\*\*\*\*\* /\ * /" > "$MARKDOWNNAME"
# Convert from Markdown to HTML
cat "$MARKDOWNNAME" | multimarkdown > "$HTMLNAME"