I would like to automatically highlight parts of a running text, based on whether the word is in a predefined dictionary, or not. Something along the lines of...
\documentclass{article}
\mydictionary{apple,banana}%A comma-separated list of unicode characters. For simplicity the dictionary contains words, and not compound expressions, such as "yellow lemon". In other words, no spaces are allowed.
\def\autohighlightStyle1{ textcolor=red }{ dictionary=\mydictionary }%I need the infrastructure to define my own formatting. For simplicity, in this example it is enough to change the textcolor. I will add my own formatting options later by myself.
\begin{document}
\autohighlightStyle1{Monkeys like banana, but they don't like apple.}
\end{document}
And the result would be a text, where the words from dictionary \mydictionary
(banana and apple) are formatted according to some instructions, here for simplicity they are colored to red.
Any chance that something like this is doable? Essentially I will need to tokenize the text by the spaces, and then compare word by word it with the contents of the dictionary, and then apply the style, and then print them out.
I am using xelatex, and unicode text (but again, in this simple example spaces function as a delimiter).
Ideally, I would like to apply this wrapper to the entire document, right after \begin{document}
and close right before \end{document}
, so... it should be... robust... But... for simplicity, perhaps we may assume that it receives ordinary text, as an argument. Another idea is that maybe I will have to use a style file to do something like this?