Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

HTML language support for the CodeMirror code editor

License

NotificationsYou must be signed in to change notification settings

codemirror/lang-html

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

[WEBSITE |ISSUES |FORUM |CHANGELOG ]

This package implements HTML language support for theCodeMirror code editor.

Theproject page has more information, anumber ofexamples and thedocumentation.

This code is released under anMIT license.

We aim to be an inclusive, welcoming community. To make that explicit,we have acode ofconduct that appliesto communication around the project.

Usage

import{EditorView,basicSetup}from"codemirror"import{html}from"@codemirror/lang-html"constview=newEditorView({parent:document.body,doc:`<!doctype html>\n<title>HTML</title>`,extensions:[basicSetup,html()]})

API Reference

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

Language support for HTML, includinghtmlCompletion and JavaScript andCSS support extensions.

config
matchClosingTags⁠?:boolean

By default, the syntax tree will highlight mismatched closingtags. Set this tofalse to turn that off (for example when youexpect to only be parsing a fragment of HTML text, not a fulldocument).

selfClosingTags⁠?:boolean

By default, the parser does not allow arbitrary self-closing tags.Set this totrue to turn on support for/> self-closing tagsyntax.

autoCloseTags⁠?:boolean

Determines whetherautoCloseTagsis 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 specifictags. If given,attrs should be a function that, given anobject representing the tag's attributes, returnstrue if thislanguage applies.

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

Register additional languages to parse attribute values with.

htmlLanguage:LRLanguage

A language provider based on theLezer HTMLparser, extended with theJavaScript 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 acontext-aware way.

interfaceTagSpec

Type used to specify tags to complete.

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

Define tag-specific attributes. Property names are attributenames, and property values can be null to indicate free-formattributes, 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 validinside this tag. The default is to allow any tag.

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

Create a completion source for HTML extended with additional tagsor 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.

About

HTML language support for the CodeMirror code editor

Resources

License

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp