summaryrefslogtreecommitdiffstats
path: root/util/bin/jbo
blob: 76f866808d544f494e4f53e587a8754515467adb (plain)
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
#! /bin/sh
# usage: jbo WORDS...
set -euf

if test $# = 0; then
  while read line; do
    if test "${clear-}" = true; then
      echo -n 'c'
    fi
    "$0" "$line"
  done
  exit
fi

echo "$*" |
tr 'h' "'" |
jbofihe -H |
tr '\n' ' ' |
sed -r '
  s@</?(HTML|HEAD|TITLE|BODY|FONT)[^>]*>@@g
  s@Lojban translation@@
' | {
  sed 's:<SUB>[^>]*</SUB>:\n&\n:g' |
  sed '/^<SUB>/y/0123456789/₀₁₂₃₄₅₆₇₈₉/' |
      tr -d '\n' |
      sed 's:</\?SUB>::g'
} |
sed -r '
  s|<B>||g; s|</B>||g

  s|<I> </I>|<I>_</I>|g
  s|<I>||g; s|</I>||g

  #s|<U>||g; s|</U>||g
  s|<U>||g; s|</U>||g

  s|&lt;|<|g
  s|&gt;|>|g

  s@^ *@@
  $s/$/\n/
'