Skip to content

Instantly share code, notes, and snippets.

@kaisugi
Created January 9, 2019 08:14
Show Gist options
  • Save kaisugi/b28c164d68c9528e96dcfc61adec8730 to your computer and use it in GitHub Desktop.
Save kaisugi/b28c164d68c9528e96dcfc61adec8730 to your computer and use it in GitHub Desktop.
check &gt, &lt in Markdown Codeblock
const fs = require('fs');
const path = require('path');
function search_gt_lt(tmp_path) {
fs.readdir(tmp_path, (err, files) => {
if (err) throw err;
files.forEach(file => {
const next_path = path.join(tmp_path, file);
fs.stat(next_path, (err, stats) => {
if (err) throw err;
if (stats.isDirectory()) {
search_gt_lt(next_path);
} else {
if (file.match(/\.md$/)) {
const data = fs.readFileSync(next_path, 'utf8');
const found_gt = data.match(/```[^>]*&gt[^<]*```/);
const found_lt = data.match(/```[^>]*&lt[^<]*```/);
if (found_gt) {
console.log(file);
console.log(found_gt[0]);
}
if (found_lt) {
console.log(file);
console.log(found_lt[0]);
}
}
}
})
})
})
}
search_gt_lt('.');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment