kaelri / enigma

A featured "suite" for the Windows system monitoring application, Rainmeter.
https://www.kaelri.com/project/enigma/
269 stars 93 forks source link

Style Tags Showing Up #112

Closed Jaabi closed 5 years ago

Jaabi commented 5 years ago

Please ignore this issue. I just noticed I do not have the latest version of the skin, and I am thoroughly embarrassed.

I apologize for any time wasted.

Jaabi commented 5 years ago

I have some code that fixes it, but I do not know if I have the permission to push it as I am new to collaborating on non-academic GitHub projects. I made all changes in the Reader/Measures/Reader.lua file, and the changes took no more than 30 minutes (because this is the first time I ever programmed with Lua).

I also wrote some code to add the apostrophe back in instead of the ' HTML equivalent, as can be seen in the image in the third-to-last title and the second-to-last title.

Anyway, here are the code snippets if y'all want them.

. . .
-- MATCH RAW DATA
Item.Unread = 1
Item.Title  = RawItem:match('<title.->(.-)</title>') or nil

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- My contribution since having <b>...</b> in the title is annoying
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Item.Title  = RemoveStyleTags(Item.Title)            or nil
Item.Title  = AddApostrophe(Item.Title)              or nil

Item.Link   = RawItem:match(Type.MatchItemLink)      or nil
Item.Desc   = RawItem:match(Type.MatchItemDesc)      or nil
. . .

The following snippet I put directly after the Input function, if that matters.

. . .
end

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- My contribution since having <b>...</b> in the feed is annoying
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

-----------------------------------------------------------------------
-- INPUT Helper Functions

-----------------------------------------------------------------------
-- REMOVE STYLE TAGS

function RemoveStyleTags(a)
    assert(type(a) == "string" or type(a) == "nil", "RemoveStyleTags(a) expects 'a' to be a string or nil")

    -- If we have a nil, return it
    if a == nil then
        return nil
    end

    -- Else, we have a string, so remove all style tags
    local StyleTags = {"i", "b"} -- Update as you see more style tags

    for i, s in ipairs(StyleTags) do
        local OpenTag = "<" .. s .. ">"
        local CloseTag = "</" .. s .. ">"

        -- Remove all of this one tag
        a = string.gsub(a, OpenTag, "")
        a = string.gsub(a, CloseTag, "")
    end

    return a
end

-----------------------------------------------------------------------
-- ADDAPOSTROPHE
function AddApostrophe(a)
    assert(type(a) == "string" or type(a) == "nil", "RemoveStyleTags(a) expects 'a' to be a string or nil")

    -- If we have a nil, return it
    if a == nil then
        return nil
    end

    a = string.gsub(a, "&#39;", "'")

    return a
end

-- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- End of my contribution. Have a good one!
-- -- -- -- -- -- -- -- -- -- -- -- -- -- --

-----------------------------------------------------------------------
-- OUTPUT
. . .

And here's the end result.

styletags_2