I am trying to clean up some HTML values that are imported from other sources, primarily email message bodies. Ideally, I would like to be able to strip <style> and <link> tags, but also apply their styles (assuming the link tag points to a style sheet) to the appropriate elements within the value.
I am currently trying to accomplish this via tidy. If it comes down to it, I can strip out the tags without applying the styles.
you could use php’s simple-xml functions to assign the styles to your markup.
or write some custom implementation to manipulate the html (which is not a good practice tbh) if you don’t want to get into the simplexml lib.