annotate runtime/indent/html.vim @ 594:35cef95a6b76 v7.0168

updated for version 7.0168
author vimboss
date Mon, 12 Dec 2005 22:05:50 +0000
parents 3fc0f57ecb91
children 1cdd2661f34c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 " Description: html indenter
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 " Author: Johannes Zellner <johannes@zellner.org>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3 " Last Change: Tue, 27 Apr 2004 10:28:39 CEST
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4 " Globals: g:html_indent_tags -- indenting tags
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5 " g:html_indent_strict -- inhibit 'O O' elements
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6 " g:html_indent_strict_table -- inhibit 'O -' elements
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 " Only load this indent file when no other was loaded.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 if exists("b:did_indent")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 let b:did_indent = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 " [-- local settings (must come before aborting the script) --]
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 setlocal indentexpr=HtmlIndentGet(v:lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 setlocal indentkeys=o,O,*<Return>,<>>,<bs>,{,}
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 if exists('g:html_indent_tags')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 unlet g:html_indent_tags
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 " [-- helper function to assemble tag list --]
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 fun! <SID>HtmlIndentPush(tag)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 if exists('g:html_indent_tags')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 let g:html_indent_tags = g:html_indent_tags.'\|'.a:tag
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 let g:html_indent_tags = a:tag
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 endfun
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 " [-- <ELEMENT ? - - ...> --]
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 call <SID>HtmlIndentPush('a')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 call <SID>HtmlIndentPush('abbr')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 call <SID>HtmlIndentPush('acronym')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 call <SID>HtmlIndentPush('address')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 call <SID>HtmlIndentPush('b')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 call <SID>HtmlIndentPush('bdo')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 call <SID>HtmlIndentPush('big')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42 call <SID>HtmlIndentPush('blockquote')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 call <SID>HtmlIndentPush('button')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 call <SID>HtmlIndentPush('caption')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 call <SID>HtmlIndentPush('center')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 call <SID>HtmlIndentPush('cite')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 call <SID>HtmlIndentPush('code')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 call <SID>HtmlIndentPush('colgroup')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 call <SID>HtmlIndentPush('del')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 call <SID>HtmlIndentPush('dfn')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 call <SID>HtmlIndentPush('dir')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 call <SID>HtmlIndentPush('div')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 call <SID>HtmlIndentPush('dl')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 call <SID>HtmlIndentPush('em')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55 call <SID>HtmlIndentPush('fieldset')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 call <SID>HtmlIndentPush('font')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 call <SID>HtmlIndentPush('form')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 call <SID>HtmlIndentPush('frameset')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 call <SID>HtmlIndentPush('h1')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 call <SID>HtmlIndentPush('h2')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 call <SID>HtmlIndentPush('h3')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 call <SID>HtmlIndentPush('h4')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 call <SID>HtmlIndentPush('h5')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 call <SID>HtmlIndentPush('h6')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65 call <SID>HtmlIndentPush('i')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 call <SID>HtmlIndentPush('iframe')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67 call <SID>HtmlIndentPush('ins')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 call <SID>HtmlIndentPush('kbd')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 call <SID>HtmlIndentPush('label')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 call <SID>HtmlIndentPush('legend')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 call <SID>HtmlIndentPush('map')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 call <SID>HtmlIndentPush('menu')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 call <SID>HtmlIndentPush('noframes')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 call <SID>HtmlIndentPush('noscript')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75 call <SID>HtmlIndentPush('object')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 call <SID>HtmlIndentPush('ol')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 call <SID>HtmlIndentPush('optgroup')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 " call <SID>HtmlIndentPush('pre')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 call <SID>HtmlIndentPush('q')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 call <SID>HtmlIndentPush('s')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 call <SID>HtmlIndentPush('samp')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 call <SID>HtmlIndentPush('script')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 call <SID>HtmlIndentPush('select')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84 call <SID>HtmlIndentPush('small')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85 call <SID>HtmlIndentPush('span')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86 call <SID>HtmlIndentPush('strong')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87 call <SID>HtmlIndentPush('style')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88 call <SID>HtmlIndentPush('sub')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89 call <SID>HtmlIndentPush('sup')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90 call <SID>HtmlIndentPush('table')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91 call <SID>HtmlIndentPush('textarea')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92 call <SID>HtmlIndentPush('title')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93 call <SID>HtmlIndentPush('tt')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
94 call <SID>HtmlIndentPush('u')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
95 call <SID>HtmlIndentPush('ul')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
96 call <SID>HtmlIndentPush('var')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
97
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
99 " [-- <ELEMENT ? O O ...> --]
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100 if !exists('g:html_indent_strict')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101 call <SID>HtmlIndentPush('body')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
102 call <SID>HtmlIndentPush('head')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103 call <SID>HtmlIndentPush('html')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104 call <SID>HtmlIndentPush('tbody')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108 " [-- <ELEMENT ? O - ...> --]
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
109 if !exists('g:html_indent_strict_table')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
110 call <SID>HtmlIndentPush('th')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
111 call <SID>HtmlIndentPush('td')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
112 call <SID>HtmlIndentPush('tr')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
113 call <SID>HtmlIndentPush('tfoot')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
114 call <SID>HtmlIndentPush('thead')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
115 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117 delfun <SID>HtmlIndentPush
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
119 set cpo-=C
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
120
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
121 " [-- count indent-increasing tags of line a:lnum --]
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
122 fun! <SID>HtmlIndentOpen(lnum, pattern)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
123 let s = substitute('x'.getline(a:lnum),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
124 \ '.\{-}\(\(<\)\('.a:pattern.'\)\>\)', "\1", 'g')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
125 let s = substitute(s, "[^\1].*$", '', '')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
126 return strlen(s)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
127 endfun
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
128
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
129 " [-- count indent-decreasing tags of line a:lnum --]
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
130 fun! <SID>HtmlIndentClose(lnum, pattern)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
131 let s = substitute('x'.getline(a:lnum),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
132 \ '.\{-}\(\(<\)/\('.a:pattern.'\)\>>\)', "\1", 'g')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
133 let s = substitute(s, "[^\1].*$", '', '')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
134 return strlen(s)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
135 endfun
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
136
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
137 " [-- count indent-increasing '{' of (java|css) line a:lnum --]
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
138 fun! <SID>HtmlIndentOpenAlt(lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
139 return strlen(substitute(getline(a:lnum), '[^{]\+', '', 'g'))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
140 endfun
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
141
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
142 " [-- count indent-decreasing '}' of (java|css) line a:lnum --]
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
143 fun! <SID>HtmlIndentCloseAlt(lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
144 return strlen(substitute(getline(a:lnum), '[^}]\+', '', 'g'))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
145 endfun
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
146
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
147 " [-- return the sum of indents respecting the syntax of a:lnum --]
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
148 fun! <SID>HtmlIndentSum(lnum, style)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
149 if a:style == match(getline(a:lnum), '^\s*</')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
150 if a:style == match(getline(a:lnum), '^\s*</\<\('.g:html_indent_tags.'\)\>')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
151 let open = <SID>HtmlIndentOpen(a:lnum, g:html_indent_tags)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
152 let close = <SID>HtmlIndentClose(a:lnum, g:html_indent_tags)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
153 if 0 != open || 0 != close
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
154 return open - close
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
155 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
156 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
157 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
158 if '' != &syntax &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
159 \ synIDattr(synID(a:lnum, 1, 1), 'name') =~ '\(css\|java\).*' &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
160 \ synIDattr(synID(a:lnum, strlen(getline(a:lnum)), 1), 'name')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
161 \ =~ '\(css\|java\).*'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
162 if a:style == match(getline(a:lnum), '^\s*}')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
163 return <SID>HtmlIndentOpenAlt(a:lnum) - <SID>HtmlIndentCloseAlt(a:lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
164 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
165 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
166 return 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
167 endfun
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
168
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
169 fun! HtmlIndentGet(lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
170 " Find a non-empty line above the current line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
171 let lnum = prevnonblank(a:lnum - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
172
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
173 " Hit the start of the file, use zero indent.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
174 if lnum == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
175 return 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
176 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
177
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
178 let restore_ic = &ic
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
179 setlocal ic " ignore case
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
180
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
181 " [-- special handling for <pre>: no indenting --]
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
182 if getline(a:lnum) =~ '\c</pre>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
183 \ || 0 < searchpair('\c<pre>', '', '\c</pre>', 'nWb')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
184 \ || 0 < searchpair('\c<pre>', '', '\c</pre>', 'nW')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
185 " we're in a line with </pre> or inside <pre> ... </pre>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
186 return -1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
187 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
188
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
189 " [-- special handling for <javascript>: use cindent --]
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
190 let js = '<script.*type\s*=\s*.*java'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
191 if 0 < searchpair(js, '', '</script>', 'nWb')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
192 \ || 0 < searchpair(js, '', '</script>', 'nW')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
193 " we're inside javascript
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
194 if getline(lnum) !~ js && getline(a:lnum) != '</script>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
195 return cindent(a:lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
196 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
197 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
198
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
199 if getline(lnum) =~ '\c</pre>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
200 " line before the current line a:lnum contains
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
201 " a closing </pre>. --> search for line before
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
202 " starting <pre> to restore the indent.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
203 let preline = prevnonblank(search('\c<pre>', 'bW') - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
204 if preline > 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
205 return indent(preline)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
206 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
207 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
208
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
209 let ind = <SID>HtmlIndentSum(lnum, -1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
210 let ind = ind + <SID>HtmlIndentSum(a:lnum, 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
211
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
212 if restore_ic == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
213 setlocal noic
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
214 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
215
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
216 return indent(lnum) + (&sw * ind)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
217 endfun
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
218
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
219 " [-- EOF <runtime>/indent/html.vim --]