Giter VIP home page Giter VIP logo

Comments (5)

valeriangalliat avatar valeriangalliat commented on September 24, 2024 1

Makes sense, well in this case your slugify function can just be title => title, there's already code that adds -1, -2 at the end of the ID in case an ID was already used.

I might default to this in the next major version, simple and easy, thanks for the suggestion. 👍

from markdown-it-anchor.

airwin avatar airwin commented on September 24, 2024 1

maybe a full solution:
UPDATED: sorry I just saw the uniqueSlug function in the lib, it's allready done. GJ~

var transliteration = require('transliteration')
var markdownItAnchorSlugCache = {}
// and use custom slugify function in markdown-it-anchor config
slugify: function(s) {
  var slug = transliteration.slugify(s, {lowercase: true, separator: '-', ignore: []})
  if (markdownItAnchorSlugCache[slug]) {
    slug += '-' + (markdownItAnchorSlugCache[slug]++)
  } else {
    markdownItAnchorSlugCache[slug] = 1
  }

  return slug
}

from markdown-it-anchor.

valeriangalliat avatar valeriangalliat commented on September 24, 2024

Duplicate of #10; the problem is the ID property is determined with strings.js, which seems to support only western languages.

What slugification module would you advise instead? I might switch from strings.js to something that have better language support it in a next major release (will be a breaking change).

Meanwhile, you can configure your own slugify function (takes the title text as argument, returns the ID), to make it support Chinese.

from markdown-it-anchor.

JimmyVV avatar JimmyVV commented on September 24, 2024

en. maybe you misunderstand my mean. I just want you just to use text and mix with some hash to make sure the id is unique. not to translate Chinese. and I just do as you suggest

from markdown-it-anchor.

nagaozen avatar nagaozen commented on September 24, 2024

Fixed by version 5.0.0.

from markdown-it-anchor.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.