0

My code looks like that

$markup = ob_get_clean();

// Specify configuration
$config = array(
    'indent' => true,
    'output-xhtml' => true,
    'wrap' => 200);

// Tidy
$tidy = new tidy;
$tidy->parseString($markup, $config, 'utf8');
$tidy->cleanRepair();

There is a big problem: My web php code gets string from database that contains programming materials (like include , etc) and tidy gets <stdio> as wrong tag, "repairs" (removes it from output) Is there any way to just indent code? I mean not to repair and remove parts of material like <stdio>??

heron
  • 3,611
  • 25
  • 80
  • 148
  • Maybe tidy should be the last step in your processing chain (after all the included code ran), not the first. – Tomalak Aug 13 '12 at 16:45
  • Use XHTML and CDATA tags to prevent tidy from seeing those non-tags as tags? – Marc B Aug 13 '12 at 16:49
  • 1
    *You* are telling the browser (and Tidy) that `` is actually a HTML tag - while it is not. Learn how to properly encode text to be used the way you like it. But do not start fixing the problem at the wrong end. – hakre Aug 13 '12 at 16:51
  • Can you provide an example of input and desired output? – Frank Farmer Aug 13 '12 at 16:52
  • @FrankFarmer tidy class removes programming content parts like .. (inside brackets) I want to prevent it. The question is how? – heron Aug 13 '12 at 16:54

1 Answers1

2

I think htmspecialchars() and htmlspecialchars_decode() functions may help you.

NotGaeL
  • 8,344
  • 5
  • 40
  • 70
  • `htmlspecialhars()` is used when you want to display HTML special chars in an html doc. It escapes HTML reserved chars like `<` and `>` to `>` and `<` so they won't be parsed as HTML (or better to say they will be substituted for code that can be parsed as the corresponding text characters, instead of code). `htmlspecialhars_decode()` does the opposite, so you can figure that out :) – NotGaeL Aug 13 '12 at 16:59