Fix some nasty bug
This commit is contained in:
+27
-27
@@ -35,40 +35,40 @@ const htmlNoMatch = html({ matchClosingTags: false });
|
||||
|
||||
/// Markdown language support.
|
||||
export function markdown(
|
||||
config: {
|
||||
/// When given, this language will be used by default to parse code
|
||||
/// blocks.
|
||||
defaultCodeLanguage?: Language | LanguageSupport;
|
||||
/// A collection of language descriptions to search through for a
|
||||
/// matching language (with
|
||||
/// [`LanguageDescription.matchLanguageName`](#language.LanguageDescription^matchLanguageName))
|
||||
/// when a fenced code block has an info string.
|
||||
codeLanguages?: readonly LanguageDescription[];
|
||||
/// Set this to false to disable installation of the Markdown
|
||||
/// [keymap](#lang-markdown.markdownKeymap).
|
||||
addKeymap?: boolean;
|
||||
/// Markdown parser
|
||||
/// [extensions](https://github.com/lezer-parser/markdown#user-content-markdownextension)
|
||||
/// to add to the parser.
|
||||
extensions?: MarkdownExtension;
|
||||
/// The base language to use. Defaults to
|
||||
/// [`commonmarkLanguage`](#lang-markdown.commonmarkLanguage).
|
||||
base?: Language;
|
||||
} = {}
|
||||
config: {
|
||||
/// When given, this language will be used by default to parse code
|
||||
/// blocks.
|
||||
defaultCodeLanguage?: Language | LanguageSupport;
|
||||
/// A collection of language descriptions to search through for a
|
||||
/// matching language (with
|
||||
/// [`LanguageDescription.matchLanguageName`](#language.LanguageDescription^matchLanguageName))
|
||||
/// when a fenced code block has an info string.
|
||||
codeLanguages?: readonly LanguageDescription[];
|
||||
/// Set this to false to disable installation of the Markdown
|
||||
/// [keymap](#lang-markdown.markdownKeymap).
|
||||
addKeymap?: boolean;
|
||||
/// Markdown parser
|
||||
/// [extensions](https://github.com/lezer-parser/markdown#user-content-markdownextension)
|
||||
/// to add to the parser.
|
||||
extensions?: MarkdownExtension;
|
||||
/// The base language to use. Defaults to
|
||||
/// [`commonmarkLanguage`](#lang-markdown.commonmarkLanguage).
|
||||
base?: Language;
|
||||
} = {}
|
||||
) {
|
||||
let {
|
||||
codeLanguages,
|
||||
defaultCodeLanguage,
|
||||
addKeymap = true,
|
||||
base: {parser} = commonmarkLanguage,
|
||||
base: { parser } = commonmarkLanguage,
|
||||
} = config;
|
||||
if (!(parser instanceof MarkdownParser))
|
||||
throw new RangeError(
|
||||
"Base parser provided to `markdown` should be a Markdown parser"
|
||||
"Base parser provided to `markdown` should be a Markdown parser"
|
||||
);
|
||||
let extensions = config.extensions ? [config.extensions] : [];
|
||||
let support = [htmlNoMatch.support],
|
||||
defaultCode;
|
||||
defaultCode;
|
||||
if (defaultCodeLanguage instanceof LanguageSupport) {
|
||||
support.push(defaultCodeLanguage.support);
|
||||
defaultCode = defaultCodeLanguage.language;
|
||||
@@ -76,11 +76,11 @@ export function markdown(
|
||||
defaultCode = defaultCodeLanguage;
|
||||
}
|
||||
let codeParser =
|
||||
codeLanguages || defaultCode
|
||||
? getCodeParser(codeLanguages || [], defaultCode)
|
||||
: undefined;
|
||||
codeLanguages || defaultCode
|
||||
? getCodeParser(codeLanguages || [], defaultCode)
|
||||
: undefined;
|
||||
extensions.push(
|
||||
parseCode({codeParser, htmlParser: htmlNoMatch.language.parser})
|
||||
parseCode({ codeParser, htmlParser: htmlNoMatch.language.parser })
|
||||
);
|
||||
if (addKeymap) support.push(Prec.high(keymap.of(markdownKeymap)));
|
||||
return new LanguageSupport(mkLang(parser.configure(extensions)), support);
|
||||
|
||||
Reference in New Issue
Block a user