<" /> <" /> <"/>

How to format dynamically generated HTML?

47 views Asked by At

I'm generating large dynamically HTML that is saved in some .html file. Now the file looks like this:

<html lang="en">

<head>
    <meta charset="utf-8">
    <style> body {font-family: Helvetica, sans-serif; font-size: 1.5em;} </style>
</head>
<body>
<div><a href="google.com">Hello Google</a><br><ul><li>Some example1</li><li>Some example2</li</ul>...
</div>
</body>

I want to be more human-readable, for example like this:

<html lang="en">

<head>
    <meta charset="utf-8">
    <style>
        body {
            font-family: Helvetica, sans-serif;
            font-size: 1.5em;
        }
    </style>
</head>
<body>
   <div>
       <a href="google.com">Hello Google</a>
       <br>
       <ul>
           <li>Some example 1</li>
           <li>Some example 2</li
       </ul>
   </div>
</body>

I have ClassLibrary project with .NET Standard 2. Any advice how can I achieve this?

I tried to find some NuGet package or some formatting example but I did not succeed. Also I tried this link Dynamically generated HTML in C# to be formatted but wasn't helpful.

0

There are 0 answers