Remove trailing whitespace.
[xhtml-compiler.git] / XHTMLCompiler / TextFilter / Fragment.php
blob8767fcfd701dd7a3e7559d2f5709ae8b6c4c5a76
1 <?php
3 /**
4 * Converts documents that have the xc-fragment class on the body
5 * element into HTML fragments, which are only the contents of the
6 * body element
7 */
8 class XHTMLCompiler_TextFilter_Fragment extends XHTMLCompiler_TextFilter
11 var $name = 'Fragment';
13 public function process($text, $page, $manager) {
14 if (strpos($text, '<body class="xc-fragment">') === false) return $text;
15 preg_match('/<body class="xc-fragment">(.+?)<\/body>/s', $text, $matches);
16 file_put_contents($page->getPathStem() . '.frag', $matches[1]);
17 return $text;