blob: d1f439905ab5b178e746d34ab3cefcb7b904904f [file] [log] [blame]
Bram Moolenaarec7944a2013-06-12 21:29:15 +02001" Vim indent script for HTML
2" General: "{{{
3" File: html.vim (Vimscript #2075)
4" Author: Andy Wokula <anwoku@yahoo.de>
Bram Moolenaar946e27a2014-06-25 18:50:27 +02005" Last Change: 2014 Jun 19
Bram Moolenaar52b91d82013-06-15 21:39:51 +02006" Rev Days: 13
7" Version: 0.9
Bram Moolenaarec7944a2013-06-12 21:29:15 +02008" Vim Version: Vim7
9" Description:
10" Improved version of the distributed html indent script, faster on a
11" range of lines.
12"
13" Credits:
14" indent/html.vim (2006 Jun 05) from J. Zellner
15" indent/css.vim (2006 Dec 20) from N. Weibull
16"
17" History:
Bram Moolenaar52b91d82013-06-15 21:39:51 +020018" 2012 Oct 21 (v0.9) added support for shiftwidth()
19" 2011 Sep 09 (v0.8) added HTML5 tags (thx to J. Zuckerman)
20" 2008 Apr 28 (v0.6) revised customization
21" 2008 Mar 09 (v0.5) fixed 'indk' issue (thx to C.J. Robinson)
Bram Moolenaarec7944a2013-06-12 21:29:15 +020022" }}}
Bram Moolenaar071d4272004-06-13 20:20:40 +000023
Bram Moolenaarec7944a2013-06-12 21:29:15 +020024" Init Folklore, check user settings (2nd time ++) "{{{
Bram Moolenaar071d4272004-06-13 20:20:40 +000025if exists("b:did_indent")
26 finish
27endif
28let b:did_indent = 1
29
Bram Moolenaarec7944a2013-06-12 21:29:15 +020030setlocal indentexpr=HtmlIndent()
31setlocal indentkeys=o,O,<Return>,<>>,{,},!^F
Bram Moolenaar071d4272004-06-13 20:20:40 +000032
Bram Moolenaar946e27a2014-06-25 18:50:27 +020033" Needed for % to work when finding start of a tag.
34setlocal matchpairs+=<:>
35
Bram Moolenaarec7944a2013-06-12 21:29:15 +020036let b:indent = {"lnum": -1}
37let b:undo_indent = "set inde< indk<| unlet b:indent"
Bram Moolenaar071d4272004-06-13 20:20:40 +000038
Bram Moolenaarec7944a2013-06-12 21:29:15 +020039" Load Once:
40if exists("*HtmlIndent")
41 call HtmlIndent_CheckUserSettings()
42 finish
Bram Moolenaar071d4272004-06-13 20:20:40 +000043endif
44
Bram Moolenaar52b91d82013-06-15 21:39:51 +020045" Patch 7.3.694
46if exists('*shiftwidth')
47 let s:ShiftWidth = function('shiftwidth')
48else
49 func! s:ShiftWidth()
50 return &shiftwidth
51 endfunc
52endif
53
Bram Moolenaar91170f82006-05-05 21:15:17 +000054let s:cpo_save = &cpo
Bram Moolenaar071d4272004-06-13 20:20:40 +000055set cpo-=C
Bram Moolenaarec7944a2013-06-12 21:29:15 +020056"}}}
Bram Moolenaar071d4272004-06-13 20:20:40 +000057
Bram Moolenaarec7944a2013-06-12 21:29:15 +020058func! HtmlIndent_CheckUserSettings() "{{{
59 if exists("g:html_indent_inctags")
60 call s:AddITags(split(g:html_indent_inctags, ","))
Bram Moolenaar071d4272004-06-13 20:20:40 +000061 endif
Bram Moolenaarec7944a2013-06-12 21:29:15 +020062 if exists("g:html_indent_autotags")
63 call s:RemoveITags(split(g:html_indent_autotags, ","))
Bram Moolenaar071d4272004-06-13 20:20:40 +000064 endif
65
Bram Moolenaarec7944a2013-06-12 21:29:15 +020066 let indone = {"zero": 0
67 \,"auto": "indent(prevnonblank(v:lnum-1))"
Bram Moolenaar52b91d82013-06-15 21:39:51 +020068 \,"inc": "b:indent.blocktagind + s:ShiftWidth()"}
Bram Moolenaarec7944a2013-06-12 21:29:15 +020069 if exists("g:html_indent_script1")
70 let s:js1indent = get(indone, g:html_indent_script1, indone.zero)
71 endif
72 if exists("g:html_indent_style1")
73 let s:css1indent = get(indone, g:html_indent_style1, indone.zero)
74 endif
75endfunc "}}}
Bram Moolenaar071d4272004-06-13 20:20:40 +000076
Bram Moolenaarec7944a2013-06-12 21:29:15 +020077" Init Script Vars "{{{
Bram Moolenaar946e27a2014-06-25 18:50:27 +020078let s:lasttick = 0
Bram Moolenaarec7944a2013-06-12 21:29:15 +020079let s:css1indent = 0
80let s:js1indent = 0
81" not to be changed:
82let s:endtags = [0,0,0,0,0,0,0,0] " some places unused
83let s:newstate = {}
84let s:countonly = 0
85 "}}}
86func! s:AddITags(taglist) "{{{
87 for itag in a:taglist
88 let s:indent_tags[itag] = 1
89 let s:indent_tags['/'.itag] = -1
90 endfor
91endfunc "}}}
92func! s:AddBlockTag(tag, id, ...) "{{{
93 if !(a:id >= 2 && a:id < 2+len(s:endtags))
94 return
95 endif
96 let s:indent_tags[a:tag] = a:id
97 if a:0 == 0
98 let s:indent_tags['/'.a:tag] = -a:id
99 let s:endtags[a:id-2] = "</".a:tag.">"
100 else
101 let s:indent_tags[a:1] = -a:id
102 let s:endtags[a:id-2] = a:1
103 endif
104endfunc "}}}
105func! s:RemoveITags(taglist) "{{{
106 " remove itags (protect blocktags from being removed)
107 for itag in a:taglist
108 if !has_key(s:indent_tags, itag) || s:indent_tags[itag] != 1
109 continue
Bram Moolenaar91170f82006-05-05 21:15:17 +0000110 endif
Bram Moolenaarec7944a2013-06-12 21:29:15 +0200111 unlet s:indent_tags[itag]
112 if itag =~ '^\w\+$'
113 unlet s:indent_tags["/".itag]
114 endif
115 endfor
116endfunc "}}}
117" Add Indent Tags: {{{
118if !exists("s:indent_tags")
119 let s:indent_tags = {}
120endif
121
122" old tags:
123call s:AddITags(['a', 'abbr', 'acronym', 'address', 'b', 'bdo', 'big',
124 \ 'blockquote', 'button', 'caption', 'center', 'cite', 'code', 'colgroup',
125 \ 'del', 'dfn', 'dir', 'div', 'dl', 'em', 'fieldset', 'font', 'form',
126 \ 'frameset', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'i', 'iframe', 'ins', 'kbd',
127 \ 'label', 'legend', 'map', 'menu', 'noframes', 'noscript', 'object', 'ol',
128 \ 'optgroup', 'q', 's', 'samp', 'select', 'small', 'span', 'strong', 'sub',
129 \ 'sup', 'table', 'textarea', 'title', 'tt', 'u', 'ul', 'var', 'th', 'td',
130 \ 'tr', 'tfoot', 'thead'])
131
132" tags added 2011 Sep 09 (especially HTML5 tags):
133call s:AddITags(['area', 'article', 'aside', 'audio', 'bdi', 'canvas',
134 \ 'command', 'datalist', 'details', 'embed', 'figure', 'footer',
135 \ 'header', 'group', 'keygen', 'mark', 'math', 'meter', 'nav', 'output',
136 \ 'progress', 'ruby', 'section', 'svg', 'texture', 'time', 'video',
137 \ 'wbr', 'text'])
138
139"}}}
140" Add Block Tags: contain alien content "{{{
141call s:AddBlockTag('pre', 2)
142call s:AddBlockTag('script', 3)
143call s:AddBlockTag('style', 4)
144call s:AddBlockTag('<!--', 5, '-->')
145"}}}
146
147func! s:CountITags(...) "{{{
148
149 " relative indent steps for current line [unit &sw]:
150 let s:curind = 0
151 " relative indent steps for next line [unit &sw]:
152 let s:nextrel = 0
153
154 if a:0==0
155 let s:block = s:newstate.block
Bram Moolenaar946e27a2014-06-25 18:50:27 +0200156 let tmpline = substitute(s:curline, '<\zs/\=\w\+\>\|<!--\|-->', '\=s:CheckTag(submatch(0))', 'g')
Bram Moolenaarec7944a2013-06-12 21:29:15 +0200157 if s:block == 3
158 let s:newstate.scripttype = s:GetScriptType(matchstr(tmpline, '\C.*<SCRIPT\>\zs[^>]*'))
159 endif
160 let s:newstate.block = s:block
161 else
162 let s:block = 0 " assume starting outside of a block
163 let s:countonly = 1 " don't change state
Bram Moolenaar946e27a2014-06-25 18:50:27 +0200164 let tmpline = substitute(s:altline, '<\zs/\=\w\+\>\|<!--\|-->', '\=s:CheckTag(submatch(0))', 'g')
Bram Moolenaarec7944a2013-06-12 21:29:15 +0200165 let s:countonly = 0
166 endif
167endfunc "}}}
168func! s:CheckTag(itag) "{{{
169 " "tag" or "/tag" or "<!--" or "-->"
170 let ind = get(s:indent_tags, a:itag)
171 if ind == -1
172 " closing tag
173 if s:block != 0
174 " ignore itag within a block
175 return "foo"
176 endif
177 if s:nextrel == 0
178 let s:curind -= 1
179 else
180 let s:nextrel -= 1
181 endif
182 " if s:curind >= 1
183 " let s:curind -= 1
184 " else
185 " let s:nextrel -= 1
186 " endif
187 elseif ind == 1
188 " opening tag
189 if s:block != 0
190 return "foo"
191 endif
192 let s:nextrel += 1
193 elseif ind != 0
194 " block-tag (opening or closing)
195 return s:Blocktag(a:itag, ind)
196 endif
197 " else ind==0 (other tag found): keep indent
198 return "foo" " no matter
199endfunc "}}}
200func! s:Blocktag(blocktag, ind) "{{{
201 if a:ind > 0
202 " a block starts here
203 if s:block != 0
204 " already in a block (nesting) - ignore
205 " especially ignore comments after other blocktags
206 return "foo"
207 endif
208 let s:block = a:ind " block type
209 if s:countonly
210 return "foo"
211 endif
212 let s:newstate.blocklnr = v:lnum
213 " save allover indent for the endtag
Bram Moolenaar52b91d82013-06-15 21:39:51 +0200214 let s:newstate.blocktagind = b:indent.baseindent + (s:nextrel + s:curind) * s:ShiftWidth()
Bram Moolenaarec7944a2013-06-12 21:29:15 +0200215 if a:ind == 3
216 return "SCRIPT" " all except this must be lowercase
217 " line is to be checked again for the type attribute
218 endif
219 else
220 let s:block = 0
221 " we get here if starting and closing block-tag on same line
222 endif
223 return "foo"
224endfunc "}}}
225func! s:GetScriptType(str) "{{{
226 if a:str == "" || a:str =~ "java"
227 return "javascript"
228 else
229 return ""
230 endif
231endfunc "}}}
232
233func! s:FreshState(lnum) "{{{
234 " Look back in the file (lines 1 to a:lnum-1) to calc a state for line
235 " a:lnum. A state is to know ALL relevant details about the lines
236 " 1..a:lnum-1, initial calculating (here!) can be slow, but updating is
237 " fast (incremental).
238 " State:
239 " lnum last indented line == prevnonblank(a:lnum - 1)
240 " block = 0 a:lnum located within special tag: 0:none, 2:<pre>,
241 " 3:<script>, 4:<style>, 5:<!--
242 " baseindent use this indent for line a:lnum as a start - kind of
243 " autoindent (if block==0)
244 " scripttype = '' type attribute of a script tag (if block==3)
245 " blocktagind indent for current opening (get) and closing (set)
246 " blocktag (if block!=0)
247 " blocklnr lnum of starting blocktag (if block!=0)
248 " inattr line {lnum} starts with attributes of a tag
249 let state = {}
250 let state.lnum = prevnonblank(a:lnum - 1)
251 let state.scripttype = ""
252 let state.blocktagind = -1
253 let state.block = 0
254 let state.baseindent = 0
255 let state.blocklnr = 0
256 let state.inattr = 0
257
258 if state.lnum == 0
259 return state
260 endif
261
262 " Heuristic:
263 " remember startline state.lnum
264 " look back for <pre, </pre, <script, </script, <style, </style tags
265 " remember stopline
266 " if opening tag found,
267 " assume a:lnum within block
268 " else
269 " look back in result range (stopline, startline) for comment
270 " \ delimiters (<!--, -->)
271 " if comment opener found,
272 " assume a:lnum within comment
273 " else
274 " assume usual html for a:lnum
275 " if a:lnum-1 has a closing comment
276 " look back to get indent of comment opener
277 " FI
278
279 " look back for blocktag
280 call cursor(a:lnum, 1)
281 let [stopline, stopcol] = searchpos('\c<\zs\/\=\%(pre\>\|script\>\|style\>\)', "bW")
282 " fugly ... why isn't there searchstr()
283 let tagline = tolower(getline(stopline))
284 let blocktag = matchstr(tagline, '\/\=\%(pre\>\|script\>\|style\>\)', stopcol-1)
285 if stopline > 0 && blocktag[0] != "/"
286 " opening tag found, assume a:lnum within block
287 let state.block = s:indent_tags[blocktag]
288 if state.block == 3
289 let state.scripttype = s:GetScriptType(matchstr(tagline, '\>[^>]*', stopcol))
290 endif
291 let state.blocklnr = stopline
292 " check preceding tags in the line:
293 let s:altline = tagline[: stopcol-2]
294 call s:CountITags(1)
Bram Moolenaar52b91d82013-06-15 21:39:51 +0200295 let state.blocktagind = indent(stopline) + (s:curind + s:nextrel) * s:ShiftWidth()
Bram Moolenaarec7944a2013-06-12 21:29:15 +0200296 return state
297 elseif stopline == state.lnum
298 " handle special case: previous line (= state.lnum) contains a
299 " closing blocktag which is preceded by line-noise;
300 " blocktag == "/..."
301 let swendtag = match(tagline, '^\s*</') >= 0
302 if !swendtag
303 let [bline, bcol] = searchpos('<'.blocktag[1:].'\>', "bW")
304 let s:altline = tolower(getline(bline)[: bcol-2])
305 call s:CountITags(1)
Bram Moolenaar52b91d82013-06-15 21:39:51 +0200306 let state.baseindent = indent(bline) + (s:nextrel+s:curline) * s:ShiftWidth()
Bram Moolenaarec7944a2013-06-12 21:29:15 +0200307 return state
308 endif
309 endif
310
311 " else look back for comment
312 call cursor(a:lnum, 1)
313 let [comline, comcol, found] = searchpos('\(<!--\)\|-->', 'bpW', stopline)
314 if found == 2
315 " comment opener found, assume a:lnum within comment
316 let state.block = 5
317 let state.blocklnr = comline
318 " check preceding tags in the line:
319 let s:altline = tolower(getline(comline)[: comcol-2])
320 call s:CountITags(1)
Bram Moolenaar52b91d82013-06-15 21:39:51 +0200321 let state.blocktagind = indent(comline) + (s:curind + s:nextrel) * s:ShiftWidth()
Bram Moolenaarec7944a2013-06-12 21:29:15 +0200322 return state
323 endif
324
325 " else within usual html
326 let s:altline = tolower(getline(state.lnum))
Bram Moolenaar946e27a2014-06-25 18:50:27 +0200327
Bram Moolenaarec7944a2013-06-12 21:29:15 +0200328 " check a:lnum-1 for closing comment (we need indent from the opening line)
329 let comcol = stridx(s:altline, '-->')
330 if comcol >= 0
331 call cursor(state.lnum, comcol+1)
332 let [comline, comcol] = searchpos('<!--', 'bW')
333 if comline == state.lnum
334 let s:altline = s:altline[: comcol-2]
335 else
336 let s:altline = tolower(getline(comline)[: comcol-2])
337 endif
338 call s:CountITags(1)
Bram Moolenaar52b91d82013-06-15 21:39:51 +0200339 let state.baseindent = indent(comline) + (s:nextrel+s:curline) * s:ShiftWidth()
Bram Moolenaarec7944a2013-06-12 21:29:15 +0200340 return state
341 " TODO check tags that follow "-->"
342 endif
343
Bram Moolenaar946e27a2014-06-25 18:50:27 +0200344 " Check if the previous line starts with end tag.
345 let swendtag = match(s:altline, '^\s*</') >= 0
346
347 " If previous line ended in a closing tag, line up with the opening tag.
348 " Avoids aligning with continuation lines.
349 " TODO: this assumes the start tag is at the start of a line.
350 if !swendtag && s:altline =~ '</\w\+\s*>\s*$'
351 call cursor(state.lnum, 99999)
352 normal F<h
353 " TODO: doesn't work for nested <br> and the like
354 let slnum = searchpair('<\w\+', '', '</\w', 'bW')
355 if slnum > 0
356 let state.baseindent = indent(slnum)
357 return state
358 endif
359 endif
360
Bram Moolenaarec7944a2013-06-12 21:29:15 +0200361 " else no comments
Bram Moolenaar946e27a2014-06-25 18:50:27 +0200362 let state.lnum = s:FindTagStart(state.lnum)
363 let s:altline = tolower(getline(state.lnum))
Bram Moolenaarec7944a2013-06-12 21:29:15 +0200364 call s:CountITags(1)
Bram Moolenaar52b91d82013-06-15 21:39:51 +0200365 let state.baseindent = indent(state.lnum) + s:nextrel * s:ShiftWidth()
Bram Moolenaarec7944a2013-06-12 21:29:15 +0200366 if !swendtag
Bram Moolenaar52b91d82013-06-15 21:39:51 +0200367 let state.baseindent += s:curind * s:ShiftWidth()
Bram Moolenaarec7944a2013-06-12 21:29:15 +0200368 endif
369 return state
370endfunc "}}}
371
372func! s:Alien2() "{{{
373 " <pre> block
374 return -1
375endfunc "}}}
376func! s:Alien3() "{{{
377 " <script> javascript
378 if prevnonblank(v:lnum-1) == b:indent.blocklnr
379 " indent for the first line after <script>
380 return eval(s:js1indent)
381 endif
382 if b:indent.scripttype == "javascript"
383 return cindent(v:lnum)
384 else
Bram Moolenaar071d4272004-06-13 20:20:40 +0000385 return -1
386 endif
Bram Moolenaarec7944a2013-06-12 21:29:15 +0200387endfunc "}}}
388func! s:Alien4() "{{{
389 " <style>
390 if prevnonblank(v:lnum-1) == b:indent.blocklnr
391 " indent for first content line
392 return eval(s:css1indent)
393 endif
394 return s:CSSIndent()
395endfunc
Bram Moolenaar071d4272004-06-13 20:20:40 +0000396
Bram Moolenaarec7944a2013-06-12 21:29:15 +0200397func! s:CSSIndent() "{{{
398 " adopted $VIMRUNTIME/indent/css.vim
399 if getline(v:lnum) =~ '^\s*[*}]'
400 return cindent(v:lnum)
401 endif
402 let minline = b:indent.blocklnr
403 let pnum = s:css_prevnoncomment(v:lnum - 1, minline)
Bram Moolenaar946e27a2014-06-25 18:50:27 +0200404 let pnum = s:FindTagStart(pnum)
Bram Moolenaarec7944a2013-06-12 21:29:15 +0200405 if pnum <= minline
406 " < is to catch errors
407 " indent for first content line after comments
408 return eval(s:css1indent)
409 endif
Bram Moolenaar52b91d82013-06-15 21:39:51 +0200410 let ind = indent(pnum) + s:css_countbraces(pnum, 1) * s:ShiftWidth()
Bram Moolenaarec7944a2013-06-12 21:29:15 +0200411 let pline = getline(pnum)
412 if pline =~ '}\s*$'
Bram Moolenaar52b91d82013-06-15 21:39:51 +0200413 let ind -= (s:css_countbraces(pnum, 0) - (pline =~ '^\s*}')) * s:ShiftWidth()
Bram Moolenaarec7944a2013-06-12 21:29:15 +0200414 endif
415 return ind
416endfunc "}}}
417func! s:css_prevnoncomment(lnum, stopline) "{{{
418 " caller starts from a line a:lnum-1 that is not a comment
419 let lnum = prevnonblank(a:lnum)
420 let ccol = match(getline(lnum), '\*/')
421 if ccol < 0
422 return lnum
423 endif
424 call cursor(lnum, ccol+1)
425 let lnum = search('/\*', 'bW', a:stopline)
426 if indent(".") == virtcol(".")-1
427 return prevnonblank(lnum-1)
428 else
429 return lnum
430 endif
431endfunc "}}}
432func! s:css_countbraces(lnum, count_open) "{{{
433 let brs = substitute(getline(a:lnum),'[''"].\{-}[''"]\|/\*.\{-}\*/\|/\*.*$\|[^{}]','','g')
434 let n_open = 0
435 let n_close = 0
436 for brace in split(brs, '\zs')
437 if brace == "{"
438 let n_open += 1
439 elseif brace == "}"
440 if n_open > 0
441 let n_open -= 1
442 else
443 let n_close += 1
Bram Moolenaar91170f82006-05-05 21:15:17 +0000444 endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000445 endif
Bram Moolenaarec7944a2013-06-12 21:29:15 +0200446 endfor
447 return a:count_open ? n_open : n_close
448endfunc "}}}
449
450"}}}
451func! s:Alien5() "{{{
452 " <!-- -->
453 return -1
454endfunc "}}}
455
Bram Moolenaar946e27a2014-06-25 18:50:27 +0200456" When the "lnum" line ends in ">" find the line containing the
457" matching "<". Avoids using the indent of a continuation line.
458" Moves the cursor.
459" Return the matching line number or "lnum".
460func! s:FindTagStart(lnum) "{{{
461 if getline(a:lnum) =~ '>\s*$'
462 call cursor(a:lnum, 99999)
463 normal! %
464 return line('.')
465 endif
466 return a:lnum
467endfunc "}}}
468
Bram Moolenaarec7944a2013-06-12 21:29:15 +0200469func! HtmlIndent() "{{{
470 let s:curline = tolower(getline(v:lnum))
Bram Moolenaar52b91d82013-06-15 21:39:51 +0200471 let indentunit = s:ShiftWidth()
Bram Moolenaarec7944a2013-06-12 21:29:15 +0200472
473 let s:newstate = {}
474 let s:newstate.lnum = v:lnum
475
Bram Moolenaar52b91d82013-06-15 21:39:51 +0200476 " does the line start with a closing tag?
Bram Moolenaarec7944a2013-06-12 21:29:15 +0200477 let swendtag = match(s:curline, '^\s*</') >= 0
478
Bram Moolenaar946e27a2014-06-25 18:50:27 +0200479 if prevnonblank(v:lnum-1) == b:indent.lnum && s:lasttick == b:changedtick - 1
Bram Moolenaarec7944a2013-06-12 21:29:15 +0200480 " use state (continue from previous line)
481 else
482 " start over (know nothing)
483 let b:indent = s:FreshState(v:lnum)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000484 endif
485
Bram Moolenaarec7944a2013-06-12 21:29:15 +0200486 if b:indent.block >= 2
487 " within block
488 let endtag = s:endtags[b:indent.block-2]
489 let blockend = stridx(s:curline, endtag)
490 if blockend >= 0
491 " block ends here
492 let s:newstate.block = 0
493 " calc indent for REST OF LINE (may start more blocks):
494 let s:curline = strpart(s:curline, blockend+strlen(endtag))
495 call s:CountITags()
496 if swendtag && b:indent.block != 5
Bram Moolenaar52b91d82013-06-15 21:39:51 +0200497 let indent = b:indent.blocktagind + s:curind * indentunit
498 let s:newstate.baseindent = indent + s:nextrel * indentunit
Bram Moolenaarec7944a2013-06-12 21:29:15 +0200499 else
500 let indent = s:Alien{b:indent.block}()
Bram Moolenaar52b91d82013-06-15 21:39:51 +0200501 let s:newstate.baseindent = b:indent.blocktagind + s:nextrel * indentunit
Bram Moolenaar91170f82006-05-05 21:15:17 +0000502 endif
Bram Moolenaarec7944a2013-06-12 21:29:15 +0200503 else
504 " block continues
505 " indent this line with alien method
506 let indent = s:Alien{b:indent.block}()
Bram Moolenaar071d4272004-06-13 20:20:40 +0000507 endif
Bram Moolenaarec7944a2013-06-12 21:29:15 +0200508 else
509 " not within a block - within usual html
510 " if < 2 then always 0
511 let s:newstate.block = b:indent.block
512 call s:CountITags()
513 if swendtag
Bram Moolenaar52b91d82013-06-15 21:39:51 +0200514 let indent = b:indent.baseindent + s:curind * indentunit
515 let s:newstate.baseindent = indent + s:nextrel * indentunit
Bram Moolenaarec7944a2013-06-12 21:29:15 +0200516 else
517 let indent = b:indent.baseindent
Bram Moolenaar52b91d82013-06-15 21:39:51 +0200518 let s:newstate.baseindent = indent + (s:curind + s:nextrel) * indentunit
Bram Moolenaarec7944a2013-06-12 21:29:15 +0200519 endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000520 endif
Bram Moolenaar946e27a2014-06-25 18:50:27 +0200521 let s:lasttick = b:changedtick
522 call extend(b:indent, s:newstate, "force")
523 return indent
Bram Moolenaar071d4272004-06-13 20:20:40 +0000524
Bram Moolenaarec7944a2013-06-12 21:29:15 +0200525endfunc "}}}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000526
Bram Moolenaarec7944a2013-06-12 21:29:15 +0200527" check user settings (first time), clear cpo, Modeline: {{{1
Bram Moolenaar071d4272004-06-13 20:20:40 +0000528
Bram Moolenaarec7944a2013-06-12 21:29:15 +0200529" DEBUG:
530com! -nargs=* IndHtmlLocal <args>
531
532call HtmlIndent_CheckUserSettings()
Bram Moolenaar071d4272004-06-13 20:20:40 +0000533
Bram Moolenaar91170f82006-05-05 21:15:17 +0000534let &cpo = s:cpo_save
535unlet s:cpo_save
536
Bram Moolenaarec7944a2013-06-12 21:29:15 +0200537" vim:set fdm=marker ts=8: