The OP asked also asked about hyperref. I can make it work in a test case, thanks to this answer, but I worry very much potential side effects. Use it in a production document at your own risk!
\documentclass{article}
\begin{filecontents}{\jobname.mst}
delim_0 "\space"
delim_1 "\space"
delim_2 "\space"
delim_n "\idxBdelim"
\end{filecontents}
\usepackage{imakeidx}
\usepackage{hyperref}
\makeindex
\makeatletter
\def\idxBdelim{@ifnextchar{\hyperindexformat}{;\space}{,\space}}
\def@commahyperpage#1{@@commahyperpage#1\idxBdelim{}\idxBdelim{}\}
\def@@commahyperpage#1\idxBdelim#2\idxBdelim#3\{%
\ifx\#2\%
\HyInd@pagelink{#1}%
\else
\HyInd@pagelink{#1}\idxBdelim\HyInd@pagelink{#2}%
\fi
}
\makeatother
\begin{document}
Some words. A test.
\index{words}
\index{phrases|see{words}}
\newpage
Words and sentences.\index{words}\index{sentences}
\newpage
Sentences.\index{sentences}
\index{sentences|seealso{words}}
\printindex
\end{document}
Possible side-effects:
- This essentially blows up how
\hyperpage works with comma-separated list of elements.
- I cannot detect
\seealso; I only detect the wrapper that \hyperref puts around \seealso; but the same wrapper also gets placed around \see, so use it at your own peril.
A potentially better solution would be to try to fully expand what (say) 1\idxBdelim2 would expand to before passing it into \hyperpage; this would not require modifying the underlying mechanics of \hyperpage. Unfortunately I couldn't make it work.
*be inKey 1, 2 * see Key2; if the see comes after a list of pages? (2) what should*be inKey * see also Key 2; if the "see also" comes without any pages. Are you just assuming that these two cases will not happen in practice? – Willie Wong Feb 22 '21 at 13:19hyperrefpackage is called... – forrest Feb 24 '21 at 10:29hyperref. (a) the package makes certain implicit assumptions on what is the separator between pages and (b) you would need to also unwrap\hyperindexformatto see the\seeor\seealso. If it were just problem (b) this could be solved with a bit more work. But I don't know how to solve (a). – Willie Wong Feb 24 '21 at 17:36