Generate Valid HTML string
Anonymous User
5952

Given a string of text and HTML formats to be applied to the string, generate a valid HTML string.

text = 'ABCDEFGHIJ'
format = {
	'bold': [(0,4)],
	'italics': [(2,6)]
}

output = '<b>AB<i>CD</i></b><i>EF</i>GHIJ'

Note: You need to close </i> at index 4 and then add it back in order to have valid HTML tags
Comments (18)