Browse Source

Simplified replacer

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

11
lib/rules_core/replacements.js

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

Loading…
Cancel
Save