UNPKG

leasot

Version:

Parse and output TODOs and FIXMEs from comments in your files

15 lines (14 loc) 788 B
import { getRegex } from '../utils/index.js'; import { extractSingleLineComments, extractSingleLineFromBlocks } from '../utils/comments.js'; const multiLineCommentRegex = /--\[\[(?:[\s\S]*)]]/gim; const parserFactory = ({ customTags }) => { const regex = getRegex(customTags); const lineCommentRegex = new RegExp(`\\s*--${regex}$`, 'mig'); const innerBlockRegex = new RegExp(`^\\s*${regex}\\s*$`, 'mig'); return (contents, file) => { const singleLineComments = extractSingleLineComments(contents, file, lineCommentRegex); const singleLineMultiBlockComments = extractSingleLineFromBlocks(contents, file, multiLineCommentRegex, innerBlockRegex); return singleLineComments.concat(singleLineMultiBlockComments); }; }; export default parserFactory;