From 1b0e0d7b0d32e7dba30d2691430c7301b02b9f0c Mon Sep 17 00:00:00 2001 From: atom0s Date: Sat, 18 Feb 2017 12:13:33 -0800 Subject: [PATCH] Added auto-translate parsing. Auto-translated items will now be bracketed with { }. Added stripping of double line breaks. Added converting FFXI's custom in-line-breaks to real line-breaks. --- logs.lua | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/logs.lua b/logs.lua index 51a8060..3215f87 100644 --- a/logs.lua +++ b/logs.lua @@ -25,7 +25,7 @@ _addon.author = 'atom0s'; _addon.name = 'Logs'; -_addon.version = '3.0.0'; +_addon.version = '3.0.1'; require 'common' @@ -40,12 +40,35 @@ local timestamp = '[%H:%M:%S]'; -- desc: Cleans a string of auto-translate and color tags. --------------------------------------------------------------------------------------------------- local function clean_str(str) + -- Parse auto-translate tags.. + str = ParseAutoTranslate(str, true); + -- Strip the string of color tags.. str = (str:gsub('[' .. string.char(0x1E, 0x1F, 0x7F) .. '].', '')); -- Strip the string of auto-translate tags.. - str = (str:gsub(string.char(0xEF) .. '[' .. string.char(0x27, 0x28) .. ']', '')); + str = (str:gsub(string.char(0xEF) .. '[' .. string.char(0x27) .. ']', '{')); + str = (str:gsub(string.char(0xEF) .. '[' .. string.char(0x28) .. ']', '}')); + -- Trim linebreaks from end of strings.. + while true do + local hasN = str:endswith('\n'); + local hasR = str:endswith('\r'); + if (hasN or hasR) then + if (hasN) then + str = str:trimend('\n'); + end + if (hasR) then + str = str:trimend('\r'); + end + else + break; + end + end + + -- Convert mid-linebreaks to real linebreaks.. + str = (str:gsub(string.char(0x07), '\n')); + return str; end