1<?php 2 3require_once(HTML2PS_DIR.'inline.content.builder.php'); 4 5class InlineContentBuilderPreLine extends InlineContentBuilder { 6 function InlineContentBuilderPreLine() { 7 $this->InlineContentBuilder(); 8 } 9 10 /** 11 * CSS 2.1 p.16.6 12 * white-space: normal 13 * This value directs user agents to collapse sequences of whitespace, and break lines as necessary to fill line boxes. 14 */ 15 function build(&$box, $text, &$pipeline) { 16 $text = $this->remove_leading_linefeeds($text); 17 $text = $this->remove_trailing_linefeeds($text); 18 $lines = $this->break_into_lines($text); 19 $parent =& $box->get_parent_node(); 20 21 for ($i=0, $size = count($lines); $i<$size; $i++) { 22 $line = $lines[$i]; 23 24 $words = $this->break_into_words($this->collapse_whitespace($line)); 25 foreach ($words as $word) { 26 $box->process_word($word, $pipeline); 27 28 $whitespace =& WhitespaceBox::create($pipeline); 29 $box->add_child($whitespace); 30 }; 31 32 if ((!$parent || $parent->isBlockLevel()) && $i < $size - 1) { 33 $this->add_line_break($box, $pipeline); 34 }; 35 }; 36 } 37} 38 39?>