lib/parser/micro-template-eslint-parser.js
function settingToRegExpInfo(val, defaultDelimiters) {
    if (!val) {
        return {
            pattern: `${defaultDelimiters[0]}([\\s\\S]*?)${
                defaultDelimiters[1]
            }`,
            getDelimiters: () => defaultDelimiters,
        }
    }
    if (Array.isArray(val)) {
        return {
            pattern: `${escapeRegExp(val[0])}([\\s\\S]*?)${escapeRegExp(
                val[1]
            )}`,
            getDelimiters: () => val,
        }
    }

    const source = val instanceof RegExp ? val.source : `${val}`
    const pattern =
        source.indexOf("([\\s\\S]+?)") >= 0
            ? source.replace("([\\s\\S]+?)", "([\\s\\S]*?)")
            : source.indexOf("([\\S\\s]+?)") >= 0
            ? source.replace("([\\S\\s]+?)", "([\\s\\S]*?)")
            : source

    let getDelimiters = undefined
    const delmPattern = pattern.split("([\\s\\S]*?)")
    if (delmPattern.length === 2) {
        const re = new RegExp(
            delmPattern.map(s => `(${s})`).join("([\\s\\S]*?)"),
            "u"
        )
        getDelimiters = (text, innerCode) => {
            const r = text.match(re)
            if (r) {
                return [r[1], r[3]]
            }
            return getDelimitersFinalMeans(text, innerCode)
        }
    } else {
        getDelimiters = getDelimitersFinalMeans
    }
    return {
        pattern,
        getDelimiters,
    }
}
function settingToRegExpInfo(val, defaultDelimiters) {
    if (!val) {
        return {
            pattern: `${defaultDelimiters[0]}([\\s\\S]*?)${
                defaultDelimiters[1]
            }`,
            getDelimiters: () => defaultDelimiters,
        }
    }
    if (Array.isArray(val)) {
        return {
            pattern: `${escapeRegExp(val[0])}([\\s\\S]*?)${escapeRegExp(
                val[1]
            )}`,
            getDelimiters: () => val,
        }
    }

    const source = val instanceof RegExp ? val.source : `${val}`
    const pattern =
        source.indexOf("([\\s\\S]+?)") >= 0
            ? source.replace("([\\s\\S]+?)", "([\\s\\S]*?)")
            : source.indexOf("([\\S\\s]+?)") >= 0
            ? source.replace("([\\S\\s]+?)", "([\\s\\S]*?)")
            : source

    let getDelimiters = undefined
    const delmPattern = pattern.split("([\\s\\S]*?)")
    if (delmPattern.length === 2) {
        const re = new RegExp(
            delmPattern.map(s => `(${s})`).join("([\\s\\S]*?)"),
            "u"
        )
        getDelimiters = (text, innerCode) => {
            const r = text.match(re)
            if (r) {
                return [r[1], r[3]]
            }
            return getDelimitersFinalMeans(text, innerCode)
        }
    } else {
        getDelimiters = getDelimitersFinalMeans
    }
    return {
        pattern,
        getDelimiters,
    }
}
function settingToRegExpInfo ( val , defaultDelimiters ) { if ( ! val ) { return { pattern : ` ${ defaultDelimiters [ 0 ] } \\ \\ ${ defaultDelimiters [ 1 ] } ` , getDelimiters : ( ) => defaultDelimiters , } } if ( Array . isArray ( val ) ) { return { pattern : ` ${ escapeRegExp ( val [ 0 ] ) } \\ \\ ${ escapeRegExp ( val [ 1 ] ) } ` , getDelimiters : ( ) => val , } } const source = val instanceof RegExp ? val . source : ` ${ val } ` const pattern = source . indexOf ( "([\\s\\S]+?)" ) >= 0 ? source . replace ( "([\\s\\S]+?)" , "([\\s\\S]*?)" ) : source . indexOf ( "([\\S\\s]+?)" ) >= 0 ? source . replace ( "([\\S\\s]+?)" , "([\\s\\S]*?)" ) : source let getDelimiters = undefined const delmPattern = pattern . split ( "([\\s\\S]*?)" ) if ( delmPattern . length === 2 ) { const re = new RegExp ( delmPattern . map ( s => ` ${ s } ` ) . join ( "([\\s\\S]*?)" ) , "u" ) getDelimiters = ( text , innerCode ) => { const r = text . match ( re ) if ( r ) { return [ r [ 1 ] , r [ 3 ] ] } return getDelimitersFinalMeans ( text , innerCode ) } } else { getDelimiters = getDelimitersFinalMeans } return { pattern , getDelimiters , } }
Delimiters setting to RegExp source

@param {*} val The delimiter settings.
@param {Array} defaultDelimiters The default delimiters.
@returns {string} The delimiters RegExp source.
Delimiters setting to RegExp source