1 | #!/usr/bin/env bash
|
2 | #
|
3 | # Usage:
|
4 | # doctools/cmark.sh <function name>
|
5 | #
|
6 | # Example:
|
7 | # doctools/cmark.sh download
|
8 | # doctools/cmark.sh extract
|
9 | # doctools/cmark.sh build
|
10 | # doctools/cmark.sh make-symlink
|
11 | # doctools/cmark.sh demo-ours # smoke test
|
12 |
|
13 | set -o nounset
|
14 | set -o pipefail
|
15 | set -o errexit
|
16 |
|
17 | REPO_ROOT=$(cd $(dirname $0)/.. && pwd)
|
18 | readonly REPO_ROOT
|
19 |
|
20 | readonly TAR_DIR=$REPO_ROOT/_cache
|
21 | readonly DEPS_DIR=$REPO_ROOT/../oil_DEPS
|
22 |
|
23 | readonly CMARK_VERSION=0.29.0
|
24 | readonly URL="https://github.com/commonmark/cmark/archive/$CMARK_VERSION.tar.gz"
|
25 |
|
26 | # 5/2020: non-hermetic dependency broke with Python 3 SyntaxError! Gah! TODO:
|
27 | # make this hermetic.
|
28 | #
|
29 | # https://pypi.org/project/Pygments/#history
|
30 | #
|
31 | # 7/2023: Download the wheel file
|
32 | # doctools/oils_doc.py OPTIONALLY uses this
|
33 | #
|
34 | # It's only used in the blog, so let's just put it in the oilshell.org repo,
|
35 | # not the oil repo
|
36 |
|
37 | download-old-pygments() {
|
38 | wget --directory _tmp --no-clobber \
|
39 | 'https://files.pythonhosted.org/packages/be/39/32da3184734730c0e4d3fa3b2b5872104668ad6dc1b5a73d8e477e5fe967/Pygments-2.5.2-py2.py3-none-any.whl'
|
40 | }
|
41 |
|
42 | demo-theirs() {
|
43 | echo '*hi*' | cmark
|
44 | }
|
45 |
|
46 | demo-ours() {
|
47 | export PYTHONPATH=.
|
48 |
|
49 | echo '*hi*' | doctools/cmark.py
|
50 |
|
51 | # This translates to <code class="language-sh"> which is cool.
|
52 | #
|
53 | # We could do syntax highlighting in JavaScript, or simply post-process HTML
|
54 |
|
55 | doctools/cmark.py <<'EOF'
|
56 | ```sh
|
57 | code
|
58 | block
|
59 | ```
|
60 |
|
61 | ```oil
|
62 | code
|
63 | block
|
64 | ```
|
65 | EOF
|
66 |
|
67 | # The $ syntax can be a little language.
|
68 | #
|
69 | # $oil-issue
|
70 | # $cross-ref
|
71 | # $blog-tag
|
72 | # $oil-source-file
|
73 | # $oil-commit
|
74 |
|
75 | doctools/cmark.py <<'EOF'
|
76 | [click here]($xref:re2c)
|
77 | EOF
|
78 |
|
79 | # Hm for some reason it gets rid of the blank lines in HTML. When rendering
|
80 | # to text, we would have to indent and insert blank lines? I guess we can
|
81 | # parse <p> and wrap it.
|
82 |
|
83 | doctools/cmark.py <<'EOF'
|
84 | Test spacing out:
|
85 |
|
86 | echo one
|
87 | echo two
|
88 |
|
89 | Another paragraph with `code`.
|
90 | EOF
|
91 |
|
92 | }
|
93 |
|
94 | "$@"
|