I have an Vuejs/Nuxtjs application with 2 textarea. One textarea is dedicated for XML and another for JSON-LD. To highlight the syntax in respective textarea I have integrated CodeMirror into my application and everything so far working correctly.
I have provided Code Sandbox for testing the same: great-browser-gfzdf - CodeSandbox
I am facing the following minor issues with CodeMirror:
-
Highlighting of the
XMLtext works perfectly however forJSON-LDall the text are displayed withred font-color. I am not understanding why allkey/valuesare displayed in the same color. Is it actually highlighting the contents? Is this default behavior forCodeMirror application/ld+jsoncontents? -
I have added the
lintingoption for theJSON-LDtextarea. If there is any syntax error then it will be highlighted and anX arrowwith a message will be displayed against that error to provide more information. However, if there is anySyntax errorinXMLcontents then they are just highlighted inred fontbut it does not show theXarrow against the line and provide more information. How can I achieve the same for theXML area?
Steps to recreate here in CodeSandbox:
- Copy the following
JSON-LDtext and paste it in theJSON-LDtextarea, you can see that all information is displayed in the same color:
{
"@context": "https://json-ld.org/contexts/person.jsonld",
"@id": "http://dbpedia.org/resource/John_Lennon",
"spouse": "http://dbpedia.org/resource/Cynthia_Lennon"
}
- Remove
comma/bracketsfrom theJSON-LDcontent provided inissue-1 above, we can see that the respective line is highlighted and displayed withX symbolto provide more information. Now copy theXMLcontents intoXML Areaand remove one character to make theXMLsyntactically invalid, we can see that contents are highlighted inredbut cannot see any error message against that line
<book id="bk101">
<title>XML Developer's Guide</title>
<genre>Computer</genre>
<price>44.95</price>
</book>
Can someone please help me with this issue? Any help will be really appreciated.
Edited:
I tried the approach mentioned here: javascript - Codemirror Show HTMLLint Errors Inline (.addLineWidget) - Stack Overflow but this is not working as expected for me.