From 14a0499b56789f279baf1dda7b97091a46e1e4e4 Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Wed, 27 Jul 2016 16:52:36 +0100 Subject: [PATCH] allow HumanReadableLogs to rewrite messages with regex also allow an explicit hintId for each rule --- .../ide/human-readable-logs/HumanReadableLogs.coffee | 7 ++++++- .../ide/human-readable-logs/HumanReadableLogsRules.coffee | 7 +++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/services/web/public/coffee/ide/human-readable-logs/HumanReadableLogs.coffee b/services/web/public/coffee/ide/human-readable-logs/HumanReadableLogs.coffee index ae9c3c1e4f..e59e35a40c 100644 --- a/services/web/public/coffee/ide/human-readable-logs/HumanReadableLogs.coffee +++ b/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? diff --git a/services/web/public/coffee/ide/human-readable-logs/HumanReadableLogsRules.coffee b/services/web/public/coffee/ide/human-readable-logs/HumanReadableLogsRules.coffee index f123515deb..021ff5d284 100644 --- a/services/web/public/coffee/ide/human-readable-logs/HumanReadableLogsRules.coffee +++ b/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{...} + """ ]