To convert the unformatted HTML code into easily readable text with syntax highlighting, you can use a JS library called PrismJS. Here are the steps to achieve this:
npm install prismjs --save
import Prism from 'prismjs';
import 'prismjs/components/prism-json';
monaco.editor.create(document.getElementById('container'), {
value: Prism.highlight(
JSON.stringify({html: '<div>Hello, World!</div>'}),
Prism.languages.json,
'json'
),
language: 'json'
})
This will highlight the syntax of your HTML code within the JSON language and make it more readable.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2022-09-17 11:00:00 +0000
Seen: 10 times
Last updated: Aug 24 '22