Giter VIP home page Giter VIP logo

Comments (11)

nagaozen avatar nagaozen commented on September 24, 2024 2

.use(require('markdown-it-anchor').default)

I do not understand where to insert this code.

When using markdown-it-anchor, usually you are importing the packages either with import ... or require(...). We've encountered a bug before when babel was transpiling the code into something else and started using exports.default instead of the Node.js exports, so loading the package as require('markdown-it-anchor').default should fix the problem.

Just another note: In the past, this package required babel transpilation due to modern ES6+ features used in the source code, but with the latest versions it's not required anymore, just require as a ES5 dependency as shown here https://npm.runkit.com/markdown-it-toc-done-right.

from markdown-it-anchor.

manastalukdar avatar manastalukdar commented on September 24, 2024 2

Fixed by including packages using the import statement:

import markdownItAnchor from 'markdown-it-anchor'
import markdownItTocDoneRight from 'markdown-it-toc-done-right'

const md = require('markdown-it')
    .use(markdownItAnchor, {
        permalink: true,
        permalinkBefore: true,
        permalinkSymbol: '' // §
      })
    .use(markdownItTocDoneRight)

from markdown-it-anchor.

nagaozen avatar nagaozen commented on September 24, 2024 2

Since we migrated our project to microbundle, there are 3 flavours of production ready files built in the dist folder:

  • dist/markdownItAnchor.js, specified as main in package.json. This is the default, CJS compatible format. It can be used as var md = require('markdown-it-anchor'). It can be tested at https://npm.runkit.com/markdown-it-anchor
  • dist/markdownItAnchor.mjs, specified as module in package.json. This version is made for modern ES6 environments. Its made to make many modern optimized builds possible, like using tree-shaking. You have to use/configure your bundler for this to work. In case you don't have a deep knowledge about your stack, its easy to find out by experimentation: if you are using import markdownItAnchor from markdown-it-anchor you are using ES6 syntax, that command is equivalent to const markdownItAnchor = require('markdown-it-anchor').default.
  • dist/markdownItAnchor.umd.js, specified as unpkg in package.json. This version is made for the browser. It exposes the library as window.markdownItAnchor.

There are no breaking changes, in the version 5.x.x since the exactly same version of runkit.js is still working fine. Errors shown are usually downstream or problems with configuration.

from markdown-it-anchor.

nagaozen avatar nagaozen commented on September 24, 2024 1

Could you please test, if it works with:

.use(require('markdown-it-anchor').default)

from markdown-it-anchor.

nagaozen avatar nagaozen commented on September 24, 2024

This error seems to be reported before (#54) and is related to (#12). If the above suggestion works, we should search for a fix like

from markdown-it-anchor.

khusamov avatar khusamov commented on September 24, 2024

.use(require('markdown-it-anchor').default)

I do not understand where to insert this code.

from markdown-it-anchor.

amxmln avatar amxmln commented on September 24, 2024

I’m affected by this error as well after upgrading to the latest version. I can confirm that the workaround suggested by @nagaozen seems to fix it.

from markdown-it-anchor.

manastalukdar avatar manastalukdar commented on September 24, 2024

The workaround does not work for me. Either for markdown-it-anchor or for markdown-it-toc-done-right.

from markdown-it-anchor.

rivy avatar rivy commented on September 24, 2024

I'm hitting the same problem after v5.1.0.

The workaround does work for v5.2.4.

But if it's not going to be fixed, I think you should deprecate the v5.x.x versions after v5.1.0 and update the semantic version to v6.x.x. At a minimum, I'd note the need at the top of the npmjs documentation for the time being...

Additionally, there are no version tags here after v5.1.0 despite several later released versions on <npmjs.com>. That makes it harder to debug/trace the code for the npmjs version.

from markdown-it-anchor.

axe-me avatar axe-me commented on September 24, 2024

still doesn't work with nuxt @nuxtjs/markdownit module.

from markdown-it-anchor.

inix avatar inix commented on September 24, 2024

Fixed by including packages using the import statement:

import markdownItAnchor from 'markdown-it-anchor'
import markdownItTocDoneRight from 'markdown-it-toc-done-right'

const md = require('markdown-it')
    .use(markdownItAnchor, {
        permalink: true,
        permalinkBefore: true,
        permalinkSymbol: '' // §
      })
    .use(markdownItTocDoneRight)

This fix issue.

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.