Skip to content

Commit

Permalink
Export parseCode from markdown *parser*
Browse files Browse the repository at this point in the history
  • Loading branch information
pankgeorg committed Dec 22, 2021
1 parent 46dc4bf commit 0f96685
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 14 deletions.
7 changes: 6 additions & 1 deletion dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4876,6 +4876,11 @@ declare class InlineContext {
elt(tree: Tree, at: number): Element$1;
}

declare function parseCode(config: {
codeParser?: (info: string) => null | Parser;
htmlParser?: Parser;
}): MarkdownExtension;

/**
Language support for [GFM](https://github.github.com/gfm/) plus
subscript, superscript, and emoji syntax.
Expand Down Expand Up @@ -5109,4 +5114,4 @@ Create an instance of the collaborative editing plugin.
*/
declare function collab(config?: CollabConfig): Extension;

export { Annotation, Compartment, Decoration, EditorSelection, EditorState, EditorView, Facet, HighlightStyle, NodeProp, PostgreSQL, SelectionRange, StateEffect, StateField, StreamLanguage, Text, Transaction, TreeCursor, ViewPlugin, ViewUpdate, WidgetType, index as autocomplete, bracketMatching, closeBrackets, closeBracketsKeymap, collab, combineConfig, commentKeymap, completionKeymap, defaultHighlightStyle, defaultKeymap, drawSelection, foldGutter, foldKeymap, highlightSelectionMatches, highlightSpecialChars, history, historyKeymap, html, htmlLanguage, indentLess, indentMore, indentOnInput, indentUnit, javascript, javascriptLanguage, julia as julia_andrey, julia$1 as julia_legacy, keymap, lineNumbers, markdown, markdownLanguage, parseMixed, placeholder, python, pythonLanguage, rectangularSelection, searchKeymap, sql, syntaxTree, tags };
export { Annotation, Compartment, Decoration, EditorSelection, EditorState, EditorView, Facet, HighlightStyle, NodeProp, PostgreSQL, SelectionRange, StateEffect, StateField, StreamLanguage, Text, Transaction, TreeCursor, ViewPlugin, ViewUpdate, WidgetType, index as autocomplete, bracketMatching, closeBrackets, closeBracketsKeymap, collab, combineConfig, commentKeymap, completionKeymap, defaultHighlightStyle, defaultKeymap, drawSelection, foldGutter, foldKeymap, highlightSelectionMatches, highlightSpecialChars, history, historyKeymap, html, htmlLanguage, indentLess, indentMore, indentOnInput, indentUnit, javascript, javascriptLanguage, julia as julia_andrey, julia$1 as julia_legacy, keymap, lineNumbers, markdown, markdownLanguage, parseCode, parseMixed, placeholder, python, pythonLanguage, rectangularSelection, searchKeymap, sql, syntaxTree, tags };
15 changes: 10 additions & 5 deletions dist/index.es.js
Original file line number Diff line number Diff line change
Expand Up @@ -24538,11 +24538,16 @@ function resolveConfig(spec) {
if (!rest || !conf)
return conf || rest;
let conc = (a, b) => (a || none).concat(b || none);
return { props: conc(conf.props, rest.props),
let wrapA = conf.wrap, wrapB = rest.wrap;
return {
props: conc(conf.props, rest.props),
defineNodes: conc(conf.defineNodes, rest.defineNodes),
parseBlock: conc(conf.parseBlock, rest.parseBlock),
parseInline: conc(conf.parseInline, rest.parseInline),
remove: conc(conf.remove, rest.remove) };
remove: conc(conf.remove, rest.remove),
wrap: !wrapA ? wrapB : !wrapB ? wrapA :
(inner, input, fragments, ranges) => wrapA(wrapB(inner, input, fragments, ranges), input, fragments, ranges)
};
}
function findName(names, name) {
let found = names.indexOf(name);
Expand Down Expand Up @@ -25073,11 +25078,11 @@ class FragmentCursor {
return tree && tree.prop(NodeProp.contextHash) == hash;
}
takeNodes(cx) {
let cur = this.cursor, off = this.fragment.offset;
let cur = this.cursor, off = this.fragment.offset, fragEnd = this.fragmentEnd - (this.fragment.openEnd ? 1 : 0);
let start = cx.absoluteLineStart, end = start, blockI = cx.block.children.length;
let prevEnd = end, prevI = blockI;
for (;;) {
if (cur.to - off >= this.fragmentEnd) {
if (cur.to - off > fragEnd) {
if (cur.type.isAnonymous && cur.firstChild())
continue;
break;
Expand Down Expand Up @@ -27911,4 +27916,4 @@ function collab(config = {}) {
return [collabField, collabConfig.of(Object.assign({ generatedID: Math.floor(Math.random() * 1e9).toString(36) }, config))];
}

export { Annotation, Compartment, Decoration, EditorSelection, EditorState, EditorView, Facet, HighlightStyle, NodeProp, PostgreSQL, SelectionRange, StateEffect, StateField, StreamLanguage, Text, Transaction, TreeCursor, ViewPlugin, ViewUpdate, WidgetType, index as autocomplete, bracketMatching, closeBrackets, closeBracketsKeymap, collab, combineConfig, commentKeymap, completionKeymap, defaultHighlightStyle, defaultKeymap, drawSelection, foldGutter, foldKeymap, highlightSelectionMatches, highlightSpecialChars, history, historyKeymap, html, htmlLanguage, indentLess, indentMore, indentOnInput, indentUnit, javascript, javascriptLanguage, julia as julia_andrey, julia$1 as julia_legacy, keymap, lineNumbers, markdown, markdownLanguage, parseMixed, placeholder, python, pythonLanguage, rectangularSelection, searchKeymap, sql, syntaxTree, tags$1 as tags };
export { Annotation, Compartment, Decoration, EditorSelection, EditorState, EditorView, Facet, HighlightStyle, NodeProp, PostgreSQL, SelectionRange, StateEffect, StateField, StreamLanguage, Text, Transaction, TreeCursor, ViewPlugin, ViewUpdate, WidgetType, index as autocomplete, bracketMatching, closeBrackets, closeBracketsKeymap, collab, combineConfig, commentKeymap, completionKeymap, defaultHighlightStyle, defaultKeymap, drawSelection, foldGutter, foldKeymap, highlightSelectionMatches, highlightSpecialChars, history, historyKeymap, html, htmlLanguage, indentLess, indentMore, indentOnInput, indentUnit, javascript, javascriptLanguage, julia as julia_andrey, julia$1 as julia_legacy, keymap, lineNumbers, markdown, markdownLanguage, parseCode, parseMixed, placeholder, python, pythonLanguage, rectangularSelection, searchKeymap, sql, syntaxTree, tags$1 as tags };
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"@codemirror/stream-parser": "^0.19.2",
"@codemirror/view": "^0.19.9",
"@lezer/common": "^0.15.7",
"@lezer/markdown": "^0.15.0",
"@lezer/markdown": "^0.15.3",
"@lezer/python": "^0.15.0",
"esbuild": "^0.12.28",
"lang-julia": "^0.1.0",
Expand Down
2 changes: 2 additions & 0 deletions src/basic-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { completionKeymap } from "@codemirror/autocomplete"
import { commentKeymap } from "@codemirror/comment"
import { TreeCursor, NodeProp, parseMixed } from "@lezer/common"
import { markdown, markdownLanguage } from "@codemirror/lang-markdown"
import { parseCode } from "@lezer/markdown"
import { html, htmlLanguage } from "@codemirror/lang-html"
import { javascript, javascriptLanguage } from "@codemirror/lang-javascript"
import { sql, PostgreSQL } from "@codemirror/lang-sql"
Expand Down Expand Up @@ -86,6 +87,7 @@ export {
// Syntax Highlighting magic
markdown,
markdownLanguage,
parseCode,
parseMixed,
html,
htmlLanguage,
Expand Down

0 comments on commit 0f96685

Please sign in to comment.