nuke html
This commit is contained in:
parent
014d2ab62c
commit
afeca03eef
28
dictpopup
28
dictpopup
|
@ -1,24 +1,14 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
# Depends on:
|
# Looks up argument instead, if provided
|
||||||
# - sdcv
|
word=${1:-$(xclip -o)}
|
||||||
# - sselp (for selection support)
|
[ -z "$word" ] && exit 1
|
||||||
# - lynx (for html support)
|
|
||||||
# invocation: dictpopup [html] [word]
|
|
||||||
# - If no argument provided, the selection is used
|
|
||||||
# - If supplied with the html option, the dictionary output will be piped through lynx
|
|
||||||
# in order to format html as plain text
|
|
||||||
|
|
||||||
# TODO: Switch between dictionaries / dictionary results.
|
dict_lookup=$(sdcv -n --utf8-output -e "$word")
|
||||||
# Implementation idea (in C): Store each dictionary entry in an array. Invoke popup with a dictionary entry.
|
if echo "$dict_lookup" | grep -F -q "Nothing similar to"; then
|
||||||
# Increment, decrement array and reinvoke or quit according to exit code of popup
|
popup "$dict_lookup"
|
||||||
|
|
||||||
if [ "$1" = "html" ]; then
|
|
||||||
word=${2:-$(sselp)}
|
|
||||||
sdcv -n --utf8-output -e "$word" | format_output |
|
|
||||||
lynx -dump -stdin -assume_charset=UTF-8 -display_charset=UTF-8 |
|
|
||||||
popup
|
|
||||||
else
|
else
|
||||||
word=${1:-$(sselp)}
|
output=$(echo "$dict_lookup" | tail -n +5 | sed 's|<br>|\n|g' | sed 's|<[^>]*>||g')
|
||||||
sdcv -n --utf8-output -e "$word" | format_output | popup
|
output=$(echo "$output" | sed -E 's/&(amp|lt|gt|quot);/\1/g')
|
||||||
|
printf '%s\0' "$output" | xargs -0 -I {} sh -c 'popup "$@"' _ {}
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue