Comments (11)
.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.
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.
Since we migrated our project to microbundle, there are 3 flavours of production ready files built in the dist folder:
dist/markdownItAnchor.js
, specified asmain
inpackage.json
. This is the default, CJS compatible format. It can be used asvar md = require('markdown-it-anchor')
. It can be tested at https://npm.runkit.com/markdown-it-anchordist/markdownItAnchor.mjs
, specified asmodule
inpackage.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 usingimport markdownItAnchor from markdown-it-anchor
you are using ES6 syntax, that command is equivalent toconst markdownItAnchor = require('markdown-it-anchor').default
.dist/markdownItAnchor.umd.js
, specified asunpkg
inpackage.json
. This version is made for the browser. It exposes the library aswindow.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.
Could you please test, if it works with:
.use(require('markdown-it-anchor').default)
from markdown-it-anchor.
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.
.use(require('markdown-it-anchor').default)
I do not understand where to insert this code.
from markdown-it-anchor.
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.
The workaround does not work for me. Either for markdown-it-anchor
or for markdown-it-toc-done-right
.
from markdown-it-anchor.
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.
still doesn't work with nuxt @nuxtjs/markdownit
module.
from markdown-it-anchor.
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)
- Add container around heading and anchor HOT 3
- Expose custom options regardless of permalink styles HOT 4
- Headings containing a hashtag yield invalid hrefs HOT 2
- Headers in html_block Tokens aren't given slugs HOT 11
- Add <span> inside permalink.headerLink style until safari reader more is fixed HOT 1
- incorrect type for permalink.headerLink() HOT 2
- Feature request: container option for linkAfterHeader HOT 5
- KaTeX Expressions aren't Included in Headings HOT 4
- Should return type for `PermalinkGenerator` be `void` instead of `string`? HOT 1
- Missing `wrapper` property in `LinkAfterHeaderPermalinkOptions` type HOT 1
- Add brief description of what plugin does to top of readme. HOT 1
- Types invalid with `"type": "module"` and `"moduleResolution": "Node16"` HOT 7
- @types in peerDeps HOT 2
- TypeError: c.attrGet is not a function HOT 1
- Missing #todo-anchor-or-file header in README HOT 1
- Exception 'plugin.apply is not a function' HOT 2
- Colon in header doesn't work HOT 6
- Upgrade markdown-it types to v14 HOT 1
- more icons for "symbol" HOT 3
- Query: How do I attach a class to the header element? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from markdown-it-anchor.