Closed alinex closed 8 years ago
i'll look into this tomorrow. can you provide example code, so i can reproduce the issue easily ? thanks
I can give you an example this evening.
Now I made a short example in coffeescript:
# markdown
markdown = require 'markdown-it'
mdAbbr = require 'markdown-it-abbr'
mdFootnote = require 'markdown-it-footnote'
mdToc = require 'markdown-it-toc-and-anchor'
# setup markdown it
md = markdown()
.use mdAbbr # abbreviations (auto added)
.use mdFootnote # footnotes (auto linked)
.use mdToc.default, # possibility to add TOC
tocClassName: 'table-of-contents'
tocFirstLevel: 2
anchorLink: false
data = {}
content = "Put markdown here..."
html = md.render content, data
console.log html
And translated to javascript:
var content, data, html, markdown, md, mdAbbr, mdFootnote, mdToc;
markdown = require('markdown-it');
mdAbbr = require('markdown-it-abbr');
mdFootnote = require('markdown-it-footnote');
mdToc = require('markdown-it-toc-and-anchor');
md = markdown().use(mdAbbr).use(mdFootnote).use(mdToc["default"], {
tocClassName: 'table-of-contents',
tocFirstLevel: 2,
anchorLink: false
});
data = {};
content = "Put markdown here...";
html = md.render(content, data);
console.log(html);
If I run this with the newest version i get:
$ npm install markdown-it-toc-and-anchor@4.1.0
$ coffee src/test.coffee
TypeError: Cannot read property 'footnotes' of undefined
at Array.footnote_tail (/home/alex/github/node-report/node_modules/markdown-it-footnote/index.js:246:19)
at Core.process (/home/alex/github/node-report/node_modules/markdown-it/lib/parser_core.js:51:13)
at MarkdownIt.parse (/home/alex/github/node-report/node_modules/markdown-it/lib/index.js:519:13)
at Array.<anonymous> (/home/alex/github/node-report/node_modules/markdown-it-toc-and-anchor/dist/index.js:77:42)
at Core.process (/home/alex/github/node-report/node_modules/markdown-it/lib/parser_core.js:51:13)
at MarkdownIt.parse (/home/alex/github/node-report/node_modules/markdown-it/lib/index.js:519:13)
at MarkdownIt.render (/home/alex/github/node-report/node_modules/markdown-it/lib/index.js:539:36)
at Object.<anonymous> (/home/alex/github/node-report/src/test.coffee:17:11)
at Object.<anonymous> (/home/alex/github/node-report/src/test.coffee:2:1)
But if i run with the older version:
$ npm install markdown-it-toc-and-anchor@3.1.0
$ coffee src/test.coffee
<p>Put markdown here...</p>
I hope that helps to find the bug.
Thanks, it is fixed in commit https://github.com/MoOx/markdown-it-toc-and-anchor/commit/a0675b80c9500f1cf42f0ff478c820288ac00845 The problem is that i forgot to initialize the environment on the second instance of markdown-it, that runs inside this plugin to allow toc generation from markdown while preventing an infinite loop. version bump to 4.1.1
Thanks, works now.
It is a bit mysterious, since I updated this module some other markdown-it modules wont work like:
In both I got the same error: state.env is undefined and so this modules can't access its sub-properties. I didn't change anything in these and if I downgrade your module back to V3.1.0 everything is working again.
Did you accidentally delete the state.env within markdown-it?
Hope you can fix this to get your new version working properly, again.