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
XML
text works perfectly however forJSON-LD
all the text are displayed withred font-color
. I am not understanding why allkey/values
are displayed in the same color. Is it actually highlighting the contents? Is this default behavior forCodeMirror application/ld+json
contents? -
I have added the
linting
option for theJSON-LD
textarea. If there is any syntax error then it will be highlighted and anX arrow
with a message will be displayed against that error to provide more information. However, if there is anySyntax error
inXML
contents then they are just highlighted inred font
but it does not show theX
arrow 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-LD
text and paste it in theJSON-LD
textarea, 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/brackets
from theJSON-LD
content provided inissue-1 above
, we can see that the respective line is highlighted and displayed withX symbol
to provide more information. Now copy theXML
contents intoXML Area
and remove one character to make theXML
syntactically invalid, we can see that contents are highlighted inred
but 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.