1. @codemirror/lang-html
HTML language support for the CodeMirror code editor
@codemirror/lang-html
Package: @codemirror/lang-html
Created by: codemirror
Last modified: Fri, 12 Apr 2024 07:44:04 GMT
Version: 6.4.9
License: MIT
Downloads: 1,408,330
Repository: https://github.com/codemirror/lang-html

Install

npm install @codemirror/lang-html
yarn add @codemirror/lang-html

@codemirror/lang-html NPM version

[ WEBSITE | ISSUES | FORUM | CHANGELOG ]

This package implements HTML language support for the
CodeMirror code editor.

The project page has more information, a
number of examples and the
documentation.

This code is released under an
MIT license.

We aim to be an inclusive, welcoming community. To make that explicit,
we have a code of
conduct
that applies
to communication around the project.

API Reference

html(config⁠?: {selfClosingTags⁠?: boolean} = {}) → LanguageSupport

Language support for HTML, including htmlCompletion and JavaScript and CSS support extensions.

config
matchClosingTags⁠?: boolean

By default, the syntax tree will highlight mismatched closing tags. Set this to false to turn that off (for example when you expect to only be parsing a fragment of HTML text, not a full document).

autoCloseTags⁠?: boolean

Determines whether autoCloseTags is included in the support extensions. Defaults to true.

extraTags⁠?: Record<string, TagSpec>

Add additional tags that can be completed.

extraGlobalAttributes⁠?: Record<string, readonly string[] | null>

Add additional completable attributes to all tags.

nestedLanguages⁠?: {tag: string, attrs⁠?: fn(attrsObject<string>) → boolean, parser: Parser}[]

Register additional languages to parse the content of specific tags. If given, attrs should be a function that, given an object representing the tag's attributes, returns true if this language applies.

nestedAttributes⁠?: {name: string, tagName⁠?: string, parser: Parser}[]

Register additional languages to parse attribute values with.

htmlLanguage: LRLanguage

A language provider based on the Lezer HTML parser, extended with the JavaScript and CSS parsers to parse the content of <script> and <style> tags.

htmlCompletionSource(contextCompletionContext) → CompletionResult | null

HTML tag completion. Opens and closes tags and attributes in a context-aware way.

interface TagSpec

Type used to specify tags to complete.

attrs⁠?: Record<string, readonly string[] | null>

Define tag-specific attributes. Property names are attribute names, and property values can be null to indicate free-form attributes, or a list of strings for suggested attribute values.

globalAttrs⁠?: boolean

When set to false, don't complete global attributes on this tag.

children⁠?: readonly string[]

Can be used to specify a list of child tags that are valid inside this tag. The default is to allow any tag.

htmlCompletionSourceWith(configObject) → fn(contextCompletionContext) → CompletionResult | null

Create a completion source for HTML extended with additional tags or attributes.

config
extraTags⁠?: Record<string, TagSpec>

Define extra tag names to complete.

extraGlobalAttributes⁠?: Record<string, readonly string[] | null>

Add global attributes that are available on all tags.

autoCloseTags: Extension

Extension that will automatically insert close tags when a > or / is typed.

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin