New algorithm to insert line when composing in HTML