How to parse a string with html tags in substrings in bold, italics, underlined

I created some kind of text rendering tool for 2D graphics in C #.

Now I tried to parse text with specific html tags in it, for example:

"Hello <b>world</b>!" 

But the parsing code was getting ugly, and I thought: there must be some kind of lib that does just that. At the end, it should output an array of data structures, for example:

string text;
bool IsBold;
bool IsItalic;
bool IsUnderlined;
...

or

string text;
FontStyle FontStyle;

Does anyone know such a parser?

Thank you so much!

+3
source share
3 answers

HTML Agility Pack is a good HTML parser (and also parses snippets).

XPath ( XmlDocument) - , .

+3

Tidy.net is a fantastic tool that is a port from the original Tidy project, which is used in the Tidy firefox HTML plugin. Run your code through Tidy and it will return a clean, compatible html.

0
source

Source: https://habr.com/ru/post/1773615/


All Articles