diff --git a/src/config.js b/src/config.js index 37731db..a4f3af5 100644 --- a/src/config.js +++ b/src/config.js @@ -1,5 +1,6 @@ const config = { devMode:true, + breeMode: true, recaptcha: "", IP: [ { @@ -23,6 +24,11 @@ if ( config.devMode ) { config.recaptcha = "6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI"; config['domain'] = config.IP[0].domain; config['socketIP'] = config.IP[0].socketIP; + + if( config.breeMode ) { + config['domain'] = config.IP[1].domain; + config['socketIP'] = config.IP[1].socketIP; + } } else { config.recaptcha = "6Ld0EIwUAAAAALJNTa-1s63l-w_jHyCY6dFAVwKe"; config['domain'] = config.IP[1].domain; diff --git a/src/messageFormatter.js b/src/messageFormatter.js index 0f99ecd..6bf619e 100644 --- a/src/messageFormatter.js +++ b/src/messageFormatter.js @@ -41,7 +41,7 @@ export default (message) => { name: 'code-block', symbol: '``\`', recursive: false, - transformer: text => `
${text.trim()}
`, + transformer: text => `
${formatCode(text.trim())}
`, }) futoji.addTransformer({ @@ -53,6 +53,26 @@ export default (message) => { return futoji.format(message); } +/** + * format code to add syntax highlighting + */ +function formatCode(text) { + // matches if word until newline + // if spaces then it won't match + let nameRegex = new RegExp('^(\\w+)\\n') + + if(nameRegex.test(text)) { + let language = nameRegex.exec(text)[1] + let newText = text.replace(nameRegex, '') + + // TODO: format newText with language + + return newText + } + + return text +} + function escapeHtml(unsafe) { return unsafe .replace(/&/g, "&")