How to make Monaco editor show \n or \" in the editor

104 Views Asked by At

I have the following problem, I want Monaco editor to literally show me the characters as I passed them in the value, to show \n and \". But it couldn't, any suggestions?

this is my code

editor_source = monaco.editor.create(document.getElementById('editor_source'), {
    value: "{\n  \"message\": \"¡Hello World!\", \n  \"status\": \"successful\"\n}",
    language: 'plaintext',
    wordWrap: 'on',
    tabSize: 2,
    indentSize: 2,
  })

This is what it looks like in the editor

{
  "message": "¡Hello World!", 
  "status": "successful"
}

monaco-editor

and I want it to show like this

{\n  \"message\": \"¡Hello World!\", \n  \"status\": \"successful\"\n}

thank you very much for your help

0

There are 0 best solutions below