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 cyrillic headers #604

Closed
ArmorDarks opened this issue Jun 12, 2015 · 6 comments
Closed

Issue with cyrillic headers #604

ArmorDarks opened this issue Jun 12, 2015 · 6 comments

Comments

@ArmorDarks
Copy link

Hi

First of all, thanks for great parser and compiler!

Seems that cyrillic generated ids from markdown headers have some issues.

This

# Заголовок

becomes

<h1 id="-">Заголовок</h1>

while it have to be like this:

<h1 id="заголовок">Заголовок</h1>

I understand that it might sound a bit odd, but it's perfectly fine id. Link like <a href='index.html#заголовок'>link</a> works as expected (tested in Chrome, Mozilla and IE11).

@Jayin
Copy link

Jayin commented Jun 18, 2015

+1

@KostyaTretyak
Copy link
Contributor

+1
It would be good if a link could be made like this

# Заголовок {#some-hash-link}

@scsmash3r
Copy link

I support this too. Will it ever be fixed? Or can there be an option to disable automatic id generation?

@KostyaTretyak
Copy link
Contributor

I fix it, just read README.md

  var renderer = new window.marked.Renderer();

  renderer.heading = function (text, level)
  {
    var patt = /\s?{([^}]+)}$/;
    var link = patt.exec( text );

    if(link && link.length && link[1])
    {
      text = text.replace(patt, '');
      link = link[1];
    }
    else
    {
      link = text.toLowerCase().replace(/[^\wА-яіІїЇєЄ]+/gi, '-');
    }

    return '<h' + level + ' id="' + link + '">' + text + '</h' + level + '>';
  };

@ArmorDarks
Copy link
Author

oh, nice. How did I miss it. Thanks.

I thinks it would be better to use something like urlify, which will convert cyrillic chars to latin ones, instead of replacing them with null or dash.

@joshbruce
Copy link
Member

#981

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

5 participants