Created
January 9, 2019 08:14
-
-
Save kaisugi/b28c164d68c9528e96dcfc61adec8730 to your computer and use it in GitHub Desktop.
check >, < in Markdown Codeblock
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(/```[^>]*>[^<]*```/); | |
const found_lt = data.match(/```[^>]*<[^<]*```/); | |
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