|
import { power_user } from './power-user.js'; |
|
import { substituteParams } from '../script.js'; |
|
|
|
|
|
|
|
|
|
|
|
export const markdownExclusionExt = () => { |
|
if (!power_user) { |
|
console.log('Showdown-dinkus extension: power_user wasn\'t found! Returning.'); |
|
return []; |
|
} |
|
|
|
|
|
|
|
if (!power_user.markdown_escape_strings) { |
|
return []; |
|
} |
|
|
|
|
|
|
|
return [{ |
|
type: 'lang', |
|
filter: (text) => { |
|
const escapedExclusions = substituteParams(power_user.markdown_escape_strings) |
|
.split(',') |
|
.filter((element) => element.length > 0) |
|
.map((element) => `(${element.split('').map((char) => `\\${char}`).join('')})`); |
|
|
|
|
|
if (escapedExclusions.length === 0) { |
|
return text; |
|
} |
|
|
|
const replaceRegex = new RegExp(`^(${escapedExclusions.join('|')})\n`, 'gm'); |
|
return text.replace(replaceRegex, ((match) => match.replace(replaceRegex, `\u0000${match} \n`))); |
|
}, |
|
}]; |
|
}; |
|
|