Skip to content

Instantly share code, notes, and snippets.

View AleksCore's full-sized avatar

Aleksey AleksCore

View GitHub Profile
@HoraceBury
HoraceBury / cleanhtml.lua
Created February 14, 2014 13:37
Cleans rich text so that HTML is cleanly removed, p and br tags are reduced to new lines and some special characters are replaced with the text equivelents.
local t = [[ your html ]]
-- list of strings to replace (the order is important to avoid conflicts)
local cleaner = {
{ "&", "&" }, -- decode ampersands
{ "—", "-" }, -- em dash
{ "’", "'" }, -- right single quote
{ "“", "\"" }, -- left double quote
{ "”", "\"" }, -- right double quote
{ "–", "-" }, -- en dash