Advanced Search

Page 2 of 2 FirstFirst 12
Results 11 to 16 of 16

Thread: Removing extra <tr><td><table> and </tr></td></table> with preg_replace

  1. #11
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,165
    Thanks
    62
    Thanked 446 Times in 435 Posts
    Blog Entries
    7

    Default

    Are you sure HTMLpurifier is "too complex" for what you want to do?

    Quote Originally Posted by http://htmlpurifier.org/docs
    PHP Code:
    require_once '/path/to/HTMLPurifier.auto.php';

    $config HTMLPurifier_Config::createDefault();
    $purifier = new HTMLPurifier($config);
    $clean_html $purifier->purify($dirty_html); 
    ($dirty_html would be the markup your users submit; $clean_html would be the purified markup you save/use.)
    Last edited by traq; 05-25-2013 at 04:04 AM.
    Adrian ~ facebook | gist/github

    ['66.215.156.37','208.75.149.97'] // ip,ip array!
    "Take that sticker *off* your hat; you look stupid" --Wil Wheaton

  2. The Following User Says Thank You to traq For This Useful Post:

    djr33 (05-25-2013)

  3. #12
    Join Date
    Oct 2012
    Posts
    84
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Default

    It's not as easy as you think, in my case. An ad content, in my case, already goes through a markdown and it's not just one $dirty_html that is called out. In my case, the html is echoed and it has two different components in it. I will need a professional help to make it work.

  4. #13
    Join Date
    Oct 2012
    Posts
    84
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Default

    I am also wondering, how the purifier is going to help me with html tables. And... if it can, why can't I do the same thing through my markdown? Obviously the purifier is using something to straighten html tables, why can't I just take the same regex (or whatever) and just make it part of my markdown?

  5. #14
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,165
    Thanks
    62
    Thanked 446 Times in 435 Posts
    Blog Entries
    7

    Default

    I'm sure it's possible to reverse-engineer HTMLpurifier and integrate the relevant parts with your code. I'm also sure that it would not be a "simpler" approach.

    If you'd like to share further details - what user input you receive, how you need to process it, how it needs to be output/saved - I'd be happy to continue to help you find a solution.

    Otherwise, if you want to hire someone, you're welcome to post in the Paid Work forum.
    Adrian ~ facebook | gist/github

    ['66.215.156.37','208.75.149.97'] // ip,ip array!
    "Take that sticker *off* your hat; you look stupid" --Wil Wheaton

  6. #15
    Join Date
    Oct 2012
    Posts
    84
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Default

    traq

    You may wander why I need that thing to be fixed so badly. Here's an example of a table based template a user posted on the site:

    http://qwikad.com/0/posts/8-real-est...use-FAST-.html

    That's why I want to perfect the whole table thing so that others could enjoy good looking templates and never encounter the ones that mess up the site.
    Last edited by qwikad.com; 05-26-2013 at 09:14 PM.

  7. #16
    Join Date
    Oct 2012
    Posts
    84
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Default

    I guess I've taken the easiest way out for now. I've tried different lines and ended up with this one. It does what I want... for now:

    Code:
     $text = preg_replace( '/(s*<\/table\s*\/?>\s*)+/', "</table>", $text);
    Thanks everyone for your input!



    By the way, in the process I've discovered this site. Some of you (regex fans) may find it useful: http://regex101.com
    Last edited by qwikad.com; 05-26-2013 at 10:03 PM.

Similar Threads

  1. DHTML Window widget - removing inset table border?
    By jamba in forum Dynamic Drive scripts help
    Replies: 2
    Last Post: 02-21-2012, 05:51 AM
  2. DD Window Widget - adds extra space in window before <table> or <ul> tags
    By CherieP in forum Dynamic Drive scripts help
    Replies: 1
    Last Post: 01-20-2010, 08:48 AM
  3. Replies: 4
    Last Post: 01-18-2010, 01:42 PM
  4. table with extra bit on bottom
    By djr33 in forum HTML
    Replies: 4
    Last Post: 03-02-2007, 04:22 AM
  5. copy records from table to table in MySQL?
    By nephish in forum Other
    Replies: 0
    Last Post: 07-29-2005, 07:40 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •