| 1 |
lars |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
require_once(HTML2PS_DIR.'inline.content.builder.php');
|
|
|
4 |
|
|
|
5 |
class InlineContentBuilderPreWrap extends InlineContentBuilder {
|
|
|
6 |
function InlineContentBuilderPreWrap() {
|
|
|
7 |
$this->InlineContentBuilder();
|
|
|
8 |
}
|
|
|
9 |
|
|
|
10 |
/**
|
|
|
11 |
* CSS 2.1 16.6 Whitespace: the 'white-space' property
|
|
|
12 |
*
|
|
|
13 |
* pre-wrap:
|
|
|
14 |
*
|
|
|
15 |
* This value prevents user agents from collapsing sequences of
|
|
|
16 |
* whitespace. Lines are broken at newlines in the source, at
|
|
|
17 |
* occurrences of "\A" in generated content, and as necessary to
|
|
|
18 |
* fill line boxes.
|
|
|
19 |
*/
|
|
|
20 |
function build(&$box, $text, &$pipeline) {
|
|
|
21 |
$text = $this->remove_trailing_linefeeds($text);
|
|
|
22 |
$parent =& $box->get_parent_node();
|
|
|
23 |
$lines = $this->break_into_lines($text);
|
|
|
24 |
|
|
|
25 |
for ($i=0, $size = count($lines); $i<$size; $i++) {
|
|
|
26 |
$line = $lines[$i];
|
|
|
27 |
|
|
|
28 |
$words = $this->break_into_words($line);
|
|
|
29 |
foreach ($words as $word) {
|
|
|
30 |
$word .= ' ';
|
|
|
31 |
$box->process_word($word, $pipeline);
|
|
|
32 |
|
|
|
33 |
$whitespace =& WhitespaceBox::create($pipeline);
|
|
|
34 |
$box->add_child($whitespace);
|
|
|
35 |
};
|
|
|
36 |
|
|
|
37 |
if ((!$parent || $parent->isBlockLevel()) && $i < $size - 1) {
|
|
|
38 |
$this->add_line_break($box, $pipeline);
|
|
|
39 |
};
|
|
|
40 |
};
|
|
|
41 |
}
|
|
|
42 |
}
|
|
|
43 |
|
|
|
44 |
?>
|