I want to add custom logic/class to my custom Jackson JsonSerialize implementation such that it parses out html based on certain rules. For example, if html is inclosed in single quotes ''text'' then the custom logic should accept the string as is. If its not in single quotes, like text then I want the custom logic/class to return just text. Additionally, if I have a block of html enclosed in three single quotes '''example''' it should accepted as is but if its not then only the example text should be returned and everything else parsed out. What is the best Java library to accomplish this? I thought about using AnitSamy but that leaves me open to an XSS attack since I need to accept anything inside quotes.