!!g;
s!\([^<>]*\)!\1 !g;
s!\([^<>]*\)
!$(tput sitm)\2$(tput sgr0)!g;
s!\([^<>]*\)!\1!g;
s!\([^<>]*\)!$(tput sitm)\1$(tput sgr0)!g;
s!\([^<>]*\)!$(tput sitm)\1$(tput sgr0)!g;
s!]*>\([^<>]*\)!$(tput sitm)\1$(tput sgr0)!g;
s!\([^<>]*\)!$(tput sitm)\1$(tput sgr0) !g;
s!\([^<>]*\)!$(tput sitm)\1$(tput sgr0) !g;
s!\([^<>]*\)!$(tput setaf 3)\1$(tput sgr0)!g;
s!\([^<>]*\)!$(tput bold)\1$(tput sgr0)\t!g;
s!\?a[^>]*>!!g
s!\?[cp]b[^>]*>!!g
s!\?gramGrp[^>]*>!!g
s!\?lbl[^>]*>!!g
s!\?xr[^>]*>!!g
s!\?pron[^>]*>!!g
s!\?gen[^>]*>!!g
s!\?etym[^>]*>!!g
s!]*>!$(tput sitm)!g
s!]*>!$(tput sgr0)!g
s!\?date[^>]*>!!g
s!\?placeName[^>]*>!!g
s!\?itype[^>]*>!!g
s!\?p>!!g
s!]*>!!g
s!\?orth[^>]*>!!g
s!\?forename[^>]*>!!g
s!\?persName[^>]*>!!g
s!\?surname[^>]*>!!g
s!\?entryFree[^>]*>!!g
s!\?def[^>]*>!!g
s!\?cit[^>]*>!!g
s!\?pos[^>]*>!!g
s!\?usg[^>]*>!!g
s!\?span>!!g
s!]*>!$(tput setaf 245)!g
s!]*>!$(tput sgr0)!g
s//$(tput bold)/g;
s::$(tput sgr0):g;
s//\n/g;
s:::g;
s/<[bB]>/$(tput bold)/g;
s:[bB]>:$(tput sgr0):g;
s:<[bB][rR]\s*/\?>:\n:g;
s:<[iI]>:$(tput sitm):g;
s:[iI]>:$(tput sgr0):g;
s:<[uU]>:$(tput smul):g;
s:[uU]>:$(tput sgr0):g;
s:]*>::g;
s:::g;
s!\([^<>]*\)!$(tput bold)\1$(tput sgr0)!g;
s!\([^<>]*\)!\2!g
s#\(.*\)
#\\1#g;
s:\([^<>]*\):$(tput setaf 3)\\1$(tput sgr0):g;
s:\([^<>]*\):$(tput setaf 4)\\1$(tput sgr0):g;
s:\([^<>]*\):$(tput setaf 1)\\1$(tput sgr0):g;
s:\([^<>]*\):$(tput setaf 5)\\1$(tput sgr0):g;
s:\([^<>]*\):$(tput bold)\1$(tput sgr0):g
s:\([^<>]*\):$(tput setaf 3)\1$(tput sgr0):g
s:':':g
s:<:<:g
s:>:>:g
s:\([^<>]*\):$(tput setaf 2)\\1$(tput sgr0):g;
s:\([^<>]*\):$(tput setaf 2)\\1$(tput sgr0):g;
s:\([^<>]*\):$(tput setaf 4)\\1$(tput sgr0):g;
s:\([^<>]*\):$(tput bold)\\1$(tput sgr0):g;
s:]*>:ː:g;
s:]*>::g;
s!\?TABLE>!!g
s!\?TR[^>]*>!!g
s!\?TD>!!g
s!\?FONT[^>]*>!!g
s!\?A[^>]*>!!g
s!\([^<>]*\)!$(tput setaf 245)\1$(tput sgr0)!g
s!\?SPAN[^>]*>!!g
s! +! !g;
s!!\n\n&!g
s!]*>!!g
s!\?div[^>]*>!!g
s!!!g # unbalanced in Frisk
s!^\s*[0-9])!$(tput setaf 5)&$(tput sgr0)!g
s#^\(-->.*\)\$#$(tput bold)\1$(tput sgr0)#
"
'';
mkDictBin = name: dicts:
pkgs.writers.writeDashBin name ''
set -efu
export SDCV_PAGER=${toString sdcvPager}
exec ${pkgs.sdcv}/bin/sdcv --data-dir ${makeStardictDataDir dicts} "$@"
'';
in
pkgs.symlinkJoin {
name = "stardict";
paths = [
(mkDictBin "sd-classics" classicsDictionaries)
(mkDictBin "sd-sanskrit" sanskritDictionaries)
(mkDictBin "sd-swahili" swahiliDictionaries)
(mkDictBin "sd" englishGermanDictionaries)
];
}