Browse Source

Simplified replacer

pull/82/head
Vitaly Puzrin 10 years ago
parent
commit
84375344d2
  1. 9
      lib/rules_core/replacements.js

9
lib/rules_core/replacements.js

@ -27,22 +27,17 @@ var SCOPED_ABBR = {
'tm': '™' 'tm': '™'
}; };
function replaceScopedAbbr(str) { function replaceFn(match, name) {
if (str.indexOf('(') < 0) { return str; }
return str.replace(SCOPED_ABBR_RE, function(match, name) {
return SCOPED_ABBR[name.toLowerCase()]; return SCOPED_ABBR[name.toLowerCase()];
});
} }
function replace_scoped(inlineTokens) { function replace_scoped(inlineTokens) {
var i, token; var i, token;
for (i = inlineTokens.length - 1; i >= 0; i--) { for (i = inlineTokens.length - 1; i >= 0; i--) {
token = inlineTokens[i]; token = inlineTokens[i];
if (token.type === 'text') { if (token.type === 'text') {
token.content = replaceScopedAbbr(token.content); token.content = token.content.replace(SCOPED_ABBR_RE, replaceFn);
} }
} }
} }

Loading…
Cancel
Save