Просмотр исходного кода

allow HumanReadableLogs to rewrite messages with regex

also allow an explicit hintId for each rule
Brian Gough 10 лет назад
Родитель
Сommit
14a0499b56

+ 6 - 1
services/web/public/coffee/ide/human-readable-logs/HumanReadableLogs.coffee

@@ -15,7 +15,12 @@ define [
 			ruleDetails = _getRule entry.message
 
 			if (ruleDetails?)
-				entry.ruleId = 'hint_' + ruleDetails.regexToMatch.toString().replace(/\s/g, '_').slice(1, -1) if ruleDetails.regexToMatch?
+				if ruleDetails.ruleId?
+					entry.ruleId = ruleDetails.ruleId
+				else if ruleDetails.regexToMatch?
+					entry.ruleId = 'hint_' + ruleDetails.regexToMatch.toString().replace(/\s/g, '_').slice(1, -1)
+				if ruleDetails.newMessage?
+					entry.message = entry.message.replace ruleDetails.regexToMatch, ruleDetails.newMessage
 				
 				entry.humanReadableHint = ruleDetails.humanReadableHint if ruleDetails.humanReadableHint?
 				entry.extraInfoURL = ruleDetails.extraInfoURL if ruleDetails.extraInfoURL?

+ 7 - 0
services/web/public/coffee/ide/human-readable-logs/HumanReadableLogsRules.coffee

@@ -88,4 +88,11 @@ define -> [
 		humanReadableHint: """
 			You have used a font command which is only available in math mode. To use this command, you must be in maths mode (E.g. $ \u2026 $ or \\begin{math} \u2026 \\end{math}). If you want to use it outside of math mode, use the text version instead: \\textrm, \\textit, etc.
 		"""
+	,
+		ruleId: "hint_mismatched_environment"
+		regexToMatch: /Error: `([^']{2,})' expected, found `([^']{2,})'.*/
+		newMessage: "Error: environment does not match \\begin{$1} ... \\end{$2}"
+		humanReadableHint: """
+			You have used \\begin{...} without a corresponding \\end{...}
+		"""
 ]