interrupt.js 803 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. 'use strict';
  2. module.exports = interrupt;
  3. function interrupt(interruptors, tokenizers, ctx, params) {
  4. var bools = ['pedantic', 'commonmark'];
  5. var count = bools.length;
  6. var length = interruptors.length;
  7. var index = -1;
  8. var interruptor;
  9. var config;
  10. var fn;
  11. var offset;
  12. var bool;
  13. var ignore;
  14. while (++index < length) {
  15. interruptor = interruptors[index];
  16. config = interruptor[1] || {};
  17. fn = interruptor[0];
  18. offset = -1;
  19. ignore = false;
  20. while (++offset < count) {
  21. bool = bools[offset];
  22. if (config[bool] !== undefined && config[bool] !== ctx.options[bool]) {
  23. ignore = true;
  24. break;
  25. }
  26. }
  27. if (ignore) {
  28. continue;
  29. }
  30. if (tokenizers[fn].apply(ctx, params)) {
  31. return true;
  32. }
  33. }
  34. return false;
  35. }