Translation - Μετάφραση

Resources, Technical Assistance and Technology News => Translator resources => Tips on Using Computers => Topic started by: spiros on 03 Oct, 2019, 16:10:45

Title: Fix invalid self-closed HTML tags
Post by: spiros on 03 Oct, 2019, 16:10:45
Fix invalid self-closed HTML tags

Mediawiki category: Pages using invalid self-closed HTML tags (this is created automatically). Fix with this regex:

// Find every tag that isn't the first set of key words and starts with a set of letters. Capture the tag name and attribute
Code: [Select]
<(?!area|base|br|col|command|embed|hr|img|input|keygen|link|meta|param|source|track|wbr)([a-z|A-Z|_|\-|:|0-9]+)([^>]*)/>
// Create a new tag using the original tag name (i.e. the first capture group of ([a-z|A-Z]*))
// Then add the attributes (i.e. second capture group of (.*))
// Then create a close tag using the first capture group
Code: [Select]
<$1$2></$1>
https://www.reddit.com/r/regex/comments/6mpc7b/replace_invalid_selfclosing_nonvoid_html_tags/