Mercurial > vim
changeset 35833:14a3f8b71418 v9.1.0635
patch 9.1.0635: filetype: SuperHTML template files not recognized
Commit: https://github.com/vim/vim/commit/e57c9a19edc906a96ccb8821ae33fa6a8b20c3cd
Author: EliSauder <24995216+EliSauder@users.noreply.github.com>
Date: Sun Jul 28 21:28:11 2024 +0200
patch 9.1.0635: filetype: SuperHTML template files not recognized
Problem: filetype: SuperHTML template files not recognized
Solution: Update the filetype detection code to detect '*.shtml' either
as HTML (Server Side Includes) or SuperHTML (template files)
(EliSauder)
related: #15355
related: #15367
Signed-off-by: EliSauder <24995216+EliSauder@users.noreply.github.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 28 Jul 2024 21:45:02 +0200 |
parents | 5a07017552a9 |
children | 626d10100885 |
files | runtime/autoload/dist/ft.vim runtime/filetype.vim src/testdir/test_filetype.vim src/version.c |
diffstat | 4 files changed, 40 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/runtime/autoload/dist/ft.vim +++ b/runtime/autoload/dist/ft.vim @@ -421,7 +421,6 @@ export def FThtml() setf htmlangular return endif - # Check for XHTML if getline(n) =~ '\<DTD\s\+XHTML\s' setf xhtml @@ -432,6 +431,11 @@ export def FThtml() setf htmldjango return endif + # Check for SuperHTML + if getline(n) =~ '<extend\|<super>' + setf superhtml + return + endif n += 1 endwhile setf FALLBACK html
--- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -1039,7 +1039,7 @@ au BufNewFile,BufRead *.t.html setf ti " Translate shell au BufNewFile,BufRead init.trans,*/etc/translate-shell,.trans setf clojure -" HTML (.shtml and .stm for server side) +" HTML (.stm for server side, .shtml is server-side or superhtml) au BufNewFile,BufRead *.html,*.htm,*.shtml,*.stm call dist#ft#FThtml() au BufNewFile,BufRead *.cshtml setf html
--- a/src/testdir/test_filetype.vim +++ b/src/testdir/test_filetype.vim @@ -1603,6 +1603,38 @@ func Test_html_file() call assert_equal('htmldjango', &filetype) bwipe! + " Super html layout + let content = ['<extend template="base.shtml">', + \ '<title id="title" var="$page.title"></title>', + \ '<head id="head"></head>', + \ '<div id="content">', + \ '</div>'] + call writefile(content, 'Xfile.shtml', 'D') + split Xfile.shtml + call assert_equal('superhtml', &filetype) + bwipe! + + " Super html template + let content = ['<!DOCTYPE html>', + \ '<html>', + \ ' <head id="head">', + \ ' <title id="title">', + \ ' <super>', + \ ' suffix', + \ ' </title>', + \ ' <super>', + \ ' </head>', + \ ' <body>', + \ ' <div id="content">', + \ ' <super>', + \ ' </div>', + \ ' </body>', + \ '</html>'] + call writefile(content, 'Xfile.shtml', 'D') + split Xfile.shtml + call assert_equal('superhtml', &filetype) + bwipe! + " regular HTML let content = ['<!DOCTYPE html>', '<html>', ' <head>Foobar</head>', ' <body>Content', ' </body>', '</html>'] call writefile(content, 'Xfile.html', 'D')