r22205 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r22204‎ | r22205 | r22206 >
Date:18:34, 16 May 2007
Author:brion
Status:old
Tags:
Comment:
Update for MW 1.11 diff formatting.
<div> wrappers allow for use of overflow: auto to scroll long cells
instead of overflowing and causing page widening.
Modified paths:
  • /trunk/extensions/wikidiff2/wikidiff2.cpp (modified) (history)
  • /trunk/extensions/wikidiff2/wikidiff2.h (modified) (history)

Diff [purge]

Index: trunk/extensions/wikidiff2/wikidiff2.cpp
@@ -71,14 +71,14 @@
7272 // Print context
7373 ret +=
7474 "<tr>\n"
75 - " <td> </td>\n"
 75+ " <td class=\"diff-marker\"> </td>\n"
7676 " <td class=\"diff-context\">";
77 - print_htmlspecialchars(*linediff[i].from[j], ret);
 77+ print_div_htmlspecialchars(*linediff[i].from[j], ret);
7878 ret +=
7979 "</td>\n"
80 - " <td> </td>\n"
 80+ " <td class=\"diff-marker\"> </td>\n"
8181 " <td class=\"diff-context\">";
82 - print_htmlspecialchars(*linediff[i].from[j], ret);
 82+ print_div_htmlspecialchars(*linediff[i].from[j], ret);
8383 ret += "</td>\n</tr>\n";
8484 } else {
8585 showLineNumber = true;
@@ -117,18 +117,18 @@
118118 {
119119 ret += "<tr>\n"
120120 " <td colspan=\"2\">&nbsp;</td>\n"
121 - " <td>+</td>\n"
 121+ " <td class=\"diff-marker\">+</td>\n"
122122 " <td class=\"diff-addedline\">";
123 - print_htmlspecialchars(line, ret);
 123+ print_div_htmlspecialchars(line, ret);
124124 ret += "</td>\n</tr>\n";
125125 }
126126
127127 void print_del(const std::string & line, std::string & ret)
128128 {
129129 ret += "<tr>\n"
130 - " <td>-</td>\n"
 130+ " <td class=\"diff-marker\">-</td>\n"
131131 " <td class=\"diff-deletedline\">";
132 - print_htmlspecialchars(line, ret);
 132+ print_div_htmlspecialchars(line, ret);
133133 ret += "</td>\n"
134134 " <td colspan=\"2\">&nbsp;</td>\n"
135135 "</tr>\n";
@@ -146,14 +146,14 @@
147147
148148 // print twice; first for left side, then for right side
149149 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";
152152 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";
156156 print_worddiff_side(worddiff, true, ret);
157 - ret += "\n </td>\n"
 157+ ret += "\n </div></td>\n"
158158 "</tr>\n";
159159 }
160160
@@ -241,6 +241,16 @@
242242 }
243243 }
244244
 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+
245255 void print_htmlspecialchars(const std::string & input, std::string & ret)
246256 {
247257 size_t start = 0;
Index: trunk/extensions/wikidiff2/wikidiff2.h
@@ -28,6 +28,7 @@
2929 void split_tokens(const std::string & text, std::vector<Word> &tokens);
3030 void print_add(const std::string & line, std::string & ret);
3131 void print_del(const std::string & line, std::string & ret);
 32+void print_div_htmlspecialchars(const std::string & input, std::string & ret);
3233 void print_htmlspecialchars(const std::string & input, std::string & ret);
3334 void debug_print_worddiff(Diff<Word> &worddiff, std::string &ret);
3435 const char *wikidiff2_do_diff(const char *text1, const char *text2, int num_lines_context);

Follow-up revisions

RevisionCommit summaryAuthorDate
r67994* Added Thai word break support. Adds a libthai dependency....tstarling13:29, 14 June 2010