Index: trunk/extensions/ApiSandbox/ext.apiSandbox.js |
— | — | @@ -76,22 +76,26 @@ |
77 | 77 | } |
78 | 78 | } |
79 | 79 | |
| 80 | + function smartEscape( s ) { |
| 81 | + s = mw.html.escape( s ); |
| 82 | + if ( s.indexOf( '\n ' ) >= 0 ) { |
| 83 | + s = s.replace( /^(.*?)((?:\n\s+\*?[^\n]*)+)(.*?)$/m, '$1<ul>$2</ul>$3' ); |
| 84 | + s = s.replace( /\n\s+\*?([^\n]*)/g, '\n<li>$1</li>' ); |
| 85 | + } |
| 86 | + s = s.replace( /\n(?!<)/, '\n<br/>' ); |
| 87 | + return s; |
| 88 | + } |
| 89 | + |
80 | 90 | function createInputs( info ) { |
81 | | - help.text( info.description ); |
| 91 | + help.html( smartEscape( info.description ) ); |
82 | 92 | var s = '<table class="api-sandbox-options">\n<tbody>'; |
83 | 93 | for ( var i = 0; i < info.parameters.length; i++ ) { |
84 | 94 | var param = info.parameters[i]; |
85 | 95 | var name = info.prefix + param.name; |
86 | | - var desc = mw.html.escape( param.description ); |
87 | | - if ( desc.indexOf( '\n ' ) >= 0 ) { |
88 | | - desc = desc.replace( /^(.*?)((?:\n\s+[^\n]*)+)(.*?)$/m, '$1<ul>$2</ul>$3' ); |
89 | | - desc = desc.replace( /\n\s+([^\n]*)/g, '\n<li>$1</li>' ); |
90 | | - } |
91 | | - desc = desc.replace( /\n(?!<)/, '\n<br/>' ); |
92 | 96 | |
93 | 97 | s += '<tr><td class="api-sandbox-label"><label for="param-' + name + '">' + name + '=</label></td>' |
94 | 98 | + '<td class="api-sandbox-value">' + input( param, name ) |
95 | | - + '</td><td>' + desc + '</td></tr>'; |
| 99 | + + '</td><td>' + smartEscape( param.description ) + '</td></tr>'; |
96 | 100 | } |
97 | 101 | s += '\n</tbody>\n</table>\n'; |
98 | 102 | further.html( s ); |