Open zim32 opened 2 years ago
Problem is somewhere in utils.getMatchingOpeningToken(tokens[i].children, j - 1);
This function returns false, and then there is no check of false value, it is just passed to utils.addAttrs(attrs, openingToken); Here is token that causes getMatchingOpeningToken to return false
Token {
type: 'em_close',
tag: 'em',
attrs: null,
map: null,
nesting: -1,
level: 0,
children: null,
content: '',
markup: '*',
info: '',
meta: null,
block: false,
hidden: false
}
After more debugging I found that level is not correct
I have this text
There are two *ways*{.red} to install
and here is token stream. I don't know why on Earth em_open and em_close have different level property and why nesting is -1
Token {
type: 'em_close',
tag: 'em',
attrs: null,
map: null,
nesting: -1,
level: 0,
children: null,
content: '',
markup: '*',
info: '',
meta: null,
block: false,
hidden: false
}
Token {
type: 'text',
tag: '',
attrs: null,
map: null,
nesting: 0,
level: 1,
children: null,
content: 'ways',
markup: '',
info: '',
meta: null,
block: false,
hidden: false
}
Token {
type: 'em_open',
tag: 'em',
attrs: null,
map: null,
nesting: 1,
level: 1,
children: null,
content: '',
markup: '*',
info: '',
meta: null,
block: false,
hidden: false
}
Token {
type: 'text',
tag: '',
attrs: null,
map: null,
nesting: 0,
level: 0,
children: null,
content: 'There are two ',
markup: '',
info: '',
meta: null,
block: false,
hidden: false
}
Right now if I remove tokens[i].level === level check from this code
for (; i >= 0; --i) {
if (tokens[i].type === type && tokens[i].level === level) {
return tokens[i];
}
}
in getMatchingOpeningToken function it works. But this is wrong
Hi👋 Thanks for the detailed description. What version of markdown-it do you use?
Actually I don't know. Im using vuepress. You can see version in issue
Maybe this will help you
+-- markdown-it-attrs@4.1.4
| `-- markdown-it@13.0.1
`-- vuepress@1.9.7
`-- @vuepress/core@1.9.7
`-- @vuepress/markdown@1.9.7
+-- markdown-it-anchor@5.3.0
| `-- markdown-it@13.0.1 deduped
+-- markdown-it-chain@1.3.0
| `-- markdown-it@13.0.1 deduped
`-- markdown-it@8.4.2
I have the same issue when using markdown-it-bracketed-spans
. Is this may more be related to https://github.com/mb21/markdown-it-bracketed-spans?
I think the problem is not with this plugin but with markdown-it itself. Or maybe vuepress. Very hard to tell
Versions:
+-- markdown-it-attrs@4.1.4 +-- markdown-it-bracketed-spans@1.0.1 `-- vuepress@1.9.7
Example input:
Current output:
Uncaught (in promise) Error: Module build failed (from ./node_modules/@vuepress/markdown-loader/index.js): TypeError: token.attrJoin is not a function