Skip to content
This repository was archived by the owner on Aug 7, 2023. It is now read-only.

Commit a97e49d

Browse files
jakewtaylorArcanemagus
authored andcommitted
Add experimental PHP support (#167)
Add experimental PHP support
1 parent 88b4b13 commit a97e49d

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

lib/index.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,16 @@ export default {
9898
return null;
9999
}
100100

101+
const removePHP = str => str.replace(/<\?(?:php|=)?(?:[\s\S])+?\?>/gi, (match) => {
102+
const newlines = match.match(/\r?\n|\r/g);
103+
const newlineCount = newlines ? newlines.length : 0;
104+
105+
return '\n'.repeat(newlineCount);
106+
});
107+
101108
const fileText = editor.getText();
102-
if (!fileText) {
109+
const fileTextStripped = removePHP(fileText);
110+
if (!fileTextStripped) {
103111
return [];
104112
}
105113

@@ -108,7 +116,7 @@ export default {
108116

109117
const ruleset = await getConfig(filePath);
110118

111-
const messages = HTMLHint.verify(fileText, ruleset || undefined);
119+
const messages = HTMLHint.verify(fileTextStripped, ruleset || undefined);
112120

113121
if (editor.getText() !== fileText) {
114122
// Editor contents have changed, tell Linter not to update

0 commit comments

Comments
 (0)