From 065378d6a8135a4f6b558378be6553da35564b64 Mon Sep 17 00:00:00 2001 From: Sheogorath Date: Wed, 10 Oct 2018 17:09:02 +0200 Subject: [PATCH] Escape special chars Right now, the copyright sign as well as other special char specifications like `(tm)`, `(r)` and `(p)` are not escapable. This patch adds the ability to escape them, simply by checking for a `\` (Backslash) in front of the first bracket (`\(tm)` or `\(c)`). Maybe not the best way, but works :crossed_fingers: --- lib/rules_core/replacements.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/rules_core/replacements.js b/lib/rules_core/replacements.js index de604ed..a893f63 100644 --- a/lib/rules_core/replacements.js +++ b/lib/rules_core/replacements.js @@ -19,9 +19,9 @@ var RARE_RE = /\+-|\.\.|\?\?\?\?|!!!!|,,|--/; // Workaround for phantomjs - need regex without /g flag, // or root check will fail every second time -var SCOPED_ABBR_TEST_RE = /\((c|tm|r|p)\)/i; +var SCOPED_ABBR_TEST_RE = /(?:^\((c|tm|r|p)\)|[^\\]\((c|tm|r|p)\))/i; -var SCOPED_ABBR_RE = /\((c|tm|r|p)\)/ig; +var SCOPED_ABBR_RE = /(?:^\((c|tm|r|p)\)|[^\\]\((c|tm|r|p)\))/ig; var SCOPED_ABBR = { c: '©', r: '®',