Project

General

Profile

« Previous | Next » 

Revision 7489

redmine_synonyms: Use the term's type label instead of its header level to determine if it's a synonym or alternative. This allows header levels to be chosen for presentational reasons rather than being constrained by being parsable.

View differences:

bin/redmine_synonyms
8 8

  
9 9
ambigTerm=
10 10
term=
11
sed -n 's/^.*<h([1-4])[^>]*>(<img [^>]*> *)?<a href="#[^>]+>([^<]+).*$/\1 \3/p'\
11
sed -n 's/^.*<h[1-4][^>]*>(<img [^>]*title="([^"]*):"[^>]*> *)?<a href="#[^>]+>([^<]+).*$/"\2" "\3"/p'\
12 12
|while read -r line; do
13
    set -- $line # split using IFS
14
    level="$1" name="$2"
13
    eval set -- $line # split to $@
14
    type="$1" name="$2"
15 15
    
16 16
    # Handle synonyms
17
    if test "$level" = 3; then echo "$name,$term"
17
    if test "$type" = Synonym; then echo "$name,$term"
18 18
    else
19 19
        term="$name"
20 20
        
21 21
        # Handle ambiguous terms
22 22
        if test "${term#\?}" != "$term"; then # ambiguous term (starts with ?)
23 23
            ambigTerm="$term"
24
        elif test "$level" = 4; then # alternative of ambiguous term
24
        elif test -n "$type"; then # alternative of ambiguous term
25 25
            echo "$ambigTerm,$term"
26 26
        else # term not related to ambiguous terms
27 27
            ambigTerm= # clear any ambiguous term in effect

Also available in: Unified diff