Skip to content

Syntax validation #16

Answered by e-chan1007
lucas-cota asked this question in Q&A
Dec 8, 2022 · 6 comments · 8 replies
Discussion options

You must be logged in to vote

By setting lang prop of <MonacoEditor> to javascript(typescript), css, (or also json), monaco-editor enables syntax checking automatically.

However, HTML couldn't be checked in this way. Using monaco-html-linter is one of the best ways.

<script setup>
import HTMLMonacoLinter from 'monaco-html-linter'
const onEditorLoad = (editor) => {
  const monaco = useMonaco()
  const linter = new HTMLMonacoLinter(editor, monaco)
  linter.watch()
}
</script>

<template>
  <MonacoEditor lang="html" @load="onEditorLoad" />
</template>

If you need to create error markers by yourself, try this with the latest version of nuxt-monaco-editor:

const onEditorLoad = (editor) => {
  const monaco = useMonaco()
  c…

Replies: 6 comments 8 replies

Comment options

You must be logged in to vote
3 replies
@lucas-cota
Comment options

@lucas-cota
Comment options

@e-chan1007
Comment options

Answer selected by e-chan1007
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@e-chan1007
Comment options

Comment options

You must be logged in to vote
1 reply
@lucas-cota
Comment options

Comment options

You must be logged in to vote
2 replies
@e-chan1007
Comment options

@lucas-cota
Comment options

Comment options

You must be logged in to vote
1 reply
@e-chan1007
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #15 on December 09, 2022 16:44.