I'm using sqlite's full-text-search support to store documents that may contain &, < and > characters. I intended to use the snippet function to highlight the matches for an html results page, but I don't see an obvious way to escape the text before injecting the markers. I'd rather not escape the text before storing it, because then amp, lt and gt will become tokens.
The simplest workaround I can think of is to escape the pages before storing them, and use a custom tokenizer that would first unescape &, < and >.
However... since the default for snippet(foo) is to use <b> and </b>, it really seems like this is a very common use case and I'm convinced that there must be a way to handle this without reinventing the wheel in C. Am I overlooking a more elegant solution?