mta-wiki-parser
Version:
Wiki to Discord parser for Multi Theft Auto Wiki: https://wiki.multitheftauto.com/
25 lines (24 loc) • 680 B
JavaScript
;
/* Warning Template:
1. text
2. image
*/
// {{Warning|information|use warning image}}
Object.defineProperty(exports, "__esModule", { value: true });
const REGEX = /{{Warning\|(.*?)}}/g;
function parse(input) {
// Parse template
input = input.replace(REGEX, (match, p1) => {
let parsed = '**Warning**: ';
for (const [i, line] of p1.split('|').entries()) {
switch (i + 1) {
case 1:
parsed = line.length > 0 ? `${parsed} ${line}` : parsed;
break;
}
}
return `${parsed}\n`;
});
return input;
}
exports.parse = parse;