~ubuntu-branches/ubuntu/intrepid/moin/intrepid-updates

« back to all changes in this revision

Viewing changes to wiki/htdocs/applets/FCKeditor/editor/_source/internals/fckcodeformatter.js

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2006-02-14 16:09:24 UTC
  • mfrom: (0.2.13 upstream)
  • Revision ID: james.westby@ubuntu.com-20060214160924-fyrx3gvknzqvt4vj
Tags: 1.5.2-1ubuntu1
Drop python2.3 package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
        FCKCodeFormatter.Regex = new Object() ;
27
27
 
28
28
        // Regex for line breaks.
29
 
        FCKCodeFormatter.Regex.BlocksOpener = /\<(P|DIV|H1|H2|H3|H4|H5|H6|ADDRESS|PRE|OL|UL|LI|TITLE|META|LINK|BASE|SCRIPT|LINK|TD|AREA|OPTION)[^\>]*\>/gi ;
30
 
        FCKCodeFormatter.Regex.BlocksCloser = /\<\/(P|DIV|H1|H2|H3|H4|H5|H6|ADDRESS|PRE|OL|UL|LI|TITLE|META|LINK|BASE|SCRIPT|LINK|TD|AREA|OPTION)[^\>]*\>/gi ;
 
29
        FCKCodeFormatter.Regex.BlocksOpener = /\<(P|DIV|H1|H2|H3|H4|H5|H6|ADDRESS|PRE|OL|UL|LI|TITLE|META|LINK|BASE|SCRIPT|LINK|TD|TH|AREA|OPTION)[^\>]*\>/gi ;
 
30
        FCKCodeFormatter.Regex.BlocksCloser = /\<\/(P|DIV|H1|H2|H3|H4|H5|H6|ADDRESS|PRE|OL|UL|LI|TITLE|META|LINK|BASE|SCRIPT|LINK|TD|TH|AREA|OPTION)[^\>]*\>/gi ;
31
31
 
32
32
        FCKCodeFormatter.Regex.NewLineTags      = /\<(BR|HR)[^\>]\>/gi ;
33
33
 
40
40
        FCKCodeFormatter.Regex.DecreaseIndent = /^\<\/(HTML|HEAD|BODY|FORM|TABLE|TBODY|THEAD|TR|UL|OL)[ \>]/i ;
41
41
        FCKCodeFormatter.Regex.FormatIndentatorRemove = new RegExp( FCKConfig.FormatIndentator ) ;
42
42
 
 
43
        FCKCodeFormatter.Regex.ProtectedTags = /(<PRE[^>]*>)([\s\S]*?)(<\/PRE>)/gi ;
 
44
 
 
45
        FCKCodeFormatter._ProtectData = function( outer, opener, data, closer )
 
46
        {
 
47
                return opener + '___FCKpd___' + FCKCodeFormatter.ProtectedData.addItem( data ) + closer ;
 
48
        }
 
49
 
43
50
        FCKCodeFormatter.Format = function( html )
44
51
        {
 
52
                // Protected content that remain untouched during the
 
53
                // process go in the following array.
 
54
                FCKCodeFormatter.ProtectedData = new Array() ;
 
55
                
 
56
                var sFormatted = html.replace( this.Regex.ProtectedTags, FCKCodeFormatter._ProtectData ) ;
 
57
        
45
58
                // Line breaks.
46
 
                var sFormatted  = html.replace( this.Regex.BlocksOpener, '\n$&' ) ; ;
 
59
                 sFormatted             = sFormatted.replace( this.Regex.BlocksOpener, '\n$&' ) ; ;
47
60
                sFormatted              = sFormatted.replace( this.Regex.BlocksCloser, '$&\n' ) ;
48
61
                sFormatted              = sFormatted.replace( this.Regex.NewLineTags, '$&\n' ) ;
49
62
                sFormatted              = sFormatted.replace( this.Regex.MainTags, '\n$&\n' ) ;
69
82
                        if ( this.Regex.IncreaseIndent.test( sLine ) )
70
83
                                sIndentation += FCKConfig.FormatIndentator ;
71
84
                }
 
85
                
 
86
                // Now we put back the protected data.
 
87
                for ( var i = 0 ; i < FCKCodeFormatter.ProtectedData.length ; i++ )
 
88
                {
 
89
                        var oRegex = new RegExp( '___FCKpd___' + i ) ;
 
90
                        sFormatted = sFormatted.replace( oRegex, FCKCodeFormatter.ProtectedData[i] ) ;
 
91
                }
72
92
 
73
93
                return sFormatted.trim() ;
74
94
        }