Skip to content
This repository has been archived by the owner on Feb 2, 2019. It is now read-only.

Commit

Permalink
Regexps to filter out jumbled forum formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
robflop committed Jun 1, 2018
1 parent fde44f1 commit ed35d64
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 39 deletions.
35 changes: 2 additions & 33 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
{
"extends": [
"eslint:recommended",
"plugin:vue/recommended"
],
"plugins": [
"vue"
"eslint:recommended"
],
"parserOptions": {
"ecmaVersion": 2017
Expand Down Expand Up @@ -144,33 +140,6 @@
"prefer-template": "error",
"rest-spread-spacing": "error",
"template-curly-spacing": "error",
"yield-star-spacing": "error",

"vue/html-closing-bracket-newline": ["error", {
"multiline": "always"
}],
"vue/html-indent": ["error", "tab", {
"attribute": 1,
"closeBracket": 0,
"alignAttributesVertically": true,
"ignores": []
}],
"vue/max-attributes-per-line": ["error", {
"singleline": 5,
"multiline": {
"max": 1,
"allowFirstLine": false
}
}],
"vue/html-self-closing": ["error", {
"html": {
"void": "always",
"normal": "never",
"component": "never"
},
"svg": "always",
"math": "always"
}],
"vue/require-default-prop": ["off"]
"yield-star-spacing": "error"
}
}
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ToL-Mod-Utility",
"version": "1.8.2",
"version": "1.9.0",
"productName": "ToL-Mod-Utility",
"description": "Moderation utility for Throne of Lies player reports.",
"main": "./src/client",
Expand All @@ -10,10 +10,8 @@
"electron-packager": "^12.1.0",
"electron-winstaller": "^2.6.4",
"eslint": "^4.19.1",
"eslint-plugin-vue": "^4.5.0",
"htmlhint": "^0.9.13",
"vue-devtools": "^3.1.9",
"vue-eslint-parser": "^2.0.3"
"vue-devtools": "^3.1.9"
},
"scripts": {
"test": "eslint src && htmlhint",
Expand Down
16 changes: 14 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,20 @@ const app = new Vue({
player.lastJournalLeft = player.lastJournalLeft.split('\n').filter(line => line).map(line => line.trim());
player.lastJournalRight = player.lastJournalRight.split('\n').filter(line => line).map(line => line.trim());
});
this.parsedChatLogs = this.chatLogsInput.split('[,]').filter(line => line).map(line => line.trim());
// parse chatlogs (character sequence is line seperator) and assign it as base chatlogs "backup" to work with
this.parsedChatLogs = this.chatLogsInput.split('[,]').filter(line => line)
// character sequence in above split is line seperator, filter used to remove empty
.map(line => {
const colorTagStartRegex = /\[color=#[a-fA-F0-9]{6}\]\s?/;
const colorTagEndRegex = /\s?\[\/color]/;
const formattingTagRegex = /<\/?[bius]>/gm;

if (colorTagStartRegex.test(line)) line.match(colorTagStartRegex).forEach(match => line = line.replace(match, ''));
if (colorTagEndRegex.test(line)) line.match(colorTagEndRegex).forEach(match => line = line.replace(match, ''));
// check log lines for color tags like "[color=#fffff]" and "[/color]", then remove them if found
if (formattingTagRegex.test(line)) line.match(formattingTagRegex).forEach(match => line = line.replace(match, ''));
// check lines for formatting tags like "<i>..</i>" etc and remove them
return line.trim();
});
this.savedChatLogs = this.parsedChatLogs;
this.days = this.savedChatLogs.filter(line => /\(Day\) Day \d+/.test(line)).length;
this.nights = this.savedChatLogs.filter(line => /\(Day\) Night \d+/.test(line)).length;
Expand Down

0 comments on commit ed35d64

Please sign in to comment.