Skip to content

Commit

Permalink
Removing formathtml function since it is never going to work.
Browse files Browse the repository at this point in the history
  • Loading branch information
julmis committed Jul 30, 2006
1 parent 980b1e0 commit 9978506
Showing 1 changed file with 0 additions and 53 deletions.
53 changes: 0 additions & 53 deletions lib/editor/htmlarea/htmlarea.php
Expand Up @@ -2353,8 +2353,6 @@ function getMozSelection(txtarea) {
break; // skip comments, for now.
}

// Still not workin' correctly...
//return HTMLArea.formathtml(html);
return html;
};

Expand Down Expand Up @@ -2479,54 +2477,3 @@ function hex(d) {
return el;
return null;
};

HTMLArea.formathtml = function (html) {
// Original idea from FCKeditor
// http://www.fckeditor.net/
// by Frederico Caldeira Knabben

var indentchar = ' ';
var format = new Object();
format.regex = new Object();

format.regex.tagopen = /<[^\/](P|DIV|H1|H2|H3|H4|H5|H6|ADDRESS|PRE|OL|UL|LI|TITLE|META|LINK|BASE|SCRIPT|LINK|TD|AREA|OPTION)[^>]*>/gi ;
format.regex.tagclose = /<\/{1}(P|DIV|H1|H2|H3|H4|H5|H6|ADDRESS|PRE|OL|UL|LI|TITLE|META|LINK|BASE|SCRIPT|LINK|TD|AREA|OPTION)[^>]*>/gi ;
format.regex.newlines = /<(BR|HR)[^>]>/gi ;
format.regex.tagsmain = /<\/?(HTML|HEAD|BODY|FORM|TABLE|TBODY|THEAD|TR)[^>]*>/gi ;
format.regex.splitter = /\s*\n+\s*/g ;
format.regex.notouchy = /<\/?(span|font)[^>]*>/gi;

format.regex.indent = /^<(HTML|HEAD|BODY|FORM|TABLE|TBODY|THEAD|TR|UL|OL)[ \/>]/i ;
format.regex.unindent = /^<\/(HTML|HEAD|BODY|FORM|TABLE|TBODY|THEAD|TR|UL|OL)[ >]/i ;
format.regex.inremove = new RegExp( indentchar );

//var formatted = html.replace( format.regex.tagopen, '\n$&' );
//formatted = formatted.replace( format.regex.tagclose, '$&\n' );
//formatted = formatted.replace( format.regex.taglines, '$&\n' );
//formatted = formatted.replace( format.regex.tagsmain, '\n$&\n' );

var indentation = '';
var tolines = html.split(format.regex.splitter);
var formatted = '';

for (var i = 0; i < tolines.length; i++) {
var line = tolines[i];
if (line.length < 1) {
continue;
}
if (format.regex.unindent.test(line) && !format.regex.notouchy.test(line)) {
indentation = indentation.replace(format.regex.inremove, '') ;
}

line = !format.regex.notouchy.test(line) ? line.replace(format.regex.tagopen, '\n$&') : line;
line = !format.regex.notouchy.test(line) ? line.replace(format.regex.tagclose, '$&\n'): line;
line = !format.regex.notouchy.test(line) ? line.replace(format.regex.tagsmain, '$&\n'): line;

formatted += indentation + line;

if (format.regex.indent.test(line)) {
indentation += indentchar;
}
}
return formatted;
}

0 comments on commit 9978506

Please sign in to comment.