~canonical-sysadmins/wordpress/4.8.1

« back to all changes in this revision

Viewing changes to wp-admin/js/editor.js

  • Committer: Barry Price
  • Date: 2016-08-17 04:50:12 UTC
  • mfrom: (1.1.18 upstream)
  • Revision ID: barry.price@canonical.com-20160817045012-qfui81zhqnqv2ba9
Merge WP4.6 from upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
122
122
                                blocklist1 = blocklist + '|div|p',
123
123
                                blocklist2 = blocklist + '|pre',
124
124
                                preserve_linebreaks = false,
125
 
                                preserve_br = false;
 
125
                                preserve_br = false,
 
126
                                preserve = [];
126
127
 
127
128
                        if ( ! html ) {
128
129
                                return '';
129
130
                        }
130
131
 
131
 
                        // Protect pre|script tags
132
 
                        if ( html.indexOf( '<pre' ) !== -1 || html.indexOf( '<script' ) !== -1 ) {
 
132
                        // Preserve script and style tags.
 
133
                        if ( html.indexOf( '<script' ) !== -1 || html.indexOf( '<style' ) !== -1 ) {
 
134
                                html = html.replace( /<(script|style)[^>]*>[\s\S]*?<\/\1>/g, function( match ) {
 
135
                                        preserve.push( match );
 
136
                                        return '<wp-preserve>';
 
137
                                } );
 
138
                        }
 
139
 
 
140
                        // Protect pre tags.
 
141
                        if ( html.indexOf( '<pre' ) !== -1 ) {
133
142
                                preserve_linebreaks = true;
134
 
                                html = html.replace( /<(pre|script)[^>]*>[\s\S]+?<\/\1>/g, function( a ) {
 
143
                                html = html.replace( /<pre[^>]*>[\s\S]+?<\/pre>/g, function( a ) {
135
144
                                        a = a.replace( /<br ?\/?>(\r\n|\n)?/g, '<wp-line-break>' );
136
145
                                        a = a.replace( /<\/?p( [^>]*)?>(\r\n|\n)?/g, '<wp-line-break>' );
137
146
                                        return a.replace( /\r?\n/g, '<wp-line-break>' );
205
214
                                html = html.replace( /<wp-temp-br([^>]*)>/g, '<br$1>' );
206
215
                        }
207
216
 
 
217
                        // Put back preserved tags.
 
218
                        if ( preserve.length ) {
 
219
                                html = html.replace( /<wp-preserve>/g, function() {
 
220
                                        return preserve.shift();
 
221
                                } );
 
222
                        }
 
223
 
208
224
                        return html;
209
225
                }
210
226