{"size": 560, "ext": "js", "max_stars_repo_path": "src/asciidoctor-microtypography-french.js", "max_stars_repo_name": "P45QU10U/nodebook", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/asciidoctor-microtypography-french.js", "max_issues_repo_name": "P45QU10U/nodebook", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/asciidoctor-microtypography-french.js", "max_forks_repo_name": "P45QU10U/nodebook", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 22.4, "max_line_length": 66, "alphanum_fraction": 0.55}
'use strict';

const REGEX = /(\u00AB|\u2014)(?:\s+)|(?:\s+)([?!:;———–\u00BB])/g;

const microtypo = (line) => {
  return REGEX.test(line)
    ? line.replace(REGEX, '$1{nbsp}$2')
    : line;
};

module.exports = function microTypography () {
  this.treeProcessor(function(){
    this.process((doc) => {
      doc.findBy({ context: 'paragraph' }).forEach(block => {
        block.lines = block.lines.map(microtypo);
      });

      doc.findBy({ context: 'list_item' }).forEach(block => {
        block.text = microtypo(block.text);
      });
    });
  });

};
