Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with fenced syntax highlighting #28

Closed
jshook opened this issue Jul 29, 2020 · 2 comments
Closed

Issue with fenced syntax highlighting #28

jshook opened this issue Jul 29, 2020 · 2 comments

Comments

@jshook
Copy link

jshook commented Jul 29, 2020

With the highlighting module included, any time there is a fenced block which is not qualified with a language, I would expect highlighting to fall back to being disabled for that block. However, I've started seeing an error like Could not find the language '', did you forget to load/include a language module? which suggest that the matching expression for enabling highlighting on a provided fenced syntax name is matching as an empty string, which triggers the logic for "I have been given a syntax, let me load that language, but I can't find it."

This seems like a new or recent bug. It could be confusion about what class names to match, but the error message doesn't share any of these details to help with diagnosis.

[edit] I suspect the error is in the matching below, but a guard condition on a non-empty string would probably fix it.

   function blockLanguage(block) {
    var match;
    var classes = block.className + ' ';

    classes += block.parentNode ? block.parentNode.className : '';

    // language-* takes precedence over non-prefixed class names.
    match = options.languageDetectRe.exec(classes);
    if (match) {
      var language = getLanguage(match[1]);
      if (!language) {
        console.warn(LANGUAGE_NOT_FOUND.replace("{}", match[1]));
        console.warn("Falling back to no-highlight mode for this block.", block);
      }
      return language ? match[1] : 'no-highlight';
    }

@cyberfly
Copy link

@jshook Hi I have the same problem, did you figure it out? Thanks

@jshook
Copy link
Author

jshook commented Aug 21, 2020

I did not figure it out. Instead for now, I just added qualifiers to all fenced sections, but this is a bit of a nuisance.

@ravenq ravenq closed this as completed in f8b1e7c Oct 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants