MCPcopy
hub / github.com/victorporof/Sublime-HTMLPrettify / isHTML

Function isHTML

src/js/utils/fileUtils.js:70–92  ·  view source on GitHub ↗
(bufferContents)

Source from the content-addressed store, hash-verified

68};
69
70export const isHTML = (bufferContents) => {
71 const isSavedFile = ORIGINAL_FILE_PATH !== '?';
72 const useEditorFileSyntaxForDeterminingFileType = EDITOR_FILE_SYNTAX !== '?';
73
74 const isAllowedExtension = hasAllowedFileExtension('html', ORIGINAL_FILE_PATH);
75 const isAllowedSyntax = hasAllowedFileSyntax('html', EDITOR_FILE_SYNTAX);
76 const isDisallowedFilePattern = hasDisallowedFilePathPattern('html', ORIGINAL_FILE_PATH);
77 const isMaybeHtml = bufferContents.match(/^\s*</);
78
79 if (!isSavedFile) {
80 return useEditorFileSyntaxForDeterminingFileType
81 ? isAllowedSyntax || isMaybeHtml
82 : isMaybeHtml;
83 }
84
85 if (isDisallowedFilePattern) {
86 return false;
87 }
88
89 return useEditorFileSyntaxForDeterminingFileType
90 ? isAllowedSyntax || isAllowedExtension
91 : isAllowedExtension;
92};
93
94export const isJSON = (bufferContents) => {
95 const isSavedFile = ORIGINAL_FILE_PATH !== '?';

Callers

nothing calls this directly

Calls 3

hasAllowedFileExtensionFunction · 0.85
hasAllowedFileSyntaxFunction · 0.85

Tested by

no test coverage detected