File: pd2md.sh

package info (click to toggle)
pd-iemmatrix 0.6.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,576 kB
  • sloc: ansic: 15,440; makefile: 291; sh: 169
file content (52 lines) | stat: -rwxr-xr-x 1,077 bytes parent folder | download
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
#!/bin/sh

helppatch="$1"

if ! test -e "${helppatch}"; then
    echo "'${helppatch}' does not exist!" 1>&2
    exit 1
fi

title="${helppatch%.pd}"
title="${title%-help}"
title="${title##*/}"

description="$(grep -h DESCRIPTION "${helppatch}" | sed -e 's|^#X text [0-9]* [0-9]* DESCRIPTION \(.*\)|\1|' -e 's|\(, f [1-9][0-9]*\)*;||'  -e 's| \\, |, |g')"

cat <<EOF
---
title: ${title}
description: ${description}
categories:
- object
pdcategory: Generic
see_also:
EOF

echo "inlets:"
grep "^#X text [0-9]* [0-9]* INLET_" "${helppatch}" | sed -e 's|#X text [0-9]* [0-9]* INLET_\(.*\);|\1|' | sort -u | while read num type; do
    if [ "${num}" = "0" ]; then
        num="1st"
    fi
    cat <<EOF
  ${num}:
  - type: ${type}
    description: ...
EOF
    done
echo "outlets:"
grep "^#X text [0-9]* [0-9]* OUTLET_" "${helppatch}" | sed -e 's|#X text [0-9]* [0-9]* OUTLET_\(.*\);|\1|' | sort -u | while read num type; do
    if [ "${num}" = "0" ]; then
        num="1st"
    fi
    cat <<EOF
  ${num}:
  - type: ${type}
    description: ...
EOF
done

cat <<EOF
draft: true
---
EOF