ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

CSS styles to HTML tags

May 19, 2009 2:44pm

Subscribe [2]
  • #1 / May 19, 2009 2:44pm

    Tom Schlick

    386 posts

    i know this is totally against everything that is good and holy in web development but i need a way to input a string of html that has inline and <style> styles and convert it to tags such as <i> <u> etc. let me explain

    im converting legislation in which they get rid of certain things in the bill text. when they do this they dont remove the text they apply a style with a strike through. when they add something it is underlined. and when they clear up something they make it bold. thats not the problem though.

    the problem is that they don’t use consistent styles across the board. so one bold item might be .style-3 and another that is exactly the same might be .style-46757, its a huge pain in the ass. i need something that will take the markup and convert the attributes of the elements to html so that i can then replace those items with my own styles that are consistent. does anyone know of a library or script out there that does this? ive googled the shit out of it and no luck

    here is an example of what i want.

    FROM THIS

    
    
    

    TO THIS

    <span><b>Some text<span><u>some more text</u></span></b></span>

    thanks

  • #2 / May 19, 2009 4:52pm

    Gordaen

    76 posts

    I don’t know of a script that specifically does that, but you could probably create something pretty easily with regular expressions as long as there is a reasonably finite set of styles.  Also the removed text should be converted to <del></del> tags.