lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

I currently have the need to strip HTML tags from a given Lua string,
ideally allowing a specific subset (such as <p>, <b>, etc.).  There
are a number of implementations of this, a PHP version in particular:

Does anyone have something like this in Lua, or some example LPEG code
for a specific tag that I could use?  A naive solution is relatively
simple using patterns matching, but I'd like to be able to handle odd
cases like this:

<a href="blah" onClick="<script src='foo'></script>">Link</a>

I'd like to avoid stripping the <script> tag in this case, since it
occurs as an attribute of another tag.

Here's hoping someone's had this need before ;-)

- Jim