forked from oils-for-unix/oils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcmark.sh
executable file
·101 lines (79 loc) · 1.63 KB
/
cmark.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/bin/bash
#
# Usage:
# doctools/cmark.sh <function name>
#
# Example:
# doctools/cmark.sh download
# doctools/cmark.sh extract
# doctools/cmark.sh build
# doctools/cmark.sh make-symlink
# doctools/cmark.sh demo-ours # smoke test
set -o nounset
set -o pipefail
set -o errexit
readonly CMARK_VERSION=0.29.0
readonly URL="https://github.com/commonmark/cmark/archive/$CMARK_VERSION.tar.gz"
download() {
mkdir -p _deps
wget --no-clobber --directory _deps $URL
}
readonly CMARK_DIR=_deps/cmark-$CMARK_VERSION
extract() {
pushd _deps
tar -x -z < $(basename $URL)
popd
}
build() {
pushd $CMARK_DIR
# GNU make calls cmake?
make
make test
popd
# Binaries are in build/src
}
make-symlink() {
#sudo make install
ln -s -f -v cmark-$CMARK_VERSION/build/src/libcmark.so _deps/
ls -l _deps/libcmark.so
}
demo-theirs() {
echo '*hi*' | cmark
}
demo-ours() {
export PYTHONPATH=.
echo '*hi*' | doctools/cmark.py
# This translates to <code class="language-sh"> which is cool.
#
# We could do syntax highlighting in JavaScript, or simply post-process HTML
doctools/cmark.py <<'EOF'
```sh
code
block
```
```oil
code
block
```
EOF
# The $ syntax can be a little language.
#
# $oil-issue
# $cross-ref
# $blog-tag
# $oil-source-file
# $oil-commit
doctools/cmark.py <<'EOF'
[click here]($xref:re2c)
EOF
# Hm for some reason it gets rid of the blank lines in HTML. When rendering
# to text, we would have to indent and insert blank lines? I guess we can
# parse <p> and wrap it.
doctools/cmark.py <<'EOF'
Test spacing out:
echo one
echo two
Another paragraph with `code`.
EOF
}
"$@"