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

Uncaught Error: Unknown language: "undefined" #803

Closed
superbogy opened this issue Sep 3, 2016 · 6 comments
Closed

Uncaught Error: Unknown language: "undefined" #803

superbogy opened this issue Sep 3, 2016 · 6 comments

Comments

@superbogy
Copy link

When i used (```) and don't flow with any program language, it will parse fail and with exception. In my mind, whatever it should not be crash for any type of text. If it is not a markdown syntax,just show it origin.

@joshbruce
Copy link
Member

#983

@Obooman
Copy link

Obooman commented Feb 14, 2018

how to track the issue progress?
can we have a temporary solution, or have to wait for a milestone release?

@joshbruce
Copy link
Member

@Obooman: Thank you for asking. Believe this has actually be resolved as of the latest...but we've done a lot over the last 60 days.

Can you attach a screenshot or code block demonstrating that you're still receiving the error? If so, will reopen.

@Obooman
Copy link

Obooman commented Feb 14, 2018

Thanks, @joshbruce, it's my mistake.I use highlight.js language-determined way to render all code blocks.

Here is a note;

  markedRenderer.code = function (code, language) {
    return '<pre><code class="hljs ' +
      (
        language ?
        language :
        ''
      ) +
      '">' +
      (
        language ?
        hljs.highlight(language, code).value :
        hljs.highlightAuto(code).value
      ) +
      "</code></pre>";
  };

BTW, has hljs class missing be fixed? I'm hacking with it this way.

@joshbruce
Copy link
Member

joshbruce commented Feb 14, 2018

Hmmm...thanks for the follow up.

The example definitely feels like a hacking way of doing it. In theory, according to the GFM spec, you should be able to put the language short name after the fence: https://github.github.com/gfm/#example-111

Renderer.prototype.code = function(code, lang, escaped) {
  if (this.options.highlight) {
    var out = this.options.highlight(code, lang);
    if (out != null && out !== code) {
      escaped = true;
      code = out;
    }
  }

  if (!lang) {
    return '<pre><code>'
      + (escaped ? code : escape(code, true))
      + '\n</code></pre>';
  }

  return '<pre><code class="'
    + this.options.langPrefix
    + escape(lang, true)
    + '">'
    + (escaped ? code : escape(code, true))
    + '\n</code></pre>\n';
};

Believe this is the Marked code that handles it. So, it looks like you should be able to set some options and have this done for you instead of overriding. What is happening when you use just Marked?


What was tried?

What was expected/desired?

What was output?

@joshbruce
Copy link
Member

Tagging in @Feder1co5oave for situational awareness.

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

3 participants