We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

insertHTML() and non-tags

My application uses insertHtml() with rather unstructured inputs. Users enter fragments that generally can be interpreted as HTML markup, and the app passes the fragments directly into insertHtml(). But sometimes they will also enter strings like “a<b” where the angle bracket is meant to indicate numeric inequality. In cases like this, the application doesn’t ask the user which interpretation he meant.

My understanding of insertHtml() is that it discards any markup that is unsupported, and that’s fine. But it also appears to discard any input that looks like it might be markup, like it might be a tag. In the example above, “a<b” is rendered as “a”. Is there any means by which I can instruct insertHtml() to discard only well-formed markup?


Thank you for your interest in Aspose components.

If we would like to add both plain text and markup in one function then markup recognition should be implemented inside. InsertHTML is sensitive to it. But if we pass here something which contains special characters it is not good to make extra assumptions. It’s a common practice not to do this.

Plain input with angle brackets (“less” and “greater” signs) should be escaped. Character escapement is replacement of particular characters with escape sequences. For these two you have to pass the following:

“greater” -> “>”

“less” -> “<”

You can find the list of characters that need to be escaped in any documentation on HTML. Also you can experiment with an editor saving your input in HTML format. Then you can open it in Notepad and look what happens with the text.


Thanks for the reply. My question was due to my temporary lapse in understanding of HTML standards.