runtime(html): Optionally fold tags with the "expr" method
Tag folding poses a few difficulties. Many elements, e.g.
"blockquote", are always delimited by start and end tags;
end tags for some elements, e.g. "p", can be omitted in
certain contexts; void elements, e.g. "hr", have no end tag.
Although the rules for supporting omissible end tags are
ad-hoc and involved, they apply to elements in scope.
Assuming syntactical wellformedness, an end tag can be
associated with its nearest matching start tag discoverable
in scope and towards the beginning of a file, whereas all
unbalanced tags and inlined tags can be disregarded.
For example:
------------------------------------------------------------
<!DOCTYPE html>
<html lang="en"> <!-- >1 : 1 -->
<body> <!-- >2 : 2 -->
<p>Paragraph #1. <!-- = : 2 -->
<p> <!-- >3 : 3 -->
Paragraph #2. <!-- = : 3 -->
</p> <!-- <3 : 3 -->
<p>Paragraph #3.</p> <!-- = : 2 -->
</body> <!-- <2 : 2 -->
</html> <!-- <1 : 1 -->
------------------------------------------------------------
(HTML comments here, "<!-- ... -->", record two values for
each folded line that are separated by ":", a value obtained
from "&foldexpr" and a value obtained from "foldlevel()".)
Innermost foldedable tags will be flattened. For example:
------------------------------------------------------------
<!DOCTYPE html>
<html lang="en"> <!-- >1 : 1 -->
<body> <!-- >2 : 2 -->
<div class="block"> <!-- >3 : 3 -->
<pre><code> <!-- >4 : 4 -->
[CODE SNIPPET] <!-- = : 4 -->
</code></pre> <!-- <4 : 4 -->
</div> <!-- <3 : 3 -->
</body> <!-- <2 : 2 -->
</html> <!-- <1 : 1 -->
------------------------------------------------------------
No folding will be requested for the "<code>"-"</code>" tag
pair and reflected by "&foldexpr" because such a fold would
have claimed the same lines that the immediate fold of the
"<pre>"-"</pre>" tag already claims.
Run-on folded tags may confuse Vim. When a file such as:
------------------------------------------------------------
<!DOCTYPE html>
<html lang="en"> <!-- >1 : 1 -->
<body> <!-- >2 : 2 -->
<div class="block"> <!-- >3 : 3 -->
<pre> <!-- >4 : 4 -->
<code> <!-- >5 : 5 -->
[CODE SNIPPET #1] <!-- = : 5 -->
</code> <!-- <5 : 5 -->
</pre> <!-- <4 : 4 -->
</div> <!-- <3 : 3 -->
<!-- = : 3 -->
<div class="block"> <!-- >3 : 3 -->
<pre> <!-- >4 : 4 -->
<code> <!-- >5 : 5 -->
[CODE SNIPPET #2] <!-- = : 5 -->
</code> <!-- <5 : 5 -->
</pre> <!-- <4 : 4 -->
</div> <!-- <3 : 3 -->
</body> <!-- <2 : 2 -->
</html> <!-- <1 : 1 -->
------------------------------------------------------------
is reformatted as follows:
------------------------------------------------------------
<!DOCTYPE html>
<html lang="en"> <!-- >1 : 1 -->
<body> <!-- >2 : 2 -->
<div class="block"> <!-- >3 : 3 -->
<pre> <!-- >4 : 4 -->
<code> <!-- >5 : 5 -->
[CODE SNIPPET #1] <!-- = : 5 -->
</code> <!-- <5 : 5 -->
</pre> <!-- <4 : 4 -->
</div><div class="block"><pre><code> <!-- <3 : 3 -->
[CODE SNIPPET #2] <!-- = : 2 ? -->
</code> <!-- <5 : 2 ? -->
</pre> <!-- <4 : 2 ? -->
</div> <!-- <3 : 2 ? -->
</body> <!-- <2 : 2 -->
</html> <!-- <1 : 1 -->
------------------------------------------------------------
"&foldexpr" values will not be used as is for the lines
between (and including) "[CODE SNIPPET #2]" and "</div>".
(Cf. v9.1.0002.)
Having syntax highlighting in effect, tag folding using the
"fold-expr" method can be enabled with:
------------------------------------------------------------
let g:html_expr_folding = 1
------------------------------------------------------------
By default, tag folding will be redone from scratch after
each occurrence of a TextChanged or an InsertLeave event.
Such frequency may not be desired, especially for large
files, and this recomputation can be disabled with:
------------------------------------------------------------
let g:html_expr_folding_without_recomputation = 1
doautocmd FileType
------------------------------------------------------------
To force another recomputation, do:
------------------------------------------------------------
unlet! b:foldsmap
normal zx
------------------------------------------------------------
References:
https://web.archive.org/web/20250328105626/https://html.spec.whatwg.org/multipage/syntax.html#optional-tags
https://en.wikipedia.org/wiki/Dangling_else
closes: #17141
Signed-off-by: Aliaksei Budavei <0x000c70@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/runtime/autoload/htmlfold.vim b/runtime/autoload/htmlfold.vim
new file mode 100644
index 0000000..76ccaef
--- /dev/null
+++ b/runtime/autoload/htmlfold.vim
@@ -0,0 +1,192 @@
+" HTML folding script, :h ft-html-plugin
+" Latest Change: 2025 May 10
+" Original Author: Aliaksei Budavei <0x000c70@gmail.com>
+
+function! htmlfold#MapBalancedTags() abort
+ " Describe only _a capturable-name prefix_ for start and end patterns of
+ " a tag so that start tags with attributes spanning across lines can also be
+ " matched with a single call of "getline()".
+ let tag = '\m\c</\=\([0-9A-Za-z-]\+\)'
+ let names = []
+ let pairs = []
+ let ends = []
+ let pos = getpos('.')
+
+ try
+ call cursor(1, 1)
+ let [lnum, cnum] = searchpos(tag, 'cnW')
+
+ " Pair up nearest non-inlined tags in scope.
+ while lnum > 0
+ let name_attr = synIDattr(synID(lnum, cnum, 0), 'name')
+
+ if name_attr ==# 'htmlTag' || name_attr ==# 'htmlScriptTag'
+ let name = get(matchlist(getline(lnum), tag, (cnum - 1)), 1, '')
+
+ if !empty(name)
+ call insert(names, tolower(name), 0)
+ call insert(pairs, [lnum, -1], 0)
+ endif
+ elseif name_attr ==# 'htmlEndTag'
+ let name = get(matchlist(getline(lnum), tag, (cnum - 1)), 1, '')
+
+ if !empty(name)
+ let idx = index(names, tolower(name))
+
+ if idx >= 0
+ " Dismiss inlined balanced tags and opened-only tags.
+ if pairs[idx][0] != lnum
+ let pairs[idx][1] = lnum
+ call add(ends, lnum)
+ endif
+
+ " Claim a pair.
+ let names[: idx] = repeat([''], (idx + 1))
+ endif
+ endif
+ endif
+
+ " Advance the cursor, at "<", past "</a", "<a>", etc.
+ call cursor(lnum, (cnum + 3))
+ let [lnum, cnum] = searchpos(tag, 'cnW')
+ endwhile
+ finally
+ call setpos('.', pos)
+ endtry
+
+ if empty(ends)
+ return {}
+ endif
+
+ let folds = {}
+ let pending_end = ends[0]
+ let level = 0
+
+ while !empty(pairs)
+ let [start, end] = remove(pairs, -1)
+
+ if end < 0
+ continue
+ endif
+
+ if start >= pending_end
+ " Mark a sibling tag.
+ call remove(ends, 0)
+
+ while start >= ends[0]
+ " Mark a parent tag.
+ call remove(ends, 0)
+ let level -= 1
+ endwhile
+
+ let pending_end = ends[0]
+ else
+ " Mark a child tag.
+ let level += 1
+ endif
+
+ " Flatten the innermost inlined folds.
+ let folds[start] = get(folds, start, ('>' . level))
+ let folds[end] = get(folds, end, ('<' . level))
+ endwhile
+
+ return folds
+endfunction
+
+" See ":help vim9-mix".
+if !has("vim9script")
+ finish
+endif
+
+def! g:htmlfold#MapBalancedTags(): dict<string>
+ # Describe only _a capturable-name prefix_ for start and end patterns of
+ # a tag so that start tags with attributes spanning across lines can also be
+ # matched with a single call of "getline()".
+ const tag: string = '\m\c</\=\([0-9A-Za-z-]\+\)'
+ var names: list<string> = []
+ var pairs: list<list<number>> = []
+ var ends: list<number> = []
+ const pos: list<number> = getpos('.')
+
+ try
+ cursor(1, 1)
+ var [lnum: number, cnum: number] = searchpos(tag, 'cnW')
+
+ # Pair up nearest non-inlined tags in scope.
+ while lnum > 0
+ const name_attr: string = synIDattr(synID(lnum, cnum, 0), 'name')
+
+ if name_attr ==# 'htmlTag' || name_attr ==# 'htmlScriptTag'
+ const name: string = get(matchlist(getline(lnum), tag, (cnum - 1)), 1, '')
+
+ if !empty(name)
+ insert(names, tolower(name), 0)
+ insert(pairs, [lnum, -1], 0)
+ endif
+ elseif name_attr ==# 'htmlEndTag'
+ const name: string = get(matchlist(getline(lnum), tag, (cnum - 1)), 1, '')
+
+ if !empty(name)
+ const idx: number = index(names, tolower(name))
+
+ if idx >= 0
+ # Dismiss inlined balanced tags and opened-only tags.
+ if pairs[idx][0] != lnum
+ pairs[idx][1] = lnum
+ add(ends, lnum)
+ endif
+
+ # Claim a pair.
+ names[: idx] = repeat([''], (idx + 1))
+ endif
+ endif
+ endif
+
+ # Advance the cursor, at "<", past "</a", "<a>", etc.
+ cursor(lnum, (cnum + 3))
+ [lnum, cnum] = searchpos(tag, 'cnW')
+ endwhile
+ finally
+ setpos('.', pos)
+ endtry
+
+ if empty(ends)
+ return {}
+ endif
+
+ var folds: dict<string> = {}
+ var pending_end: number = ends[0]
+ var level: number = 0
+
+ while !empty(pairs)
+ const [start: number, end: number] = remove(pairs, -1)
+
+ if end < 0
+ continue
+ endif
+
+ if start >= pending_end
+ # Mark a sibling tag.
+ remove(ends, 0)
+
+ while start >= ends[0]
+ # Mark a parent tag.
+ remove(ends, 0)
+ level -= 1
+ endwhile
+
+ pending_end = ends[0]
+ else
+ # Mark a child tag.
+ level += 1
+ endif
+
+ # Flatten the innermost inlined folds.
+ folds[start] = get(folds, start, ('>' .. level))
+ folds[end] = get(folds, end, ('<' .. level))
+ endwhile
+
+ return folds
+enddef
+
+" vim: fdm=syntax sw=2 ts=8 noet
diff --git a/runtime/doc/filetype.txt b/runtime/doc/filetype.txt
index fa9506d..63d7b03 100644
--- a/runtime/doc/filetype.txt
+++ b/runtime/doc/filetype.txt
@@ -1,4 +1,4 @@
-*filetype.txt* For Vim version 9.1. Last change: 2025 Apr 27
+*filetype.txt* For Vim version 9.1. Last change: 2025 May 10
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -702,6 +702,32 @@
Since the text for this plugin is rather long it has been put in a separate
file: |ft_hare.txt|.
+HTML *ft-html-plugin*
+
+Tag folding poses a few difficulties. Many elements, e.g. `blockquote`, are
+always delimited by start and end tags; end tags for some elements, e.g. `p`,
+can be omitted in certain contexts; void elements, e.g. `hr`, have no end tag.
+Although the rules for supporting omissible end tags are ad-hoc and involved
+[0], they apply to elements in scope. Assuming syntactical wellformedness, an
+end tag can be associated with its nearest matching start tag discoverable in
+scope [1] and towards the beginning of a file, whereas all unbalanced tags and
+inlined tags can be disregarded. Having syntax highlighting in effect, tag
+folding using the |fold-expr| method can be enabled with: >
+ let g:html_expr_folding = 1
+<
+By default, tag folding will be redone from scratch after each occurrence of
+a |TextChanged| or an |InsertLeave| event. Such frequency may not be desired,
+especially for large files, and this recomputation can be disabled with: >
+ let g:html_expr_folding_without_recomputation = 1
+ doautocmd FileType
+<
+To force another recomputation, do: >
+ unlet! b:foldsmap
+ normal zx
+<
+[0] https://html.spec.whatwg.org/multipage/syntax.html#optional-tags
+[1] https://en.wikipedia.org/wiki/Dangling_else
+
IDRIS2 *ft-idris2-plugin*
By default the following options are set: >
diff --git a/runtime/doc/tags b/runtime/doc/tags
index ae80f0e..b820c96 100644
--- a/runtime/doc/tags
+++ b/runtime/doc/tags
@@ -7404,6 +7404,7 @@
ft-help-omni helphelp.txt /*ft-help-omni*
ft-html-indent indent.txt /*ft-html-indent*
ft-html-omni insert.txt /*ft-html-omni*
+ft-html-plugin filetype.txt /*ft-html-plugin*
ft-html-syntax syntax.txt /*ft-html-syntax*
ft-htmlos-syntax syntax.txt /*ft-htmlos-syntax*
ft-ia64-syntax syntax.txt /*ft-ia64-syntax*
diff --git a/runtime/ftplugin/html.vim b/runtime/ftplugin/html.vim
index 5495f85..7736b5b 100644
--- a/runtime/ftplugin/html.vim
+++ b/runtime/ftplugin/html.vim
@@ -3,7 +3,8 @@
" Maintainer: Doug Kearns <dougkearns@gmail.com>
" Previous Maintainer: Dan Sharp
" Last Change: 2024 Jan 14
-" 2024 May 24 by Riley Bruins <ribru17@gmail.com> ('commentstring')
+" 2024 May 24 update 'commentstring' option
+" 2025 May 10 add expression folding #17141
if exists("b:did_ftplugin")
finish
@@ -56,5 +57,52 @@
let b:undo_ftplugin ..= " | unlet! b:browsefilter b:html_set_browsefilter"
endif
+if has("folding") && get(g:, "html_expr_folding", 0)
+ function! HTMLTagFold() abort
+ if empty(get(b:, "foldsmap", {}))
+ if empty(get(b:, "current_syntax", ''))
+ return '0'
+ else
+ let b:foldsmap = htmlfold#MapBalancedTags()
+ endif
+ endif
+
+ return get(b:foldsmap, v:lnum, '=')
+ endfunction
+
+ setlocal foldexpr=HTMLTagFold()
+ setlocal foldmethod=expr
+ let b:undo_ftplugin ..= " | setlocal foldexpr< foldmethod<"
+
+ if !get(g:, "html_expr_folding_without_recomputation", 0)
+ augroup htmltagfold
+ autocmd! htmltagfold
+ autocmd TextChanged,InsertLeave <buffer> let b:foldsmap = {}
+ augroup END
+
+ " XXX: Keep ":autocmd" last in "b:undo_ftplugin" (see ":help :bar").
+ let b:undo_ftplugin ..= " | silent! autocmd! htmltagfold * <buffer>"
+ endif
+endif
+
let &cpo = s:save_cpo
unlet s:save_cpo
+
+" See ":help vim9-mix".
+if !has("vim9script")
+ finish
+endif
+
+if exists("*g:HTMLTagFold")
+ def! g:HTMLTagFold(): string
+ if empty(get(b:, "foldsmap", {}))
+ if empty(get(b:, "current_syntax", ''))
+ return '0'
+ else
+ b:foldsmap = g:htmlfold#MapBalancedTags()
+ endif
+ endif
+
+ return get(b:foldsmap, v:lnum, '=')
+ enddef
+endif
diff --git a/runtime/syntax/html.vim b/runtime/syntax/html.vim
index ca7c7f1..0e615b7 100644
--- a/runtime/syntax/html.vim
+++ b/runtime/syntax/html.vim
@@ -5,6 +5,7 @@
" Claudio Fleiner <claudio@fleiner.com>
" Last Change: 2023 Nov 28
" 2024 Jul 30 by Vim Project: increase syn-sync-minlines to 250
+" 2025 May 10 by Vim Project: update comment
" See :help html.vim for some comments and a description of the options
@@ -325,7 +326,8 @@
endif
" Folding
-" Originally by Ingo Karkat and Marcus Zanona
+" (Originally written by Ingo Karkat and Marcus Zanona; see
+" https://vi.stackexchange.com/questions/2306/html-syntax-folding-in-vim .)
if get(g:, "html_syntax_folding", 0)
syn region htmlFold start="<\z(\<\%(area\|base\|br\|col\|command\|embed\|hr\|img\|input\|keygen\|link\|meta\|param\|source\|track\|wbr\>\)\@![a-z-]\+\>\)\%(\_s*\_[^/]\?>\|\_s\_[^>]*\_[^>/]>\)" end="</\z1\_s*>" fold transparent keepend extend containedin=htmlHead,htmlH\d
" fold comments (the real ones and the old Netscape ones)
diff --git a/runtime/syntax/testdir/dumps/html_fold_expr_00.dump b/runtime/syntax/testdir/dumps/html_fold_expr_00.dump
new file mode 100644
index 0000000..9cd6e83
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/html_fold_expr_00.dump
@@ -0,0 +1,20 @@
+| +0#0000e05#a8a8a8255@7><+0&#ffffff0|!|D|O|C|T|Y|P|E| |h|t|m|l|>| +0#0000000&@51
+| +0#0000e05#a8a8a8255@7|<+0&#ffffff0|!|-@1| +0#0000000&@62
+| +0#0000e05#a8a8a8255@7|V+0&#ffffff0|I|M|_|T|E|S|T|_|S|E|T|U|P| |s|e|t|l|o|c|a|l| |f|o|l|d|c|o|l|u|m|n|=|8| |f|o|l|d|l|e|v|e|l|=|8| |f|o|l|d|m|e|t|h|o|d|=|e|x|p|r| +0#0000000&@2
+| +0#0000e05#a8a8a8255@7| +0#0000000#ffffff0@66
+| +0#0000e05#a8a8a8255@7| +0#0000000#ffffff0@66
+| +0#0000e05#a8a8a8255@7| +0#0000000#ffffff0@66
+| +0#0000e05#a8a8a8255@7|-+0&#ffffff0@1|>| +0#0000000&@63
+|-+0#0000e05#a8a8a8255| @6|<+0#00e0e07#ffffff0|h+0#af5f00255&|t|m|l| +0#00e0e07&|l+0#00e0003&|a|n|g|=+0#00e0e07&|"+0#e000002&|e|n|"|>+0#00e0e07&| +0#0000000&@7|<+0#0000e05&|!|-@1| |1| |-@1|>| +0#0000000&@32
+||+0#0000e05#a8a8a8255|-| @5|<+0#00e0e07#ffffff0|H+0#af5f00255&|E|A|D|>+0#00e0e07&| +0#e000e06&@17|<+0#0000e05&|!|-@1| |2| |-@1|>| +0#0000000&@32
+||+0#0000e05#a8a8a8255@1| @5|<+0#00e0e07#ffffff0|m+0#af5f00255&|e|t|a| +0#00e0e07&|c+0#00e0003&|h|a|r|s|e|t|=+0#00e0e07&|"+0#e000002&|U|T|F|-|8|"|>+0#00e0e07&| +0#0000000&@44
+||+0#0000e05#a8a8a8255@1| @5|<+0#00e0e07#ffffff0|t+0#af5f00255&|i|t|l|e|>+0#00e0e07&|A+0#e000e06&| |f|o|l|d|i|n|g| |s|y|n|t|a|x| |t|e|s|t|<+0#00e0e07&|/|t+0#af5f00255&|i|t|l|e|>+0#00e0e07&|<|s+0#af5f00255&|t|y|l|e|>+0#00e0e07&| +0#0000000&|/+0#0000e05&|*| |3| |F|I|X|M|E| |*|/| +0#0000000&@9
+||+0#0000e05#a8a8a8255@1| @5|p+0#af5f00255#ffffff0| +0#0000000&|{+0#00e0e07&| +0#0000000&|f+0#00e0003&|o|n|t|-|s|i|z|e|:+0#0000000&| |2+0#e000002&|4|p|x|;+0#0000000&| |}+0#00e0e07&| +0#0000000&|/+0#0000e05&|*| |<|/|s|t|y|l|e|>| +0#0000000&@32
+||+0#0000e05#a8a8a8255@1| @5|<+0#00e0e07#ffffff0|s+0#af5f00255&|t|y|l|e|>+0#00e0e07&|*+0#af5f00255&|/+0#0000000&|<+0#00e0e07&|/|s+0#af5f00255&|t|y|l|e|>+0#00e0e07&|<|/|h+0#af5f00255&|e|a|d|>+0#00e0e07&|<|/|h+0#af5f00255&|e|a|d|>+0#00e0e07&|<|/|h+0#af5f00255&|e|a|d|>+0#00e0e07&|<|/|h+0#af5f00255&|e|a|d|>+0#00e0e07&| +0#0000000&@21
+||+0#0000e05#a8a8a8255| @6| +0#0000000#ffffff0@66
+||+0#0000e05#a8a8a8255|-| @5|<+0#00e0e07#ffffff0|b+0#af5f00255&|O|d|Y| +0#00e0e07&|S+0#00e0003&|T|Y|L|E|=+0#00e0e07&|"+0#e000002&|b|a|c|k|g|r|o|u|n|d|:| |#|b|e|b|e|b|e|"|>+0#00e0e07&| +0#0000000&@5|<+0#0000e05&|!|-@1| |2| |-@1|>| +0#0000000&@16
+||+0#0000e05#a8a8a8255@1|-| @4|<+0#00e0e07#ffffff0|b+0#af5f00255&|r|>+0#00e0e07&|<|b+0#af5f00255&|r|>+0#00e0e07&|<|b+0#af5f00255&|r|>+0#00e0e07&|<|b+0#af5f00255&|r|>+0#00e0e07&|<|s+0#af5f00255&|c|r|i|p|t|>+0#00e0e07&|<+0#e000e06&|!|[+0#00e0e07&|C+0#e000e06&|D|A|T|A|[+0#00e0e07&| +0#e000e06&@6|/+0#0000e05&@1| |3| +0#0000000&@22
+||+0#0000e05#a8a8a8255@2| @4|/+0&#ffffff0@1| |\|x|3|C|!|-@1| +0#0000000&@56
+||+0#0000e05#a8a8a8255@2| @4|/+0&#ffffff0@1| |\|x|3|C|s|c|r|i|p|t|>| +0#0000000&@52
+||+0#0000e05#a8a8a8255@2| @4|/+0&#ffffff0@1| |\|x|3|C|/|s|c|r|i|p|t|>| +0#0000000&@51
+@57|1|,|1| @10|T|o|p|
diff --git a/runtime/syntax/testdir/dumps/html_fold_expr_01.dump b/runtime/syntax/testdir/dumps/html_fold_expr_01.dump
new file mode 100644
index 0000000..96cc427
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/html_fold_expr_01.dump
@@ -0,0 +1,20 @@
+||+0#0000e05#a8a8a8255| @6| +0#0000000#ffffff0@66
+||+0#0000e05#a8a8a8255|-| @5|<+0#00e0e07#ffffff0|b+0#af5f00255&|O|d|Y| +0#00e0e07&|S+0#00e0003&|T|Y|L|E|=+0#00e0e07&|"+0#e000002&|b|a|c|k|g|r|o|u|n|d|:| |#|b|e|b|e|b|e|"|>+0#00e0e07&| +0#0000000&@5|<+0#0000e05&|!|-@1| |2| |-@1|>| +0#0000000&@16
+||+0#0000e05#a8a8a8255@1|-| @4|<+0#00e0e07#ffffff0|b+0#af5f00255&|r|>+0#00e0e07&|<|b+0#af5f00255&|r|>+0#00e0e07&|<|b+0#af5f00255&|r|>+0#00e0e07&|<|b+0#af5f00255&|r|>+0#00e0e07&|<|s+0#af5f00255&|c|r|i|p|t|>+0#00e0e07&|<+0#e000e06&|!|[+0#00e0e07&|C+0#e000e06&|D|A|T|A|[+0#00e0e07&| +0#e000e06&@6|/+0#0000e05&@1| |3| +0#0000000&@22
+||+0#0000e05#a8a8a8255@2| @4|/+0&#ffffff0@1| |\|x|3|C|!|-@1| +0#0000000&@56
+||+0#0000e05#a8a8a8255@2| @4|/+0&#ffffff0@1| |\|x|3|C|s|c|r|i|p|t|>| +0#0000000&@52
+||+0#0000e05#a8a8a8255@2| @4>/+0&#ffffff0@1| |\|x|3|C|/|s|c|r|i|p|t|>| +0#0000000&@51
+||+0#0000e05#a8a8a8255@2| @4|/+0&#ffffff0@1| |-@1|>| +0#0000000&@60
+||+0#0000e05#a8a8a8255@2| @4|]+0#00e0e07#ffffff0@1|>+0#e000e06&|<+0#00e0e07&|/|s+0#af5f00255&|c|r|i|p|t|>+0#00e0e07&| +0#0000000&@54
+||+0#0000e05#a8a8a8255@1| @5|<+0#00e0e07#ffffff0|h+0#af5f00255&|2| +0#00e0e07&|i+0#00e0003&|d|=+0#00e0e07&|"+0#e000002&|>|<|/|h|2|>|"|>+0#00e0e07&|<|i+0#af5f00255&|>+0#00e0e07&|A+0#e000e06&|n| |H|2| |h|e|a|d|e|r|<+0#00e0e07&|/|i+0#af5f00255&|>+0#00e0e07&|<|/|h+0#af5f00255&|2|>+0#00e0e07&| +0#0000000&@26
+||+0#0000e05#a8a8a8255@1| @5|<+0#00e0e07#ffffff0|b+0#af5f00255&|r|>+0#00e0e07&|<|b+0#af5f00255&|r|>+0#00e0e07&|<|b+0#af5f00255&|r|>+0#00e0e07&|<|b+0#af5f00255&|r|>+0#00e0e07&| +0#0000000&@50
+||+0#0000e05#a8a8a8255@1| @5|<+0#00e0e07#ffffff0|h+0#af5f00255&|r|>+0#00e0e07&| +0#0000000&@62
+||+0#0000e05#a8a8a8255@1| @5| +0#0000000#ffffff0@66
+||+0#0000e05#a8a8a8255@1|-| @4|<+0#00e0e07#ffffff0|p+0#af5f00255&|>+0#00e0e07&|P+0#0000000&|a|r|a|g|r|a|p|h| |#|1|.| @7|<+0#0000e05&|!|-@1| |3| |-@1|>| +0#0000000&@32
+||+0#0000e05#a8a8a8255@2| @4|<+0#00e0e07#ffffff0|/|p+0#af5f00255&|>+0#00e0e07&| +0#0000000&@62
+||+0#0000e05#a8a8a8255@1| @5| +0#0000000#ffffff0@66
+||+0#0000e05#a8a8a8255@1| @5|<+0#00e0e07#ffffff0|p+0#af5f00255&|>+0#00e0e07&|P+0#0000000&|a|r|a|g|r|a|p|h| |#|2|.| @50
+||+0#0000e05#a8a8a8255@1| @5| +0#0000000#ffffff0@66
+||+0#0000e05#a8a8a8255@1|-| @4|<+0#00e0e07#ffffff0|d+0#af5f00255&|e|t|a|i|l|s|>+0#00e0e07&| +0#0000000&@14|<+0#0000e05&|!|-@1| |3| |<|/|d|e|t|a|i|l|s|>| |-@1|>| +0#0000000&@21
+||+0#0000e05#a8a8a8255@2|-| @3|<+0#00e0e07#ffffff0|s+0#af5f00255&|u|m@1|a|r|y|>+0#00e0e07&| +0#0000000&@14|<+0#0000e05&|!|-@1| |4| |<|/|s|u|m@1|a|r|y|>| |-@1|>| +0#0000000&@21
+@57|1|9|,|1| @9|1|5|%|
diff --git a/runtime/syntax/testdir/dumps/html_fold_expr_02.dump b/runtime/syntax/testdir/dumps/html_fold_expr_02.dump
new file mode 100644
index 0000000..d2c1ec6
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/html_fold_expr_02.dump
@@ -0,0 +1,20 @@
+||+0#0000e05#a8a8a8255@2|-| @3|<+0#00e0e07#ffffff0|s+0#af5f00255&|u|m@1|a|r|y|>+0#00e0e07&| +0#0000000&@14|<+0#0000e05&|!|-@1| |4| |<|/|s|u|m@1|a|r|y|>| |-@1|>| +0#0000000&@21
+||+0#0000e05#a8a8a8255@3| @3|<+0#00e0e07#ffffff0|/|s+0#af5f00255&|u|m@1|a|r|y|>+0#00e0e07&| +0#0000000&@56
+||+0#0000e05#a8a8a8255@2| @4|<+0#00e0e07#ffffff0|p+0#af5f00255&|>+0#00e0e07&|P+0#0000000&|a|r|a|g|r|a|p|h| |#|1|.| @50
+||+0#0000e05#a8a8a8255@2|-| @3|<+0#00e0e07#ffffff0|u+0#af5f00255&|l|>+0#00e0e07&| +0#0000000&@19|<+0#0000e05&|!|-@1| |4| |-@1|>| +0#0000000&@32
+||+0#0000e05#a8a8a8255@3| @3|<+0#00e0e07#ffffff0|l+0#af5f00255&|i|>+0#00e0e07&|I+0#0000000&|t|e|m| |a|.|<+0#00e0e07&|/|l+0#af5f00255&|i|>+0#00e0e07&|<|l+0#af5f00255&|i|>+0#00e0e07&|I+0#0000000&|t|e|m| |b|.|<+0#00e0e07&|/|l+0#af5f00255&|i|>+0#00e0e07&| +0#0000000&@34
+||+0#0000e05#a8a8a8255@3| @3><+0#00e0e07#ffffff0|l+0#af5f00255&|i|>+0#00e0e07&|I+0#0000000&|t|e|m| |c|.| @55
+||+0#0000e05#a8a8a8255@3| @3|<+0#00e0e07#ffffff0|/|u+0#af5f00255&|l|>+0#00e0e07&| +0#0000000&@61
+||+0#0000e05#a8a8a8255@2|-| @3|<+0#00e0e07#ffffff0|p+0#af5f00255&|>+0#00e0e07&|P+0#0000000&|a|r|a|g|r|a|p|h| |#|2|.| @7|<+0#0000e05&|!|-@1| |4| |-@1|>| +0#0000000&@32
+||+0#0000e05#a8a8a8255@3| @3|<+0#00e0e07#ffffff0|/|p+0#af5f00255&|>+0#00e0e07&| +0#0000000&@62
+||+0#0000e05#a8a8a8255@2| @4|<+0#00e0e07#ffffff0|/|d+0#af5f00255&|e|t|a|i|l|s|>+0#00e0e07&| +0#0000000&@56
+||+0#0000e05#a8a8a8255@1| @5| +0#0000000#ffffff0@66
+||+0#0000e05#a8a8a8255@1|-| @4|<+0#00e0e07#ffffff0|d+0#af5f00255&|l|>+0#00e0e07&| +0#0000000&@19|<+0#0000e05&|!|-@1| |3| |-@1|>| +0#0000000&@32
+||+0#0000e05#a8a8a8255@2| @4|<+0#00e0e07#ffffff0|d+0#af5f00255&|t|>+0#00e0e07&|A+0#0000000&| |q|u|i|c|k| |b|r|o|w|n| |f|o|x| |j|u|m|p|s| |o|v|e|r| |t|h|e| |l|a|z|y| |d|o|g| @21
+||+0#0000e05#a8a8a8255@2| @4|<+0#00e0e07#ffffff0|d+0#af5f00255&@1|>+0#00e0e07&|W+0#0000000&|o@1|f|!| @57
+||+0#0000e05#a8a8a8255@2|-| @3|<+0#00e0e07#ffffff0|d+0#af5f00255&|l|>+0#00e0e07&| +0#0000000&@19|<+0#0000e05&|!|-@1| |4| |-@1|>| +0#0000000&@32
+||+0#0000e05#a8a8a8255@3| @3|<+0#00e0e07#ffffff0|d+0#af5f00255&|t|>+0#00e0e07&|A+0#0000000&| |q|u|i|c|k| |b|r|o|w|n| |f|o|x| |j|u|m|p|s| |o|v|e|r| |t|h|e| |l|a|z|y| |d|o|g| @21
+||+0#0000e05#a8a8a8255@3| @3|<+0#00e0e07#ffffff0|d+0#af5f00255&@1|>+0#00e0e07&|W+0#0000000&|o@1|f|!| @57
+||+0#0000e05#a8a8a8255@3| @3|<+0#00e0e07#ffffff0|/|d+0#af5f00255&|l|>+0#00e0e07&| +0#0000000&@61
+||+0#0000e05#a8a8a8255@2| @4|<+0#00e0e07#ffffff0|/|d+0#af5f00255&|l|>+0#00e0e07&| +0#0000000&@61
+@57|3|7|,|1| @9|3|6|%|
diff --git a/runtime/syntax/testdir/dumps/html_fold_expr_03.dump b/runtime/syntax/testdir/dumps/html_fold_expr_03.dump
new file mode 100644
index 0000000..74012eb
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/html_fold_expr_03.dump
@@ -0,0 +1,20 @@
+||+0#0000e05#a8a8a8255@2| @4|<+0#00e0e07#ffffff0|/|d+0#af5f00255&|l|>+0#00e0e07&| +0#0000000&@61
+||+0#0000e05#a8a8a8255@1| @5| +0#0000000#ffffff0@66
+||+0#0000e05#a8a8a8255@1|-| @4|<+0#00e0e07#ffffff0|a+0#af5f00255&|r|t|i|c|l|e|>+0#00e0e07&|T+0#0000000&|h|r|e|a|d| |#|1| @5|<+0#0000e05&|!|-@1| |3| |-@1|>| +0#0000000&@32
+||+0#0000e05#a8a8a8255@2|-| @3|<+0#00e0e07#ffffff0|a+0#af5f00255&|r|t|i|c|l|e|>+0#00e0e07&|T+0#0000000&|h|r|e|a|d| |#|2| @5|<+0#0000e05&|!|-@1| |4| |-@1|>| +0#0000000&@32
+||+0#0000e05#a8a8a8255@3| @3|<+0#00e0e07#ffffff0|/|a+0#af5f00255&|r|t|i|c|l|e|>+0#00e0e07&| +0#0000000&@56
+||+0#0000e05#a8a8a8255@2| @4><+0#00e0e07#ffffff0|/|a+0#af5f00255&|r|t|i|c|l|e|>+0#00e0e07&| +0#0000000&@56
+||+0#0000e05#a8a8a8255@1| @5| +0#0000000#ffffff0@66
+||+0#0000e05#a8a8a8255@1|-| @4|<+0#00e0e07#ffffff0|p+0#af5f00255&|>+0#00e0e07&| +0#0000000&@20|<+0#0000e05&|!|-@1| |3| |-@1|>| +0#0000000&@32
+||+0#0000e05#a8a8a8255@2| @4|<+0#00e0e07#ffffff0|l+0#af5f00255&|a|b|e|l| +0#00e0e07&|f+0#00e0003&|o|r|=+0#00e0e07&|"+0#e000002&|s|e|l|e|c|t|i|o|n|"|>+0#00e0e07&|S+0#0000000&|e|l|e|c|t| |O|p|t|i|o|n|<+0#00e0e07&|/|l+0#af5f00255&|a|b|e|l|>+0#00e0e07&| +0#0000000&@22
+||+0#0000e05#a8a8a8255@2|-| @3|<+0#00e0e07#ffffff0|s+0#af5f00255&|e|l|e|c|t| +0#0000000&@59
+||+0#0000e05#a8a8a8255@3| @3|i+0#00e0003#ffffff0|d|=+0#00e0e07&|"+0#e000002&|s|e|l|e|c|t|i|o|n|"| +0#0000000&@52
+||+0#0000e05#a8a8a8255@3| @3|n+0#00e0003#ffffff0|a|m|e|=+0#00e0e07&|"+0#e000002&|s|e|l|e|c|t|i|o|n|"|>+0#00e0e07&| +0#0000000&@6|<+0#0000e05&|!|-@1| |4| |-@1|>| +0#0000000&@32
+||+0#0000e05#a8a8a8255@3|-| @2|<+0#00e0e07#ffffff0|o+0#af5f00255&|p|t|g|r|o|u|p| +0#00e0e07&|l+0#00e0003&|a|b|e|l|=+0#00e0e07&|"+0#e000002&|P|r|i|m|a|r|y| |G|r|o|u|p|"|>+0#00e0e07&| +0#0000000&@7|<+0#0000e05&|!|-@1| |5| |-@1|>| +0#0000000&@16
+||+0#0000e05#a8a8a8255@4| @2|<+0#00e0e07#ffffff0|o+0#af5f00255&|p|t|i|o|n| +0#00e0e07&|v+0#00e0003&|a|l|u|e|=+0#00e0e07&|"+0#e000002&|1|"|>+0#00e0e07&|A+0#0000000&|l|t|e|r|n|a|t|i|v|e| @37
+||+0#0000e05#a8a8a8255@4| @2|<+0#00e0e07#ffffff0|o+0#af5f00255&|p|t|i|o|n| +0#00e0e07&|v+0#00e0003&|a|l|u|e|=+0#00e0e07&|"+0#e000002&|2|"| +0#00e0e07&|s+0#00e0003&|e|l|e|c|t|e|d|>+0#00e0e07&|D+0#0000000&|e|f|a|u|l|t| @32
+||+0#0000e05#a8a8a8255@4| @2|<+0#00e0e07#ffffff0|o+0#af5f00255&|p|t|i|o|n| +0#00e0e07&|v+0#00e0003&|a|l|u|e|=+0#00e0e07&|"+0#e000002&|3|"|>+0#00e0e07&|B+0#0000000&|a|s|i|c| @43
+||+0#0000e05#a8a8a8255@4| @2|<+0#00e0e07#ffffff0|o+0#af5f00255&|p|t|i|o|n| +0#00e0e07&|v+0#00e0003&|a|l|u|e|=+0#00e0e07&|"+0#e000002&|4|"|>+0#00e0e07&|E+0#0000000&|x|t|e|n|d|e|d| @40
+||+0#0000e05#a8a8a8255@4| @2|<+0#00e0e07#ffffff0|/|o+0#af5f00255&|p|t|g|r|o|u|p|>+0#00e0e07&| +0#0000000&@55
+||+0#0000e05#a8a8a8255@3| @3|<+0#00e0e07#ffffff0|/|s+0#af5f00255&|e|l|e|c|t|>+0#00e0e07&| +0#0000000&@57
+@57|5@1|,|1| @9|5|6|%|
diff --git a/runtime/syntax/testdir/dumps/html_fold_expr_04.dump b/runtime/syntax/testdir/dumps/html_fold_expr_04.dump
new file mode 100644
index 0000000..659463c
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/html_fold_expr_04.dump
@@ -0,0 +1,20 @@
+||+0#0000e05#a8a8a8255@3| @3|<+0#00e0e07#ffffff0|/|s+0#af5f00255&|e|l|e|c|t|>+0#00e0e07&| +0#0000000&@57
+||+0#0000e05#a8a8a8255@2| @4|<+0#00e0e07#ffffff0|/|p+0#af5f00255&|>+0#00e0e07&| +0#0000000&@62
+||+0#0000e05#a8a8a8255@1| @5| +0#0000000#ffffff0@66
+||+0#0000e05#a8a8a8255@1|-| @4|<+0#00e0e07#ffffff0|t+0#af5f00255&|a|b|l|e|>+0#00e0e07&| +0#0000000&@16|<+0#0000e05&|!|-@1| |3| |-@1|>| +0#0000000&@32
+||+0#0000e05#a8a8a8255@2| @4|<+0#00e0e07#ffffff0|c+0#af5f00255&|a|p|t|i|o|n|>+0#00e0e07&|S+0#0000000&|o|m|e| |C|a|p|t|i|o|n|<+0#00e0e07&|/|c+0#af5f00255&|a|p|t|i|o|n|>+0#00e0e07&| +0#0000000&@35
+||+0#0000e05#a8a8a8255@2| @4><+0#00e0e07#ffffff0|c+0#af5f00255&|o|l|g|r|o|u|p|>+0#00e0e07&|<|c+0#af5f00255&|o|l|>+0#00e0e07&|<|c+0#af5f00255&|o|l|>+0#00e0e07&|<|c+0#af5f00255&|o|l|>+0#00e0e07&| +0#0000000&@41
+||+0#0000e05#a8a8a8255@2| @4|<+0#00e0e07#ffffff0|t+0#af5f00255&|h|e|a|d|>+0#00e0e07&| +0#0000000&@59
+||+0#0000e05#a8a8a8255@2| @4|<+0#00e0e07#ffffff0|t+0#af5f00255&|r|>+0#00e0e07&|<|t+0#af5f00255&|h|>+0#00e0e07&|H+0#0000000&|e|a|d|e|r| |#|1|<+0#00e0e07&|t+0#af5f00255&|h|>+0#00e0e07&|H+0#0000000&|e|a|d|e|r| |#|2|<+0#00e0e07&|t+0#af5f00255&|h|>+0#00e0e07&|H+0#0000000&|e|a|d|e|r| |#|3| @23
+||+0#0000e05#a8a8a8255@2| @4|<+0#00e0e07#ffffff0|t+0#af5f00255&|b|o|d|y|>+0#00e0e07&| +0#0000000&@59
+||+0#0000e05#a8a8a8255@2| @4|<+0#00e0e07#ffffff0|t+0#af5f00255&|r|>+0#00e0e07&|<|t+0#af5f00255&|d|>+0#00e0e07&|C+0#0000000&|o|l|u|m|n| |#|1|<+0#00e0e07&|t+0#af5f00255&|d|>+0#00e0e07&|C+0#0000000&|o|l|u|m|n| |#|2|<+0#00e0e07&|t+0#af5f00255&|d|>+0#00e0e07&|C+0#0000000&|o|l|u|m|n| |#|3| @23
+||+0#0000e05#a8a8a8255@2| @4|<+0#00e0e07#ffffff0|t+0#af5f00255&|r|>+0#00e0e07&|<|t+0#af5f00255&|d|>+0#00e0e07&|C+0#0000000&|o|l|u|m|n| |#|1|<+0#00e0e07&|t+0#af5f00255&|d|>+0#00e0e07&|C+0#0000000&|o|l|u|m|n| |#|2|<+0#00e0e07&|t+0#af5f00255&|d|>+0#00e0e07&|C+0#0000000&|o|l|u|m|n| |#|3| @23
+||+0#0000e05#a8a8a8255@2| @4|<+0#00e0e07#ffffff0|t+0#af5f00255&|r|>+0#00e0e07&|<|t+0#af5f00255&|d|>+0#00e0e07&|C+0#0000000&|o|l|u|m|n| |#|1|<+0#00e0e07&|t+0#af5f00255&|d|>+0#00e0e07&|C+0#0000000&|o|l|u|m|n| |#|2|<+0#00e0e07&|t+0#af5f00255&|d|>+0#00e0e07&|C+0#0000000&|o|l|u|m|n| |#|3| @23
+||+0#0000e05#a8a8a8255@2| @4|<+0#00e0e07#ffffff0|t+0#af5f00255&|r|>+0#00e0e07&|<|t+0#af5f00255&|d|>+0#00e0e07&|C+0#0000000&|o|l|u|m|n| |#|1|<+0#00e0e07&|t+0#af5f00255&|d|>+0#00e0e07&|C+0#0000000&|o|l|u|m|n| |#|2|<+0#00e0e07&|t+0#af5f00255&|d|>+0#00e0e07&|C+0#0000000&|o|l|u|m|n| |#|3| @23
+||+0#0000e05#a8a8a8255@2| @4|<+0#00e0e07#ffffff0|/|t+0#af5f00255&|a|b|l|e|>+0#00e0e07&| +0#0000000&@58
+||+0#0000e05#a8a8a8255@1| @5| +0#0000000#ffffff0@66
+||+0#0000e05#a8a8a8255@1|-| @4|<+0#00e0e07#ffffff0|d+0#af5f00255&|i|v| +0#00e0e07&|c+0#00e0003&|l|a|s@1|=+0#00e0e07&|"+0#e000002&|b|l|o|c|k|"|>+0#00e0e07&| +0#0000000&@4|<+0#0000e05&|!|-@1| |3| |-@1|>| +0#0000000&@32
+||+0#0000e05#a8a8a8255@2|-| @3|<+0#00e0e07#ffffff0|b+0#af5f00255&|l|o|c|k|q|u|o|t|e|>+0#00e0e07&|<|p+0#af5f00255&|r|e|>+0#00e0e07&|<|c+0#af5f00255&|o|d|e|>+0#00e0e07&| +0#0000000&|<+0#0000e05&|!|-@1| |4| |-@1|>| +0#0000000&@32
+||+0#0000e05#a8a8a8255@3| @3|&+0#e000e06#ffffff0|l|t|;|d+0#0000000&|i|v| |c|l|a|s@1|=|"|b|l|o|c|k|"|&+0#e000e06&|g|t|;| +0#0000000&@41
+||+0#0000e05#a8a8a8255@3| @3|&+0#e000e06#ffffff0|l|t|;|b+0#0000000&|l|o|c|k|q|u|o|t|e|&+0#e000e06&|g|t|;|&|l|t|;|p+0#0000000&|r|e|&+0#e000e06&|g|t|;|&|l|t|;|c+0#0000000&|o|d|e|&+0#e000e06&|g|t|;| +0#0000000&@25
+@57|7|3|,|1| @9|7@1|%|
diff --git a/runtime/syntax/testdir/dumps/html_fold_expr_05.dump b/runtime/syntax/testdir/dumps/html_fold_expr_05.dump
new file mode 100644
index 0000000..8f3ed16
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/html_fold_expr_05.dump
@@ -0,0 +1,20 @@
+||+0#0000e05#a8a8a8255@3| @3|&+0#e000e06#ffffff0|l|t|;|b+0#0000000&|l|o|c|k|q|u|o|t|e|&+0#e000e06&|g|t|;|&|l|t|;|p+0#0000000&|r|e|&+0#e000e06&|g|t|;|&|l|t|;|c+0#0000000&|o|d|e|&+0#e000e06&|g|t|;| +0#0000000&@25
+||+0#0000e05#a8a8a8255@3| @3|&+0#e000e06#ffffff0|l|t|;|/+0#0000000&|c|o|d|e|&+0#e000e06&|g|t|;|&|l|t|;|/+0#0000000&|p|r|e|&+0#e000e06&|g|t|;|&|l|t|;|/+0#0000000&|b|l|o|c|k|q|u|o|t|e|&+0#e000e06&|g|t|;|&|l|t|;|/+0#0000000&|d|i|v|&+0#e000e06&|g|t|;| +0#0000000&@10
+||+0#0000e05#a8a8a8255@3| @3|<+0#00e0e07#ffffff0|/|c+0#af5f00255&|o|d|e|>+0#00e0e07&|<|/|p+0#af5f00255&|r|e|>+0#00e0e07&|<|/|b+0#af5f00255&|l|o|c|k|q|u|o|t|e|>+0#00e0e07&|<|/|d+0#af5f00255&|i|v|>+0#00e0e07&| +0#0000000&@34
+||+0#0000e05#a8a8a8255@1| @5| +0#0000000#ffffff0@66
+||+0#0000e05#a8a8a8255@1| @5|<+0#00e0e07#ffffff0|p+0#af5f00255&|>+0#00e0e07&|P+0#0000000&|a|r|a|g|r|a|p|h| |#|3|.|<+0#00e0e07&|/|p+0#af5f00255&|>+0#00e0e07&|<|p+0#af5f00255&|>+0#00e0e07&|P+0#0000000&|a|r|a|g|r|a|p|h| |#|4|.|<+0#00e0e07&|/|p+0#af5f00255&|>+0#00e0e07&|<|p+0#af5f00255&|>+0#00e0e07&|P+0#0000000&|a|r|a|g|r|a|p|h| |#|5|.| @10
+||+0#0000e05#a8a8a8255@1| @5> +0#0000000#ffffff0@66
+||+0#0000e05#a8a8a8255@1| @5|<+0#00e0e07#ffffff0|p+0#af5f00255&|>+0#00e0e07&|P+0#0000000&|a|r|a|g|r|a|p|h| |#|6|.|<+0#00e0e07&|/|p+0#af5f00255&|>+0#00e0e07&|<|p+0#af5f00255&|>+0#00e0e07&|P+0#0000000&|a|r|a|g|r|a|p|h| |#|7|.|<+0#00e0e07&|/|p+0#af5f00255&|>+0#00e0e07&|<|p+0#af5f00255&|>+0#00e0e07&|P+0#0000000&|a|r|a|g|r|a|p|h| |#|8|.|<+0#00e0e07&|/|p+0#af5f00255&|>+0#00e0e07&|<|p+0#af5f00255&|>+0#00e0e07&|P+0#0000000&|a|r|a
+||+0#0000e05#a8a8a8255@1| @5|g+0#0000000#ffffff0|r|a|p|h| |#|9|.|<+0#00e0e07&|/|p+0#af5f00255&|>+0#00e0e07&| +0#0000000&@53
+||+0#0000e05#a8a8a8255@1| @5| +0#0000000#ffffff0@66
+||+0#0000e05#a8a8a8255@1|-| @4|<+0#00e0e07#ffffff0|p+0#af5f00255&| +0#00e0e07&|i+0#00e0003&|d|=+0#00e0e07&|"+0#e000002&|>|<|/|p|>|"|>+0#00e0e07&|P+0#0000000&|a|r|a|g|r|a|p|h| |#|1|0|.| @3|<+0#0000e05&|!|-@1| |3| |-@1|>| +0#0000000&@24
+||+0#0000e05#a8a8a8255@2| @4|<+0#00e0e07#ffffff0|/|p+0#af5f00255&|>+0#00e0e07&| +0#0000000&@62
+||+0#0000e05#a8a8a8255@1| @5| +0#0000000#ffffff0@66
+||+0#0000e05#a8a8a8255@1|-| @4|<+0#00e0e07#ffffff0|p+0#af5f00255&| +0#00e0e07&|>|P+0#0000000&|a|r|a|g|r|a|p|h| |#|1@1|.|<+0#00e0e07&|/|p+0#af5f00255&|>+0#00e0e07&|<|p+0#af5f00255&| +0#00e0e07&|i+0#00e0003&|d|=+0#00e0e07&|"+0#e000002&|p|"| +0#0000000&@35
+||+0#0000e05#a8a8a8255@2| @4|c+0#00e0003#ffffff0|l|a|s@1|=+0#00e0e07&|"+0#e000002&|p|"|>+0#00e0e07&|P+0#0000000&|a|r|a|g|r|a|p|h| |#|1|2|.|<+0#00e0e07&|/|p+0#af5f00255&|>+0#00e0e07&|<|p+0#af5f00255&| +0#0000000&@36
+||+0#0000e05#a8a8a8255@1| @5|c+0#00e0003#ffffff0|l|a|s@1|=+0#00e0e07&|"+0#e000002&|p|"|>+0#00e0e07&|P+0#0000000&|a|r|a|g|r|a|p|h| |#|1|3|.|<+0#00e0e07&|/|p+0#af5f00255&|>+0#00e0e07&|<|p+0#af5f00255&| +0#0000000&@36
+||+0#0000e05#a8a8a8255@1| @5|>+0#00e0e07#ffffff0|P+0#0000000&|a|r|a|g|r|a|p|h| |#|1|4|.|<+0#00e0e07&|/|p+0#af5f00255&|>+0#00e0e07&| +0#0000000&@47
+||+0#0000e05#a8a8a8255@1| @5| +0#0000000#ffffff0@66
+||+0#0000e05#a8a8a8255@1| @5|<+0#00e0e07#ffffff0|p+0#af5f00255&|>+0#00e0e07&|P+0#0000000&|a|r|a|g|r|a|p|h| |#|1|5|.| @49
+||+0#0000e05#a8a8a8255@1| @5|<+0#00e0e07#ffffff0|p+0#af5f00255&|>+0#00e0e07&|P+0#0000000&|a|r|a|g|r|a|p|h| |#|1|6|.| @49
+@57|9|1|,|0|-|1| @7|9|7|%|
diff --git a/runtime/syntax/testdir/dumps/html_fold_expr_06.dump b/runtime/syntax/testdir/dumps/html_fold_expr_06.dump
new file mode 100644
index 0000000..97e500f
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/html_fold_expr_06.dump
@@ -0,0 +1,20 @@
+||+0#0000e05#a8a8a8255@1| @5|<+0#00e0e07#ffffff0|p+0#af5f00255&|>+0#00e0e07&|P+0#0000000&|a|r|a|g|r|a|p|h| |#|1|6|.| @49
+||+0#0000e05#a8a8a8255@1| @5|<+0#00e0e07#ffffff0|/|B+0#af5f00255&|o|D|y|>+0#00e0e07&| +0#0000000&@59
+||+0#0000e05#a8a8a8255| @6><+0#00e0e07#ffffff0|/|H+0#af5f00255&|T|M|L|>+0#00e0e07&| +0#0000000&@59
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+| +0#0000000&@56|1|0|5|,|1| @8|B|o|t|
diff --git a/runtime/syntax/testdir/dumps/html_fold_syntax_00.dump b/runtime/syntax/testdir/dumps/html_fold_syntax_00.dump
new file mode 100644
index 0000000..06611aa
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/html_fold_syntax_00.dump
@@ -0,0 +1,20 @@
+| +0#0000e05#a8a8a8255@7><+0&#ffffff0|!|D|O|C|T|Y|P|E| |h|t|m|l|>| +0#0000000&@51
+| +0#0000e05#a8a8a8255@7|<+0&#ffffff0|!|-@1| +0#0000000&@62
+| +0#0000e05#a8a8a8255@7|V+0&#ffffff0|I|M|_|T|E|S|T|_|S|E|T|U|P| |l|e|t| |g|:|h|t|m|l|_|s|y|n|t|a|x|_|f|o|l|d|i|n|g| |=| |1| +0#0000000&@22
+| +0#0000e05#a8a8a8255@7|V+0&#ffffff0|I|M|_|T|E|S|T|_|S|E|T|U|P| |s|e|t|l|o|c|a|l| |f|o|l|d|c|o|l|u|m|n|=|8| |f|o|l|d|l|e|v|e|l|=|8| |f|o|l|d|m|e|t|h|o|d|=|s|y|n|t|a|x| +0#0000000&
+| +0#0000e05#a8a8a8255@7| +0#0000000#ffffff0@66
+| +0#0000e05#a8a8a8255@7| +0#0000000#ffffff0@66
+| +0#0000e05#a8a8a8255@7|-+0&#ffffff0@1|>| +0#0000000&@63
+|-+0#0000e05#a8a8a8255| @6|<+0#00e0e07#ffffff0|h+0#af5f00255&|t|m|l| +0#00e0e07&|l+0#00e0003&|a|n|g|=+0#00e0e07&|"+0#e000002&|e|n|"|>+0#00e0e07&| +0#0000000&@7|<+0#0000e05&|!|-@1| |1| |-@1|>| +0#0000000&@32
+||+0#0000e05#a8a8a8255|-| @5|<+0#00e0e07#ffffff0|H+0#af5f00255&|E|A|D|>+0#00e0e07&| +0#e000e06&@17|<+0#0000e05&|!|-@1| |2| |-@1|>| +0#0000000&@32
+||+0#0000e05#a8a8a8255@1| @5|<+0#00e0e07#ffffff0|m+0#af5f00255&|e|t|a| +0#00e0e07&|c+0#00e0003&|h|a|r|s|e|t|=+0#00e0e07&|"+0#e000002&|U|T|F|-|8|"|>+0#00e0e07&| +0#0000000&@44
+||+0#0000e05#a8a8a8255@1|-| @4|<+0#00e0e07#ffffff0|t+0#af5f00255&|i|t|l|e|>+0#00e0e07&|A+0#e000e06&| |f|o|l|d|i|n|g| |s|y|n|t|a|x| |t|e|s|t|<+0#00e0e07&|/|t+0#af5f00255&|i|t|l|e|>+0#00e0e07&|<|s+0#af5f00255&|t|y|l|e|>+0#00e0e07&| +0#0000000&|/+0#0000e05&|*| |3| |*|/| +0#0000000&@15
+||+0#0000e05#a8a8a8255@2| @4|p+0#af5f00255#ffffff0| +0#0000000&|{+0#00e0e07&| +0#0000000&|f+0#00e0003&|o|n|t|-|s|i|z|e|:+0#0000000&| |2+0#e000002&|4|p|x|;+0#0000000&| |}+0#00e0e07&| +0#0000000&|/+0#0000e05&|*| |<|/|s|t|y|l|e|>| +0#0000000&@32
+||+0#0000e05#a8a8a8255@1| @5|<+0#00e0e07#ffffff0|s+0#af5f00255&|t|y|l|e|>+0#00e0e07&|*+0#af5f00255&|/+0#0000000&|<+0#00e0e07&|/|s+0#af5f00255&|t|y|l|e|>+0#00e0e07&|<|/|h+0#af5f00255&|e|a|d|>+0#00e0e07&|<|/|h+0#af5f00255&|e|a|d|>+0#00e0e07&|<|/|h+0#af5f00255&|e|a|d|>+0#00e0e07&|<|/|h+0#af5f00255&|e|a|d|>+0#00e0e07&| +0#0000000&@21
+||+0#0000e05#a8a8a8255| @6| +0#0000000#ffffff0@66
+||+0#0000e05#a8a8a8255|-| @5|<+0#00e0e07#ffffff0|b+0#af5f00255&|O|d|Y| +0#00e0e07&|S+0#00e0003&|T|Y|L|E|=+0#00e0e07&|"+0#e000002&|b|a|c|k|g|r|o|u|n|d|:| |#|b|e|b|e|b|e|"|>+0#00e0e07&| +0#0000000&@5|<+0#0000e05&|!|-@1| |2| |-@1|>| +0#0000000&@16
+||+0#0000e05#a8a8a8255@1|-| @4|<+0#00e0e07#ffffff0|b+0#af5f00255&|r|>+0#00e0e07&|<|b+0#af5f00255&|r|>+0#00e0e07&|<|b+0#af5f00255&|r|>+0#00e0e07&|<|b+0#af5f00255&|r|>+0#00e0e07&|<|s+0#af5f00255&|c|r|i|p|t|>+0#00e0e07&|<+0#e000e06&|!|[+0#00e0e07&|C+0#e000e06&|D|A|T|A|[+0#00e0e07&| +0#e000e06&@6|/+0#0000e05&@1| |3| +0#0000000&@22
+||+0#0000e05#a8a8a8255@2| @4|/+0&#ffffff0@1| |\|x|3|C|!|-@1| +0#0000000&@56
+||+0#0000e05#a8a8a8255@2| @4|/+0&#ffffff0@1| |\|x|3|C|s|c|r|i|p|t|>| +0#0000000&@52
+||+0#0000e05#a8a8a8255@2| @4|/+0&#ffffff0@1| |\|x|3|C|/|s|c|r|i|p|t|>| +0#0000000&@51
+@57|1|,|1| @10|T|o|p|
diff --git a/runtime/syntax/testdir/dumps/html_fold_syntax_01.dump b/runtime/syntax/testdir/dumps/html_fold_syntax_01.dump
new file mode 100644
index 0000000..b50223d
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/html_fold_syntax_01.dump
@@ -0,0 +1,20 @@
+||+0#0000e05#a8a8a8255| @6| +0#0000000#ffffff0@66
+||+0#0000e05#a8a8a8255|-| @5|<+0#00e0e07#ffffff0|b+0#af5f00255&|O|d|Y| +0#00e0e07&|S+0#00e0003&|T|Y|L|E|=+0#00e0e07&|"+0#e000002&|b|a|c|k|g|r|o|u|n|d|:| |#|b|e|b|e|b|e|"|>+0#00e0e07&| +0#0000000&@5|<+0#0000e05&|!|-@1| |2| |-@1|>| +0#0000000&@16
+||+0#0000e05#a8a8a8255@1|-| @4|<+0#00e0e07#ffffff0|b+0#af5f00255&|r|>+0#00e0e07&|<|b+0#af5f00255&|r|>+0#00e0e07&|<|b+0#af5f00255&|r|>+0#00e0e07&|<|b+0#af5f00255&|r|>+0#00e0e07&|<|s+0#af5f00255&|c|r|i|p|t|>+0#00e0e07&|<+0#e000e06&|!|[+0#00e0e07&|C+0#e000e06&|D|A|T|A|[+0#00e0e07&| +0#e000e06&@6|/+0#0000e05&@1| |3| +0#0000000&@22
+||+0#0000e05#a8a8a8255@2| @4|/+0&#ffffff0@1| |\|x|3|C|!|-@1| +0#0000000&@56
+||+0#0000e05#a8a8a8255@2| @4|/+0&#ffffff0@1| |\|x|3|C|s|c|r|i|p|t|>| +0#0000000&@52
+||+0#0000e05#a8a8a8255@2| @4>/+0&#ffffff0@1| |\|x|3|C|/|s|c|r|i|p|t|>| +0#0000000&@51
+||+0#0000e05#a8a8a8255@2| @4|/+0&#ffffff0@1| |-@1|>| +0#0000000&@60
+||+0#0000e05#a8a8a8255@2| @4|]+0#00e0e07#ffffff0@1|>+0#e000e06&|<+0#00e0e07&|/|s+0#af5f00255&|c|r|i|p|t|>+0#00e0e07&| +0#0000000&@54
+||+0#0000e05#a8a8a8255@1| @5|<+0#00e0e07#ffffff0|h+0#af5f00255&|2| +0#00e0e07&|i+0#00e0003&|d|=+0#00e0e07&|"+0#e000002&|>|<|/|h|2|>|"|>+0#00e0e07&|<|i+0#af5f00255&|>+0#00e0e07&|A+0#e000e06&|n| |H|2| |h|e|a|d|e|r|<+0#00e0e07&|/|i+0#af5f00255&|>+0#00e0e07&|<|/|h+0#af5f00255&|2|>+0#00e0e07&| +0#0000000&@26
+||+0#0000e05#a8a8a8255@1| @5|<+0#00e0e07#ffffff0|b+0#af5f00255&|r|>+0#00e0e07&|<|b+0#af5f00255&|r|>+0#00e0e07&|<|b+0#af5f00255&|r|>+0#00e0e07&|<|b+0#af5f00255&|r|>+0#00e0e07&| +0#0000000&@50
+||+0#0000e05#a8a8a8255@1| @5|<+0#00e0e07#ffffff0|h+0#af5f00255&|r|>+0#00e0e07&| +0#0000000&@62
+||+0#0000e05#a8a8a8255@1| @5| +0#0000000#ffffff0@66
+||+0#0000e05#a8a8a8255@1|-| @4|<+0#00e0e07#ffffff0|p+0#af5f00255&|>+0#00e0e07&|P+0#0000000&|a|r|a|g|r|a|p|h| |#|1|.| @7|<+0#0000e05&|!|-@1| |3| |-@1|>| +0#0000000&@32
+||+0#0000e05#a8a8a8255@2| @4|<+0#00e0e07#ffffff0|/|p+0#af5f00255&|>+0#00e0e07&| +0#0000000&@62
+||+0#0000e05#a8a8a8255@1| @5| +0#0000000#ffffff0@66
+||+0#0000e05#a8a8a8255@1| @5|<+0#00e0e07#ffffff0|p+0#af5f00255&|>+0#00e0e07&|P+0#0000000&|a|r|a|g|r|a|p|h| |#|2|.|<+0#00e0e07&|/|p+0#af5f00255&|>+0#00e0e07&| +0#0000000&@46
+||+0#0000e05#a8a8a8255@1| @5| +0#0000000#ffffff0@66
+||+0#0000e05#a8a8a8255@1| @5|<+0#00e0e07#ffffff0|d+0#af5f00255&|e|t|a|i|l|s|>+0#00e0e07&| +0#0000000&@14|<+0#0000e05&|!|-@1| |3| |<|/|d|e|t|a|i|l|s|>| +0#0000000&|-@1|>+0#ffffff16#ff404010| +0#0000000#ffffff0@21
+||+0#0000e05#a8a8a8255@1| @5|<+0#00e0e07#ffffff0|s+0#af5f00255&|u|m@1|a|r|y|>+0#00e0e07&| +0#0000000&@14|<+0#0000e05&|!|-@1| |4| |<|/|s|u|m@1|a|r|y|>| +0#0000000&|-@1|>+0#ffffff16#ff404010| +0#0000000#ffffff0@21
+@57|1|9|,|1| @9|1|5|%|
diff --git a/runtime/syntax/testdir/dumps/html_fold_syntax_02.dump b/runtime/syntax/testdir/dumps/html_fold_syntax_02.dump
new file mode 100644
index 0000000..cc0060e
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/html_fold_syntax_02.dump
@@ -0,0 +1,20 @@
+||+0#0000e05#a8a8a8255@1| @5|<+0#00e0e07#ffffff0|s+0#af5f00255&|u|m@1|a|r|y|>+0#00e0e07&| +0#0000000&@14|<+0#0000e05&|!|-@1| |4| |<|/|s|u|m@1|a|r|y|>| +0#0000000&|-@1|>+0#ffffff16#ff404010| +0#0000000#ffffff0@21
+||+0#0000e05#a8a8a8255@1| @5|<+0#00e0e07#ffffff0|/|s+0#af5f00255&|u|m@1|a|r|y|>+0#00e0e07&| +0#0000000&@56
+||+0#0000e05#a8a8a8255@1| @5|<+0#00e0e07#ffffff0|p+0#af5f00255&|>+0#00e0e07&|P+0#0000000&|a|r|a|g|r|a|p|h| |#|1|.|<+0#00e0e07&|/|p+0#af5f00255&|>+0#00e0e07&| +0#0000000&@46
+||+0#0000e05#a8a8a8255@1|-| @4|<+0#00e0e07#ffffff0|u+0#af5f00255&|l|>+0#00e0e07&| +0#0000000&@19|<+0#0000e05&|!|-@1| |4| |F|I|X|M|E| |-@1|>| +0#0000000&@26
+||+0#0000e05#a8a8a8255@2| @4|<+0#00e0e07#ffffff0|l+0#af5f00255&|i|>+0#00e0e07&|I+0#0000000&|t|e|m| |a|.|<+0#00e0e07&|/|l+0#af5f00255&|i|>+0#00e0e07&|<|l+0#af5f00255&|i|>+0#00e0e07&|I+0#0000000&|t|e|m| |b|.|<+0#00e0e07&|/|l+0#af5f00255&|i|>+0#00e0e07&| +0#0000000&@34
+||+0#0000e05#a8a8a8255@2| @4><+0#00e0e07#ffffff0|l+0#af5f00255&|i|>+0#00e0e07&|I+0#0000000&|t|e|m| |c|.|<+0#00e0e07&|/|l+0#af5f00255&|i|>+0#00e0e07&| +0#0000000&@50
+||+0#0000e05#a8a8a8255@2| @4|<+0#00e0e07#ffffff0|/|u+0#af5f00255&|l|>+0#00e0e07&| +0#0000000&@61
+||+0#0000e05#a8a8a8255@1|-| @4|<+0#00e0e07#ffffff0|p+0#af5f00255&|>+0#00e0e07&|P+0#0000000&|a|r|a|g|r|a|p|h| |#|2|.| @7|<+0#0000e05&|!|-@1| |4| |F|I|X|M|E| |-@1|>| +0#0000000&@26
+||+0#0000e05#a8a8a8255@2| @4|<+0#00e0e07#ffffff0|/|p+0#af5f00255&|>+0#00e0e07&| +0#0000000&@62
+||+0#0000e05#a8a8a8255@1| @5|<+0#00e0e07#ffffff0|/|d+0#af5f00255&|e|t|a|i|l|s|>+0#00e0e07&| +0#0000000&@56
+||+0#0000e05#a8a8a8255@1| @5| +0#0000000#ffffff0@66
+||+0#0000e05#a8a8a8255@1|-| @4|<+0#00e0e07#ffffff0|d+0#af5f00255&|l|>+0#00e0e07&| +0#0000000&@19|<+0#0000e05&|!|-@1| |3| |-@1|>| +0#0000000&@32
+||+0#0000e05#a8a8a8255@2| @4|<+0#00e0e07#ffffff0|d+0#af5f00255&|t|>+0#00e0e07&|A+0#0000000&| |q|u|i|c|k| |b|r|o|w|n| |f|o|x| |j|u|m|p|s| |o|v|e|r| |t|h|e| |l|a|z|y| |d|o|g|<+0#00e0e07&|/|d+0#af5f00255&|t|>+0#00e0e07&| +0#0000000&@16
+||+0#0000e05#a8a8a8255@2|-| @3|<+0#00e0e07#ffffff0|d+0#af5f00255&@1|>+0#00e0e07&|W+0#0000000&|o@1|f|!| @14|<+0#0000e05&|!|-@1| |4| |-@1|>| +0#0000000&@32
+||+0#0000e05#a8a8a8255@3|-| @2|<+0#00e0e07#ffffff0|d+0#af5f00255&|l|>+0#00e0e07&| +0#0000000&@19|<+0#0000e05&|!|-@1| |5| |-@1|>| +0#0000000&@32
+||+0#0000e05#a8a8a8255@4| @2|<+0#00e0e07#ffffff0|d+0#af5f00255&|t|>+0#00e0e07&|A+0#0000000&| |q|u|i|c|k| |b|r|o|w|n| |f|o|x| |j|u|m|p|s| |o|v|e|r| |t|h|e| |l|a|z|y| |d|o|g|<+0#00e0e07&|/|d+0#af5f00255&|t|>+0#00e0e07&| +0#0000000&@16
+||+0#0000e05#a8a8a8255@4| @2|<+0#00e0e07#ffffff0|d+0#af5f00255&@1|>+0#00e0e07&|W+0#0000000&|o@1|f|!|<+0#00e0e07&|/|d+0#af5f00255&@1|>+0#00e0e07&| +0#0000000&@52
+||+0#0000e05#a8a8a8255@4| @2|<+0#00e0e07#ffffff0|/|d+0#af5f00255&|l|>+0#00e0e07&|<|/|d+0#af5f00255&@1|>+0#00e0e07&| +0#0000000&@56
+||+0#0000e05#a8a8a8255@2| @4|<+0#00e0e07#ffffff0|/|d+0#af5f00255&|l|>+0#00e0e07&| +0#0000000&@61
+@57|3|7|,|1| @9|3|6|%|
diff --git a/runtime/syntax/testdir/dumps/html_fold_syntax_03.dump b/runtime/syntax/testdir/dumps/html_fold_syntax_03.dump
new file mode 100644
index 0000000..810f101
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/html_fold_syntax_03.dump
@@ -0,0 +1,20 @@
+||+0#0000e05#a8a8a8255@2| @4|<+0#00e0e07#ffffff0|/|d+0#af5f00255&|l|>+0#00e0e07&| +0#0000000&@61
+||+0#0000e05#a8a8a8255@1| @5| +0#0000000#ffffff0@66
+||+0#0000e05#a8a8a8255@1|-| @4|<+0#00e0e07#ffffff0|a+0#af5f00255&|r|t|i|c|l|e|>+0#00e0e07&|T+0#0000000&|h|r|e|a|d| |#|1| @5|<+0#0000e05&|!|-@1| |3| |-@1|>| +0#0000000&@32
+||+0#0000e05#a8a8a8255@2|-| @3|<+0#00e0e07#ffffff0|a+0#af5f00255&|r|t|i|c|l|e|>+0#00e0e07&|T+0#0000000&|h|r|e|a|d| |#|2| @5|<+0#0000e05&|!|-@1| |4| |-@1|>| +0#0000000&@32
+||+0#0000e05#a8a8a8255@3| @3|<+0#00e0e07#ffffff0|/|a+0#af5f00255&|r|t|i|c|l|e|>+0#00e0e07&| +0#0000000&@56
+||+0#0000e05#a8a8a8255@2| @4><+0#00e0e07#ffffff0|/|a+0#af5f00255&|r|t|i|c|l|e|>+0#00e0e07&| +0#0000000&@56
+||+0#0000e05#a8a8a8255@1| @5| +0#0000000#ffffff0@66
+||+0#0000e05#a8a8a8255@1|-| @4|<+0#00e0e07#ffffff0|p+0#af5f00255&|>+0#00e0e07&| +0#0000000&@20|<+0#0000e05&|!|-@1| |3| |-@1|>| +0#0000000&@32
+||+0#0000e05#a8a8a8255@2| @4|<+0#00e0e07#ffffff0|l+0#af5f00255&|a|b|e|l| +0#00e0e07&|f+0#00e0003&|o|r|=+0#00e0e07&|"+0#e000002&|s|e|l|e|c|t|i|o|n|"|>+0#00e0e07&|S+0#0000000&|e|l|e|c|t| |O|p|t|i|o|n|<+0#00e0e07&|/|l+0#af5f00255&|a|b|e|l|>+0#00e0e07&| +0#0000000&@22
+||+0#0000e05#a8a8a8255@2|-@1| @2|<+0#00e0e07#ffffff0|s+0#af5f00255&|e|l|e|c|t| +0#0000000&@59
+||+0#0000e05#a8a8a8255@4| @2|i+0#00e0003#ffffff0|d|=+0#00e0e07&|"+0#e000002&|s|e|l|e|c|t|i|o|n|"| +0#0000000&@52
+||+0#0000e05#a8a8a8255@4| @2|n+0#00e0003#ffffff0|a|m|e|=+0#00e0e07&|"+0#e000002&|s|e|l|e|c|t|i|o|n|"|>+0#00e0e07&| +0#0000000&@6|<+0#0000e05&|!|-@1| |5| |-@1|>| +0#0000000&@32
+||+0#0000e05#a8a8a8255@3|-| @2|<+0#00e0e07#ffffff0|o+0#af5f00255&|p|t|g|r|o|u|p| +0#00e0e07&|l+0#00e0003&|a|b|e|l|=+0#00e0e07&|"+0#e000002&|P|r|i|m|a|r|y| |G|r|o|u|p|"|>+0#00e0e07&| +0#0000000&@7|<+0#0000e05&|!|-@1| |5| |-@1|>| +0#0000000&@16
+||+0#0000e05#a8a8a8255@4| @2|<+0#00e0e07#ffffff0|o+0#af5f00255&|p|t|i|o|n| +0#00e0e07&|v+0#00e0003&|a|l|u|e|=+0#00e0e07&|"+0#e000002&|1|"|>+0#00e0e07&|A+0#0000000&|l|t|e|r|n|a|t|i|v|e|<+0#00e0e07&|/|o+0#af5f00255&|p|t|i|o|n|>+0#00e0e07&| +0#0000000&@28
+||+0#0000e05#a8a8a8255@4| @2|<+0#00e0e07#ffffff0|o+0#af5f00255&|p|t|i|o|n| +0#00e0e07&|v+0#00e0003&|a|l|u|e|=+0#00e0e07&|"+0#e000002&|2|"| +0#00e0e07&|s+0#00e0003&|e|l|e|c|t|e|d|>+0#00e0e07&|D+0#0000000&|e|f|a|u|l|t|<+0#00e0e07&|/|o+0#af5f00255&|p|t|i|o|n|>+0#00e0e07&| +0#0000000&@23
+||+0#0000e05#a8a8a8255@4| @2|<+0#00e0e07#ffffff0|o+0#af5f00255&|p|t|i|o|n| +0#00e0e07&|v+0#00e0003&|a|l|u|e|=+0#00e0e07&|"+0#e000002&|3|"|>+0#00e0e07&|B+0#0000000&|a|s|i|c|<+0#00e0e07&|/|o+0#af5f00255&|p|t|i|o|n|>+0#00e0e07&| +0#0000000&@34
+||+0#0000e05#a8a8a8255@4| @2|<+0#00e0e07#ffffff0|o+0#af5f00255&|p|t|i|o|n| +0#00e0e07&|v+0#00e0003&|a|l|u|e|=+0#00e0e07&|"+0#e000002&|4|"|>+0#00e0e07&|E+0#0000000&|x|t|e|n|d|e|d|<+0#00e0e07&|/|o+0#af5f00255&|p|t|i|o|n|>+0#00e0e07&| +0#0000000&@31
+||+0#0000e05#a8a8a8255@4| @2|<+0#00e0e07#ffffff0|/|o+0#af5f00255&|p|t|g|r|o|u|p|>+0#00e0e07&| +0#0000000&@55
+||+0#0000e05#a8a8a8255@3| @3|<+0#00e0e07#ffffff0|/|s+0#af5f00255&|e|l|e|c|t|>+0#00e0e07&| +0#0000000&@57
+@57|5@1|,|1| @9|5|6|%|
diff --git a/runtime/syntax/testdir/dumps/html_fold_syntax_04.dump b/runtime/syntax/testdir/dumps/html_fold_syntax_04.dump
new file mode 100644
index 0000000..b3c4382
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/html_fold_syntax_04.dump
@@ -0,0 +1,20 @@
+||+0#0000e05#a8a8a8255@3| @3|<+0#00e0e07#ffffff0|/|s+0#af5f00255&|e|l|e|c|t|>+0#00e0e07&| +0#0000000&@57
+||+0#0000e05#a8a8a8255@2| @4|<+0#00e0e07#ffffff0|/|p+0#af5f00255&|>+0#00e0e07&| +0#0000000&@62
+||+0#0000e05#a8a8a8255@1| @5| +0#0000000#ffffff0@66
+||+0#0000e05#a8a8a8255@1|-| @4|<+0#00e0e07#ffffff0|t+0#af5f00255&|a|b|l|e|>+0#00e0e07&| +0#0000000&@16|<+0#0000e05&|!|-@1| |3| |-@1|>| +0#0000000&@32
+||+0#0000e05#a8a8a8255@2| @4|<+0#00e0e07#ffffff0|c+0#af5f00255&|a|p|t|i|o|n|>+0#00e0e07&|S+0#0000000&|o|m|e| |C|a|p|t|i|o|n|<+0#00e0e07&|/|c+0#af5f00255&|a|p|t|i|o|n|>+0#00e0e07&| +0#0000000&@35
+||+0#0000e05#a8a8a8255@2| @4><+0#00e0e07#ffffff0|c+0#af5f00255&|o|l|g|r|o|u|p|>+0#00e0e07&|<|c+0#af5f00255&|o|l|>+0#00e0e07&|<|c+0#af5f00255&|o|l|>+0#00e0e07&|<|c+0#af5f00255&|o|l|>+0#00e0e07&|<|/|c+0#af5f00255&|o|l|g|r|o|u|p|>+0#00e0e07&| +0#0000000&@30
+||+0#0000e05#a8a8a8255@2|-| @3|<+0#00e0e07#ffffff0|t+0#af5f00255&|h|e|a|d|>+0#00e0e07&| +0#0000000&@16|<+0#0000e05&|!|-@1| |4| |-@1|>| +0#0000000&@32
+||+0#0000e05#a8a8a8255@3| @3|<+0#00e0e07#ffffff0|t+0#af5f00255&|r|>+0#00e0e07&|<|t+0#af5f00255&|h|>+0#00e0e07&|H+0#0000000&|e|a|d|e|r| |#|1|<+0#00e0e07&|/|t+0#af5f00255&|h|>+0#00e0e07&|<|t+0#af5f00255&|h|>+0#00e0e07&|H+0#0000000&|e|a|d|e|r| |#|2|<+0#00e0e07&|/|t+0#af5f00255&|h|>+0#00e0e07&|<|t+0#af5f00255&|h|>+0#00e0e07&|H+0#0000000&|e|a|d|e|r| |#|3|<+0#00e0e07&|/|t+0#af5f00255&|h|>+0#00e0e07&|<|/|t+0#af5f00255&|r|>+0#00e0e07&| +0#0000000&@3
+||+0#0000e05#a8a8a8255@3| @3|<+0#00e0e07#ffffff0|/|t+0#af5f00255&|h|e|a|d|>+0#00e0e07&|<|t+0#af5f00255&|b|o|d|y|>+0#00e0e07&| +0#0000000&@51
+||+0#0000e05#a8a8a8255@3| @3|<+0#00e0e07#ffffff0|t+0#af5f00255&|r|>+0#00e0e07&|<|t+0#af5f00255&|d|>+0#00e0e07&|C+0#0000000&|o|l|u|m|n| |#|1|<+0#00e0e07&|/|t+0#af5f00255&|d|>+0#00e0e07&|<|t+0#af5f00255&|d|>+0#00e0e07&|C+0#0000000&|o|l|u|m|n| |#|2|<+0#00e0e07&|/|t+0#af5f00255&|d|>+0#00e0e07&|<|t+0#af5f00255&|d|>+0#00e0e07&|C+0#0000000&|o|l|u|m|n| |#|3|<+0#00e0e07&|/|t+0#af5f00255&|d|>+0#00e0e07&|<|/|t+0#af5f00255&|r|>+0#00e0e07&| +0#0000000&@3
+||+0#0000e05#a8a8a8255@3| @3|<+0#00e0e07#ffffff0|t+0#af5f00255&|r|>+0#00e0e07&|<|t+0#af5f00255&|d|>+0#00e0e07&|C+0#0000000&|o|l|u|m|n| |#|1|<+0#00e0e07&|/|t+0#af5f00255&|d|>+0#00e0e07&|<|t+0#af5f00255&|d|>+0#00e0e07&|C+0#0000000&|o|l|u|m|n| |#|2|<+0#00e0e07&|/|t+0#af5f00255&|d|>+0#00e0e07&|<|t+0#af5f00255&|d|>+0#00e0e07&|C+0#0000000&|o|l|u|m|n| |#|3|<+0#00e0e07&|/|t+0#af5f00255&|d|>+0#00e0e07&|<|/|t+0#af5f00255&|r|>+0#00e0e07&| +0#0000000&@3
+||+0#0000e05#a8a8a8255@3| @3|<+0#00e0e07#ffffff0|t+0#af5f00255&|r|>+0#00e0e07&|<|t+0#af5f00255&|d|>+0#00e0e07&|C+0#0000000&|o|l|u|m|n| |#|1|<+0#00e0e07&|/|t+0#af5f00255&|d|>+0#00e0e07&|<|t+0#af5f00255&|d|>+0#00e0e07&|C+0#0000000&|o|l|u|m|n| |#|2|<+0#00e0e07&|/|t+0#af5f00255&|d|>+0#00e0e07&|<|t+0#af5f00255&|d|>+0#00e0e07&|C+0#0000000&|o|l|u|m|n| |#|3|<+0#00e0e07&|/|t+0#af5f00255&|d|>+0#00e0e07&|<|/|t+0#af5f00255&|r|>+0#00e0e07&| +0#0000000&@3
+||+0#0000e05#a8a8a8255@3| @3|<+0#00e0e07#ffffff0|t+0#af5f00255&|r|>+0#00e0e07&|<|t+0#af5f00255&|d|>+0#00e0e07&|C+0#0000000&|o|l|u|m|n| |#|1|<+0#00e0e07&|/|t+0#af5f00255&|d|>+0#00e0e07&|<|t+0#af5f00255&|d|>+0#00e0e07&|C+0#0000000&|o|l|u|m|n| |#|2|<+0#00e0e07&|/|t+0#af5f00255&|d|>+0#00e0e07&|<|t+0#af5f00255&|d|>+0#00e0e07&|C+0#0000000&|o|l|u|m|n| |#|3|<+0#00e0e07&|/|t+0#af5f00255&|d|>+0#00e0e07&|<|/|t+0#af5f00255&|r|>+0#00e0e07&| +0#0000000&@3
+||+0#0000e05#a8a8a8255@3| @3|<+0#00e0e07#ffffff0|/|t+0#af5f00255&|b|o|d|y|>+0#00e0e07&|<|/|t+0#af5f00255&|a|b|l|e|>+0#00e0e07&| +0#0000000&@50
+||+0#0000e05#a8a8a8255@1| @5| +0#0000000#ffffff0@66
+||+0#0000e05#a8a8a8255@1|-| @4|<+0#00e0e07#ffffff0|d+0#af5f00255&|i|v| +0#00e0e07&|c+0#00e0003&|l|a|s@1|=+0#00e0e07&|"+0#e000002&|b|l|o|c|k|"|>+0#00e0e07&| +0#0000000&@4|<+0#0000e05&|!|-@1| |3| |-@1|>| +0#0000000&@32
+||+0#0000e05#a8a8a8255@2|-@2| @1|<+0#00e0e07#ffffff0|b+0#af5f00255&|l|o|c|k|q|u|o|t|e|>+0#00e0e07&|<|p+0#af5f00255&|r|e|>+0#00e0e07&|<|c+0#af5f00255&|o|d|e|>+0#00e0e07&| +0#0000000&|<+0#0000e05&|!|-@1| |6| |-@1|>| +0#0000000&@32
+||+0#0000e05#a8a8a8255@5| @1|&+0#e000e06#ffffff0|l|t|;|d+0#0000000&|i|v| |c|l|a|s@1|=|"|b|l|o|c|k|"|&+0#e000e06&|g|t|;| +0#0000000&@41
+||+0#0000e05#a8a8a8255@5| @1|&+0#e000e06#ffffff0|l|t|;|b+0#0000000&|l|o|c|k|q|u|o|t|e|&+0#e000e06&|g|t|;|&|l|t|;|p+0#0000000&|r|e|&+0#e000e06&|g|t|;|&|l|t|;|c+0#0000000&|o|d|e|&+0#e000e06&|g|t|;| +0#0000000&@25
+@57|7|3|,|1| @9|7@1|%|
diff --git a/runtime/syntax/testdir/dumps/html_fold_syntax_05.dump b/runtime/syntax/testdir/dumps/html_fold_syntax_05.dump
new file mode 100644
index 0000000..a76fa82
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/html_fold_syntax_05.dump
@@ -0,0 +1,20 @@
+||+0#0000e05#a8a8a8255@5| @1|&+0#e000e06#ffffff0|l|t|;|b+0#0000000&|l|o|c|k|q|u|o|t|e|&+0#e000e06&|g|t|;|&|l|t|;|p+0#0000000&|r|e|&+0#e000e06&|g|t|;|&|l|t|;|c+0#0000000&|o|d|e|&+0#e000e06&|g|t|;| +0#0000000&@25
+||+0#0000e05#a8a8a8255@5| @1|&+0#e000e06#ffffff0|l|t|;|/+0#0000000&|c|o|d|e|&+0#e000e06&|g|t|;|&|l|t|;|/+0#0000000&|p|r|e|&+0#e000e06&|g|t|;|&|l|t|;|/+0#0000000&|b|l|o|c|k|q|u|o|t|e|&+0#e000e06&|g|t|;|&|l|t|;|/+0#0000000&|d|i|v|&+0#e000e06&|g|t|;| +0#0000000&@10
+||+0#0000e05#a8a8a8255@5| @1|<+0#00e0e07#ffffff0|/|c+0#af5f00255&|o|d|e|>+0#00e0e07&|<|/|p+0#af5f00255&|r|e|>+0#00e0e07&|<|/|b+0#af5f00255&|l|o|c|k|q|u|o|t|e|>+0#00e0e07&|<|/|d+0#af5f00255&|i|v|>+0#00e0e07&| +0#0000000&@34
+||+0#0000e05#a8a8a8255@1| @5| +0#0000000#ffffff0@66
+||+0#0000e05#a8a8a8255@1| @5|<+0#00e0e07#ffffff0|p+0#af5f00255&|>+0#00e0e07&|P+0#0000000&|a|r|a|g|r|a|p|h| |#|3|.|<+0#00e0e07&|/|p+0#af5f00255&|>+0#00e0e07&|<|p+0#af5f00255&|>+0#00e0e07&|P+0#0000000&|a|r|a|g|r|a|p|h| |#|4|.|<+0#00e0e07&|/|p+0#af5f00255&|>+0#00e0e07&|<|p+0#af5f00255&|>+0#00e0e07&|P+0#0000000&|a|r|a|g|r|a|p|h| |#|5|.|<+0#00e0e07&|/|p+0#af5f00255&|>+0#00e0e07&| +0#0000000&@6
+||+0#0000e05#a8a8a8255@1| @5> +0#0000000#ffffff0@66
+||+0#0000e05#a8a8a8255@1| @5|<+0#00e0e07#ffffff0|p+0#af5f00255&|>+0#00e0e07&|P+0#0000000&|a|r|a|g|r|a|p|h| |#|6|.|<+0#00e0e07&|/|p+0#af5f00255&|>+0#00e0e07&|<|p+0#af5f00255&|>+0#00e0e07&|P+0#0000000&|a|r|a|g|r|a|p|h| |#|7|.|<+0#00e0e07&|/|p+0#af5f00255&|>+0#00e0e07&|<|p+0#af5f00255&|>+0#00e0e07&|P+0#0000000&|a|r|a|g|r|a|p|h| |#|8|.|<+0#00e0e07&|/|p+0#af5f00255&|>+0#00e0e07&|<|p+0#af5f00255&|>+0#00e0e07&|P+0#0000000&|a|r|a
+||+0#0000e05#a8a8a8255@1| @5|g+0#0000000#ffffff0|r|a|p|h| |#|9|.|<+0#00e0e07&|/|p+0#af5f00255&|>+0#00e0e07&| +0#0000000&@53
+||+0#0000e05#a8a8a8255@1| @5| +0#0000000#ffffff0@66
+||+0#0000e05#a8a8a8255@1| @5|<+0#00e0e07#ffffff0|p+0#af5f00255&| +0#00e0e07&|i+0#00e0003&|d|=+0#00e0e07&|"+0#e000002&|>|<|/|p|>|"+0#0000000&|>+0#ffffff16#ff404010|P+0#0000000#ffffff0|a|r|a|g|r|a|p|h| |#|1|0|.| @3|<+0#0000e05&|!|-@1| |3| |F|I|X|M|E| |-@1|>| +0#0000000&@18
+||+0#0000e05#a8a8a8255@1| @5|<+0#00e0e07#ffffff0|/|p+0#af5f00255&|>+0#00e0e07&| +0#0000000&@62
+||+0#0000e05#a8a8a8255@1| @5| +0#0000000#ffffff0@66
+||+0#0000e05#a8a8a8255@1| @5|<+0#00e0e07#ffffff0|p+0#af5f00255&| +0#00e0e07&|>|P+0#0000000&|a|r|a|g|r|a|p|h| |#|1@1|.|<+0#00e0e07&|/|p+0#af5f00255&|>+0#00e0e07&|<+0#0000000&|p| |i|d|=|"|p|"| @35
+||+0#0000e05#a8a8a8255@1| @5|c+0#0000000#ffffff0|l|a|s@1|=|"|p|"|>+0#ffffff16#ff404010|P+0#0000000#ffffff0|a|r|a|g|r|a|p|h| |#|1|2|.|<+0#00e0e07&|/|p+0#af5f00255&|>+0#00e0e07&|<+0#0000000&|p| @36
+||+0#0000e05#a8a8a8255@1| @5|c+0#0000000#ffffff0|l|a|s@1|=|"|p|"|>+0#ffffff16#ff404010|P+0#0000000#ffffff0|a|r|a|g|r|a|p|h| |#|1|3|.|<+0#00e0e07&|/|p+0#af5f00255&|>+0#00e0e07&|<+0#0000000&|p| @36
+||+0#0000e05#a8a8a8255@1| @5|>+0#ffffff16#ff404010|P+0#0000000#ffffff0|a|r|a|g|r|a|p|h| |#|1|4|.|<+0#00e0e07&|/|p+0#af5f00255&|>+0#00e0e07&| +0#0000000&@47
+||+0#0000e05#a8a8a8255@1| @5| +0#0000000#ffffff0@66
+||+0#0000e05#a8a8a8255@1|-| @4|<+0#00e0e07#ffffff0|p+0#af5f00255&|>+0#00e0e07&|P+0#0000000&|a|r|a|g|r|a|p|h| |#|1|5|.| @6|<+0#0000e05&|!|-@1| |U|N|B|A|L|A|N|C|E|D|!| |-@1|>| +0#0000000&@22
+||+0#0000e05#a8a8a8255@2|-| @3|<+0#00e0e07#ffffff0|p+0#af5f00255&|>+0#00e0e07&|P+0#0000000&|a|r|a|g|r|a|p|h| |#|1|6|.| @6|<+0#0000e05&|!|-@1| |U|N|B|A|L|A|N|C|E|D|!| |-@1|>| +0#0000000&@22
+@57|9|1|,|0|-|1| @7|9|7|%|
diff --git a/runtime/syntax/testdir/dumps/html_fold_syntax_06.dump b/runtime/syntax/testdir/dumps/html_fold_syntax_06.dump
new file mode 100644
index 0000000..a6b936e
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/html_fold_syntax_06.dump
@@ -0,0 +1,20 @@
+||+0#0000e05#a8a8a8255@2|-| @3|<+0#00e0e07#ffffff0|p+0#af5f00255&|>+0#00e0e07&|P+0#0000000&|a|r|a|g|r|a|p|h| |#|1|6|.| @6|<+0#0000e05&|!|-@1| |U|N|B|A|L|A|N|C|E|D|!| |-@1|>| +0#0000000&@22
+||+0#0000e05#a8a8a8255@3| @3|<+0#00e0e07#ffffff0|/|B+0#af5f00255&|o|D|y|>+0#00e0e07&| +0#0000000&@59
+||+0#0000e05#a8a8a8255@3| @3><+0#00e0e07#ffffff0|/|H+0#af5f00255&|T|M|L|>+0#00e0e07&| +0#0000000&@59
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+| +0#0000000&@56|1|0|5|,|1| @8|B|o|t|
diff --git a/runtime/syntax/testdir/input/html_fold_expr.html b/runtime/syntax/testdir/input/html_fold_expr.html
new file mode 100644
index 0000000..f85e7fa
--- /dev/null
+++ b/runtime/syntax/testdir/input/html_fold_expr.html
@@ -0,0 +1,105 @@
+<!DOCTYPE html>
+<!--
+VIM_TEST_SETUP setlocal foldcolumn=8 foldlevel=8 foldmethod=expr
+
+
+
+-->
+<html lang="en"> <!-- 1 -->
+<HEAD> <!-- 2 -->
+<meta charset="UTF-8">
+<title>A folding syntax test</title><style> /* 3 FIXME */
+p { font-size: 24px; } /* </style>
+<style>*/</style></head></head></head></head>
+
+<bOdY STYLE="background: #bebebe"> <!-- 2 -->
+<br><br><br><br><script><![CDATA[ // 3
+// \x3C!--
+// \x3Cscript>
+// \x3C/script>
+// -->
+]]></script>
+<h2 id="></h2>"><i>An H2 header</i></h2>
+<br><br><br><br>
+<hr>
+
+<p>Paragraph #1. <!-- 3 -->
+</p>
+
+<p>Paragraph #2.
+
+<details> <!-- 3 </details> -->
+<summary> <!-- 4 </summary> -->
+</summary>
+<p>Paragraph #1.
+<ul> <!-- 4 -->
+<li>Item a.</li><li>Item b.</li>
+<li>Item c.
+</ul>
+<p>Paragraph #2. <!-- 4 -->
+</p>
+</details>
+
+<dl> <!-- 3 -->
+<dt>A quick brown fox jumps over the lazy dog
+<dd>Woof!
+<dl> <!-- 4 -->
+<dt>A quick brown fox jumps over the lazy dog
+<dd>Woof!
+</dl>
+</dl>
+
+<article>Thread #1 <!-- 3 -->
+<article>Thread #2 <!-- 4 -->
+</article>
+</article>
+
+<p> <!-- 3 -->
+<label for="selection">Select Option</label>
+<select
+id="selection"
+name="selection"> <!-- 4 -->
+<optgroup label="Primary Group"> <!-- 5 -->
+<option value="1">Alternative
+<option value="2" selected>Default
+<option value="3">Basic
+<option value="4">Extended
+</optgroup>
+</select>
+</p>
+
+<table> <!-- 3 -->
+<caption>Some Caption</caption>
+<colgroup><col><col><col>
+<thead>
+<tr><th>Header #1<th>Header #2<th>Header #3
+<tbody>
+<tr><td>Column #1<td>Column #2<td>Column #3
+<tr><td>Column #1<td>Column #2<td>Column #3
+<tr><td>Column #1<td>Column #2<td>Column #3
+<tr><td>Column #1<td>Column #2<td>Column #3
+</table>
+
+<div class="block"> <!-- 3 -->
+<blockquote><pre><code> <!-- 4 -->
+<div class="block">
+<blockquote><pre><code>
+</code></pre></blockquote></div>
+</code></pre></blockquote></div>
+
+<p>Paragraph #3.</p><p>Paragraph #4.</p><p>Paragraph #5.
+
+<p>Paragraph #6.</p><p>Paragraph #7.</p><p>Paragraph #8.</p><p>Paragraph #9.</p>
+
+<p id="></p>">Paragraph #10. <!-- 3 -->
+</p>
+
+<p >Paragraph #11.</p><p id="p"
+class="p">Paragraph #12.</p><p
+class="p">Paragraph #13.</p><p
+>Paragraph #14.</p>
+
+<p>Paragraph #15.
+<p>Paragraph #16.
+</BoDy>
+</HTML>
diff --git a/runtime/syntax/testdir/input/html_fold_syntax.html b/runtime/syntax/testdir/input/html_fold_syntax.html
new file mode 100644
index 0000000..73579aa
--- /dev/null
+++ b/runtime/syntax/testdir/input/html_fold_syntax.html
@@ -0,0 +1,105 @@
+<!DOCTYPE html>
+<!--
+VIM_TEST_SETUP let g:html_syntax_folding = 1
+VIM_TEST_SETUP setlocal foldcolumn=8 foldlevel=8 foldmethod=syntax
+
+
+-->
+<html lang="en"> <!-- 1 -->
+<HEAD> <!-- 2 -->
+<meta charset="UTF-8">
+<title>A folding syntax test</title><style> /* 3 */
+p { font-size: 24px; } /* </style>
+<style>*/</style></head></head></head></head>
+
+<bOdY STYLE="background: #bebebe"> <!-- 2 -->
+<br><br><br><br><script><![CDATA[ // 3
+// \x3C!--
+// \x3Cscript>
+// \x3C/script>
+// -->
+]]></script>
+<h2 id="></h2>"><i>An H2 header</i></h2>
+<br><br><br><br>
+<hr>
+
+<p>Paragraph #1. <!-- 3 -->
+</p>
+
+<p>Paragraph #2.</p>
+
+<details> <!-- 3 </details> -->
+<summary> <!-- 4 </summary> -->
+</summary>
+<p>Paragraph #1.</p>
+<ul> <!-- 4 FIXME -->
+<li>Item a.</li><li>Item b.</li>
+<li>Item c.</li>
+</ul>
+<p>Paragraph #2. <!-- 4 FIXME -->
+</p>
+</details>
+
+<dl> <!-- 3 -->
+<dt>A quick brown fox jumps over the lazy dog</dt>
+<dd>Woof! <!-- 4 -->
+<dl> <!-- 5 -->
+<dt>A quick brown fox jumps over the lazy dog</dt>
+<dd>Woof!</dd>
+</dl></dd>
+</dl>
+
+<article>Thread #1 <!-- 3 -->
+<article>Thread #2 <!-- 4 -->
+</article>
+</article>
+
+<p> <!-- 3 -->
+<label for="selection">Select Option</label>
+<select
+id="selection"
+name="selection"> <!-- 5 -->
+<optgroup label="Primary Group"> <!-- 5 -->
+<option value="1">Alternative</option>
+<option value="2" selected>Default</option>
+<option value="3">Basic</option>
+<option value="4">Extended</option>
+</optgroup>
+</select>
+</p>
+
+<table> <!-- 3 -->
+<caption>Some Caption</caption>
+<colgroup><col><col><col></colgroup>
+<thead> <!-- 4 -->
+<tr><th>Header #1</th><th>Header #2</th><th>Header #3</th></tr>
+</thead><tbody>
+<tr><td>Column #1</td><td>Column #2</td><td>Column #3</td></tr>
+<tr><td>Column #1</td><td>Column #2</td><td>Column #3</td></tr>
+<tr><td>Column #1</td><td>Column #2</td><td>Column #3</td></tr>
+<tr><td>Column #1</td><td>Column #2</td><td>Column #3</td></tr>
+</tbody></table>
+
+<div class="block"> <!-- 3 -->
+<blockquote><pre><code> <!-- 6 -->
+<div class="block">
+<blockquote><pre><code>
+</code></pre></blockquote></div>
+</code></pre></blockquote></div>
+
+<p>Paragraph #3.</p><p>Paragraph #4.</p><p>Paragraph #5.</p>
+
+<p>Paragraph #6.</p><p>Paragraph #7.</p><p>Paragraph #8.</p><p>Paragraph #9.</p>
+
+<p id="></p>">Paragraph #10. <!-- 3 FIXME -->
+</p>
+
+<p >Paragraph #11.</p><p id="p"
+class="p">Paragraph #12.</p><p
+class="p">Paragraph #13.</p><p
+>Paragraph #14.</p>
+
+<p>Paragraph #15. <!-- UNBALANCED! -->
+<p>Paragraph #16. <!-- UNBALANCED! -->
+</BoDy>
+</HTML>
diff --git a/runtime/syntax/testdir/input/setup/html_fold_expr.vim b/runtime/syntax/testdir/input/setup/html_fold_expr.vim
new file mode 100644
index 0000000..e8daae0
--- /dev/null
+++ b/runtime/syntax/testdir/input/setup/html_fold_expr.vim
@@ -0,0 +1,2 @@
+let g:html_expr_folding = 1
+filetype plugin on