fuzzii fuzzii - 1 year ago 198
Javascript Question

Typescript: print string as HTML to the terminal?

I know this seems like a very basic question, but I haven't been able to find the answer.

I'm reading from a local file using typescript. I then want to use console.log to print the file contents to the terminal. However, the file is a HTML file, so I'm wondering if I can render the tags, before printing to the terminal.

My progress so far, has just involved printing the tags to the terminal with the content.

Is it possible to render the HTML elements before the content is printed to the terminal?

Answer Source

You can't render HTML in the browser's console. What you can do is, you can style the output. See this answer for more information.


console.log("%cThis will be formatted with large, blue text", "color: blue; font-size: x-large");

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download