Index: trunk/extensions/wikidiff2/wikidiff2.cpp |
— | — | @@ -71,14 +71,14 @@ |
72 | 72 | // Print context |
73 | 73 | ret += |
74 | 74 | "<tr>\n" |
75 | | - " <td> </td>\n" |
| 75 | + " <td class=\"diff-marker\"> </td>\n" |
76 | 76 | " <td class=\"diff-context\">"; |
77 | | - print_htmlspecialchars(*linediff[i].from[j], ret); |
| 77 | + print_div_htmlspecialchars(*linediff[i].from[j], ret); |
78 | 78 | ret += |
79 | 79 | "</td>\n" |
80 | | - " <td> </td>\n" |
| 80 | + " <td class=\"diff-marker\"> </td>\n" |
81 | 81 | " <td class=\"diff-context\">"; |
82 | | - print_htmlspecialchars(*linediff[i].from[j], ret); |
| 82 | + print_div_htmlspecialchars(*linediff[i].from[j], ret); |
83 | 83 | ret += "</td>\n</tr>\n"; |
84 | 84 | } else { |
85 | 85 | showLineNumber = true; |
— | — | @@ -117,18 +117,18 @@ |
118 | 118 | { |
119 | 119 | ret += "<tr>\n" |
120 | 120 | " <td colspan=\"2\"> </td>\n" |
121 | | - " <td>+</td>\n" |
| 121 | + " <td class=\"diff-marker\">+</td>\n" |
122 | 122 | " <td class=\"diff-addedline\">"; |
123 | | - print_htmlspecialchars(line, ret); |
| 123 | + print_div_htmlspecialchars(line, ret); |
124 | 124 | ret += "</td>\n</tr>\n"; |
125 | 125 | } |
126 | 126 | |
127 | 127 | void print_del(const std::string & line, std::string & ret) |
128 | 128 | { |
129 | 129 | ret += "<tr>\n" |
130 | | - " <td>-</td>\n" |
| 130 | + " <td class=\"diff-marker\">-</td>\n" |
131 | 131 | " <td class=\"diff-deletedline\">"; |
132 | | - print_htmlspecialchars(line, ret); |
| 132 | + print_div_htmlspecialchars(line, ret); |
133 | 133 | ret += "</td>\n" |
134 | 134 | " <td colspan=\"2\"> </td>\n" |
135 | 135 | "</tr>\n"; |
— | — | @@ -146,14 +146,14 @@ |
147 | 147 | |
148 | 148 | // print twice; first for left side, then for right side |
149 | 149 | ret += "<tr>\n" |
150 | | - " <td>-</td>\n" |
151 | | - " <td class=\"diff-deletedline\">\n"; |
| 150 | + " <td class=\"diff-marker\">-</td>\n" |
| 151 | + " <td class=\"diff-deletedline\"><div>\n"; |
152 | 152 | print_worddiff_side(worddiff, false, ret); |
153 | | - ret += "\n </td>\n" |
154 | | - " <td>+</td>\n" |
155 | | - " <td class=\"diff-addedline\">\n"; |
| 153 | + ret += "\n </div></td>\n" |
| 154 | + " <td class=\"diff-marker\">+</td>\n" |
| 155 | + " <td class=\"diff-addedline\"><div>\n"; |
156 | 156 | print_worddiff_side(worddiff, true, ret); |
157 | | - ret += "\n </td>\n" |
| 157 | + ret += "\n </div></td>\n" |
158 | 158 | "</tr>\n"; |
159 | 159 | } |
160 | 160 | |
— | — | @@ -241,6 +241,16 @@ |
242 | 242 | } |
243 | 243 | } |
244 | 244 | |
| 245 | +void print_div_htmlspecialchars(const std::string & input, std::string & ret) |
| 246 | +{ |
| 247 | + // Wrap string in a <div> if it's not empty |
| 248 | + if (input.size() > 0) { |
| 249 | + ret.append("<div>"); |
| 250 | + print_htmlspecialchars(input, ret); |
| 251 | + ret.append("</div>"); |
| 252 | + } |
| 253 | +} |
| 254 | + |
245 | 255 | void print_htmlspecialchars(const std::string & input, std::string & ret) |
246 | 256 | { |
247 | 257 | size_t start = 0; |
Index: trunk/extensions/wikidiff2/wikidiff2.h |
— | — | @@ -28,6 +28,7 @@ |
29 | 29 | void split_tokens(const std::string & text, std::vector<Word> &tokens); |
30 | 30 | void print_add(const std::string & line, std::string & ret); |
31 | 31 | void print_del(const std::string & line, std::string & ret); |
| 32 | +void print_div_htmlspecialchars(const std::string & input, std::string & ret); |
32 | 33 | void print_htmlspecialchars(const std::string & input, std::string & ret); |
33 | 34 | void debug_print_worddiff(Diff<Word> &worddiff, std::string &ret); |
34 | 35 | const char *wikidiff2_do_diff(const char *text1, const char *text2, int num_lines_context); |