Index: trunk/extensions/CodeReview/backend/DiffHighlighter.php |
— | — | @@ -12,9 +12,9 @@ |
13 | 13 | * @return string |
14 | 14 | */ |
15 | 15 | function render( $text ) { |
16 | | - return '<pre class="mw-codereview-diff">' . |
| 16 | + return '<table class="mw-codereview-diff">' . |
17 | 17 | $this->splitLines( $text ) . |
18 | | - "</pre>\n"; |
| 18 | + "</table>\n"; |
19 | 19 | } |
20 | 20 | |
21 | 21 | /** |
— | — | @@ -41,7 +41,7 @@ |
42 | 42 | return ""; // don't create bogus spans |
43 | 43 | } |
44 | 44 | list( $element, $attribs ) = $this->tagForLine( $line ); |
45 | | - return Xml::element( $element, $attribs, $line ); |
| 45 | + return "<tr>".Xml::element( $element, $attribs, $line )."</tr>"; |
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
— | — | @@ -50,12 +50,12 @@ |
51 | 51 | * @return array |
52 | 52 | */ |
53 | 53 | function tagForLine( $line ) { |
54 | | - static $default = array( 'span', array() ); |
| 54 | + static $default = array( 'td', array() ); |
55 | 55 | static $tags = array( |
56 | | - '-' => array( 'del', array() ), |
57 | | - '+' => array( 'ins', array() ), |
58 | | - '@' => array( 'span', array( 'class' => 'meta' ) ), |
59 | | - ' ' => array( 'span', array() ), |
| 56 | + '-' => array( 'td', array( 'class' => 'del' ) ), |
| 57 | + '+' => array( 'td', array( 'class' => 'ins' ) ), |
| 58 | + '@' => array( 'td', array( 'class' => 'meta' ) ), |
| 59 | + ' ' => array( 'td', array() ), |
60 | 60 | ); |
61 | 61 | $first = substr( $line, 0, 1 ); |
62 | 62 | if ( isset( $tags[$first] ) ) { |
Index: trunk/extensions/CodeReview/modules/ext.codereview.styles.css |
— | — | @@ -131,15 +131,47 @@ |
132 | 132 | } |
133 | 133 | |
134 | 134 | /* Diffs */ |
135 | | -.mw-codereview-diff pre { |
| 135 | +.mw-codereview-diff table { |
136 | 136 | /* @noflip */direction: ltr; /* Source code is always LTR */ |
| 137 | + |
| 138 | + /* mimic MediaWiki <pre> style */ |
| 139 | + font-family: monospace, "Courer New"; |
| 140 | + line-height: 1.3em; |
| 141 | + background-color: #F9F9F9; |
| 142 | + border: 1px dashed #2F6FAB; |
| 143 | + color: black; |
| 144 | + |
| 145 | + /* fix up space between <tr> */ |
| 146 | + border-collapse: collapse; |
137 | 147 | } |
138 | | -.mw-codereview-diff ins { |
| 148 | +.mw-codereview-diff td { |
| 149 | + margin:0; |
| 150 | + |
| 151 | + /* keep padding on left and right just like <pre> |
| 152 | + * top bottom paddings are defined below for first/last childs |
| 153 | + */ |
| 154 | + padding:0 1em; |
| 155 | + |
| 156 | + /* respect white spaces just like <pre> */ |
| 157 | + white-space: pre; |
| 158 | +} |
| 159 | + |
| 160 | +/* "table border-collapse: collapse;" overrides padding |
| 161 | + * The two next rules mimic <pre> padding by applying one to the first |
| 162 | + * and last childs |
| 163 | + */ |
| 164 | +.mw-codereview-diff tr:first-child td { |
| 165 | + padding-top: 1em; |
| 166 | +} |
| 167 | +.mw-codereview-diff tr:last-child td { |
| 168 | + padding-bottom: 1em; |
| 169 | +} |
| 170 | + |
| 171 | +.mw-codereview-diff td.ins { |
139 | 172 | text-decoration: none; |
140 | 173 | color: green; |
141 | 174 | } |
142 | | - |
143 | | -.mw-codereview-diff del { |
| 175 | +.mw-codereview-diff td.del { |
144 | 176 | text-decoration: none; |
145 | 177 | color: red; |
146 | 178 | } |