You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After testing, it was found that it was due to the nesting of container_column_closewill be set -1 When the markdown-it-container adding the div container for column-container
/** * Token#nesting -> Number * * Level change (number in {-1, 0, 1} set), where: * * - `1` means the tag is opening * - `0` means the tag is self-closing * - `-1` means the tag is closing **/this.nesting=nesting
But when using both markdown-it-container and markdown-it-attrs at the same time,markdown-it-attrs traverses to find the container_div_close node, due to the newly added container of container_column_close node also satisfies the condition that nesting === -1, which will result in the style column-1 that should have been added to column test1 being added to the parent container of column container.
The temporary solution to this problem is to modify the code. As I am currently using the locally installed from NPM, I can modify the code in const token_c = state.push('container_' + name + '_close', 'div', -1) to temporarily use const token_c = state.push('container_' + name + '_close', 'div', -2). However, this may cause unknown and unpredictable bugs in the markdown-it-container. Here are the reasons for the problem and temporary solutions, hoping for a more professional solution.
Example input:
Current output:
Expected output:
When not using 'markdown-it-container' output:
After testing, it was found that it was due to the
nesting
ofcontainer_column_close
will be set-1
When the markdown-it-container adding thediv
container forcolumn-container
markdown-it-container
index.mjs#L123According to the official documentation of markdown-it, there is no problem with this setting
markdown-it token nesting
But when using both
markdown-it-container
andmarkdown-it-attrs
at the same time,markdown-it-attrs
traverses to find thecontainer_div_close
node, due to the newly added container ofcontainer_column_close
node also satisfies the condition thatnesting === -1
, which will result in the stylecolumn-1
that should have been added tocolumn test1
being added to the parent container ofcolumn container
.markdown-it-attrs
patterns.js#L327Other related issues:
# markdown-it-container issue#39 [Incompatibility with markdown-it-attrs]
# markdown-it-attrs issue#111 [Propagation of Attributes in Markdown-it-container]
# markdown-it-attrs issue#72 [Conflict with markdown-it-container]
Possible issues caused by this reason:
# markdown-it-attrs issue#150 [Unable to apply attributes to the last column of tables.]
# markdown-it-attrs issue#142 [Last column attribute setting results unexpectedly.]
The temporary solution to this problem is to modify the code. As I am currently using the locally installed from
NPM
, I can modify the code inconst token_c = state.push('container_' + name + '_close', 'div', -1)
to temporarily useconst token_c = state.push('container_' + name + '_close', 'div', -2)
. However, this may cause unknown and unpredictable bugs in themarkdown-it-container
. Here are the reasons for the problem and temporary solutions, hoping for a more professional solution.Temporary solution:
modify the markdown-it-container index.mjs#L123 code
The above is what I wrote using translation tools, hoping to understand it,
This problem was discovered during my use of
nodeppt
, hope it can be helpful.# nodeppt issue#311 [关于同时使用markdown-it-container和markdown-it-attrs导致冲突的问题.]
The text was updated successfully, but these errors were encountered: