Skip to content

Issue with cyrillic headers #604

Closed
Closed

Description

@ArmorDarks

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).

Activity

  1. Jayin commented on Jun 18, 2015

    @Jayin

    +1

  2. KostyaTretyak commented on Jul 4, 2015

    @KostyaTretyak
    Contributor

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

    # Заголовок {#some-hash-link}
    
  3. scsmash3r commented on Nov 7, 2015

    @scsmash3r

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

  4. KostyaTretyak commented on Nov 7, 2015

    @KostyaTretyak
    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 + '>';
      };
  5. ArmorDarks commented on Nov 8, 2015

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

  6. joshbruce commented on Dec 25, 2017

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