Skip to content

Uncaught Error: Unknown language: "undefined" #803

Closed

Description

@superbogy

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.

Activity

  1. joshbruce commented on Dec 25, 2017

    @joshbruce
    Member
  2. Obooman commented on Feb 14, 2018

    @Obooman

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

  3. joshbruce commented on Feb 14, 2018

    @joshbruce
    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.

  4. Obooman commented on Feb 14, 2018

    @Obooman

    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.

  5. joshbruce commented on Feb 14, 2018

    @joshbruce
    Member

    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?

  6. joshbruce commented on Feb 14, 2018

    @joshbruce
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions