Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@codemirror/lang-markdown

Package Overview
Dependencies
Maintainers
2
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@codemirror/lang-markdown - npm Package Compare versions

Comparing version 6.1.1 to 6.2.0

dist/index.d.cts

6

CHANGELOG.md

@@ -0,1 +1,7 @@

## 6.2.0 (2023-06-23)
### New features
The markdown package now installs a completion source that completes HTML tags when in Markdown context.
## 6.1.1 (2023-04-13)

@@ -2,0 +8,0 @@

@@ -82,4 +82,10 @@ import { KeyBinding } from '@codemirror/view';

base?: Language;
/**
By default, the extension installs an autocompletion source that
completes HTML tags when a `<` is typed. Set this to false to
disable this.
*/
completeHTMLTags?: boolean;
}): LanguageSupport;
export { commonmarkLanguage, deleteMarkupBackward, insertNewlineContinueMarkup, markdown, markdownKeymap, markdownLanguage };

36

dist/index.js

@@ -1,6 +0,7 @@

import { EditorSelection, Prec } from '@codemirror/state';
import { EditorSelection, Prec, EditorState } from '@codemirror/state';
import { keymap } from '@codemirror/view';
import { defineLanguageFacet, foldNodeProp, indentNodeProp, languageDataProp, foldService, syntaxTree, Language, LanguageDescription, ParseContext, LanguageSupport } from '@codemirror/language';
import { CompletionContext } from '@codemirror/autocomplete';
import { parser, GFM, Subscript, Superscript, Emoji, MarkdownParser, parseCode } from '@lezer/markdown';
import { html } from '@codemirror/lang-html';
import { html, htmlCompletionSource } from '@codemirror/lang-html';
import { NodeProp } from '@lezer/common';

@@ -348,3 +349,3 @@

function markdown(config = {}) {
let { codeLanguages, defaultCodeLanguage, addKeymap = true, base: { parser } = commonmarkLanguage } = config;
let { codeLanguages, defaultCodeLanguage, addKeymap = true, base: { parser } = commonmarkLanguage, completeHTMLTags = true } = config;
if (!(parser instanceof MarkdownParser))

@@ -365,5 +366,32 @@ throw new RangeError("Base parser provided to `markdown` should be a Markdown parser");

support.push(Prec.high(keymap.of(markdownKeymap)));
return new LanguageSupport(mkLang(parser.configure(extensions)), support);
let lang = mkLang(parser.configure(extensions));
if (completeHTMLTags)
support.push(lang.data.of({ autocomplete: htmlTagCompletion }));
return new LanguageSupport(lang, support);
}
function htmlTagCompletion(context) {
let { state, pos } = context, m = /<[:\-\.\w\u00b7-\uffff]*$/.exec(state.sliceDoc(pos - 25, pos));
if (!m)
return null;
let tree = syntaxTree(state).resolveInner(pos, -1);
while (tree && !tree.type.isTop) {
if (tree.name == "CodeBlock" || tree.name == "FencedCode" || tree.name == "ProcessingInstructionBlock" ||
tree.name == "CommentBlock" || tree.name == "Link" || tree.name == "Image")
return null;
tree = tree.parent;
}
return {
from: pos - m[0].length, to: pos,
options: htmlTagCompletions(),
validFor: /^<[:\-\.\w\u00b7-\uffff]*$/
};
}
let _tagCompletions = null;
function htmlTagCompletions() {
if (_tagCompletions)
return _tagCompletions;
let result = htmlCompletionSource(new CompletionContext(EditorState.create({ extensions: htmlNoMatch }), 0, true));
return _tagCompletions = result ? result.options : [];
}
export { commonmarkLanguage, deleteMarkupBackward, insertNewlineContinueMarkup, markdown, markdownKeymap, markdownLanguage };

5

package.json
{
"name": "@codemirror/lang-markdown",
"version": "6.1.1",
"version": "6.2.0",
"description": "Markdown language support for the CodeMirror code editor",

@@ -29,2 +29,3 @@ "scripts": {

"dependencies": {
"@codemirror/autocomplete": "^6.7.1",
"@codemirror/lang-html": "^6.0.0",

@@ -38,3 +39,3 @@ "@codemirror/language": "^6.3.0",

"devDependencies": {
"@codemirror/buildhelper": "^0.1.5"
"@codemirror/buildhelper": "^1.0.0"
},

@@ -41,0 +42,0 @@ "repository": {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc