Browse Source

Support switching rare and scoped typographer replacements

pull/762/head
Kyle E. Mitchell 4 years ago
parent
commit
9ac5ec778d
  1. 12
      lib/rules_core/replacements.js

12
lib/rules_core/replacements.js

@ -85,21 +85,25 @@ function replace_rare(inlineTokens) {
}
}
module.exports = function replace(state) {
var blkIdx;
var typographerOption = state.md.options.typographer;
if (!typographerOption) { return; }
if (!state.md.options.typographer) { return; }
var optionIsObject = typeof typographerOption === 'object';
var replaceRare = !optionIsObject || typographerOption.rare;
var replaceIP = !optionIsObject || typographerOption.intellectualProperty;
for (blkIdx = state.tokens.length - 1; blkIdx >= 0; blkIdx--) {
if (state.tokens[blkIdx].type !== 'inline') { continue; }
if (SCOPED_ABBR_TEST_RE.test(state.tokens[blkIdx].content)) {
if (replaceIP && SCOPED_ABBR_TEST_RE.test(state.tokens[blkIdx].content)) {
replace_scoped(state.tokens[blkIdx].children);
}
if (RARE_RE.test(state.tokens[blkIdx].content)) {
if (replaceRare && RARE_RE.test(state.tokens[blkIdx].content)) {
replace_rare(state.tokens[blkIdx].children);
}

Loading…
Cancel
Save