following this: https://tex.stackexchange.com/a/48549/22969, I tried this code:
\documentclass{article}
\usepackage{ulem}
\usepackage{xcolor}
\usepackage{polyglossia}
\setdefaultlanguage{hebrew}
\newfontfamily\hebrewfont[Script=Hebrew]{Arial} %or use any other font, even Bitstream Vera Sans
\begin{document}
\newcommand\hl{\bgroup\markoverwith{\textcolor{yellow}{\rule[-.5ex]{2pt}{2.5ex}}}\ULon}
this is a \LR{\hl{hightlighted text}}. and this is \hl{unseen}.
\end{document}
as stated in the code itself, the ulem macros don't work well when trying to color an RTL text.
why is it so, and how can that be solved (even by rewriting parts of ulem package)?
EDIT: of course, I'm not tied to the ulem/rule approach. if anyone has a different idea of how to achieve my goal (yellow highlighting of several words in the middle of RTL text that may break across lines, using xelatex) - it will definitely suffice.
EDIT: ok. I have a partial solution. at the preamble add this:
\makeatletter
\def\UL@putbox{\ifx\UL@start\@empty \else % not inner
\vrule\@width\z@ \LA@penalty\@M
{%
\UL@skip\wd\UL@box%
\box\UL@box% originally leaders here
\kern-\UL@skip%
\UL@leaders% originally box here
}%
\fi}
\makeatother
this will "fix" the ulem code to the RTL case, where the first strike "wins", as opposed to the regular LTR logic, where the last strike "wins".
it's only partial, since the last word in the line is not colored now. need to understand which macro handles this edge case.