Aucune description

1234567891011121314151617181920212223242526
  1. (function() {
  2. var EscapeStore = require('./escape-store');
  3. var QuoteScanner = require('./quote-scanner');
  4. var Free = function Free() {
  5. this.matches = new EscapeStore('FREE_TEXT');
  6. };
  7. // Strip content tags by replacing them by the a special
  8. // marker for further restoring. It's done via string scanning
  9. // instead of regexps to speed up the process.
  10. Free.prototype.escape = function(data) {
  11. var self = this;
  12. return new QuoteScanner(data).each(function(match, store) {
  13. var placeholder = self.matches.store(match);
  14. store.push(placeholder);
  15. });
  16. };
  17. Free.prototype.restore = function(data) {
  18. return data.replace(this.matches.placeholderRegExp, this.matches.restore);
  19. };
  20. module.exports = Free;
  21. })();