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
/** * 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
测试 如下:
:::column {.column-container} column test1 {.column-1} --- column test2 {.column-2} :::
输出:
预期输出:
不使用markdown-it-container时:
经过测试发现是由于markdown-it-container在添加
column-container
父容器Token时,默认会将container_column _close
的nesting
设置为-1
.container.js#147
这是按照markdown-it的官方文档设置的,原本是没有问题的。
markdown-it token nesting
当同时使用
markdown-it-container
和markdown-it-attrs
时,markdown-it-attrs
在遍历寻找container_div _close
时由于新添加的容器的container_column _close
节点同样满足条件nesting
等于-1
的条件,这就会导致本来应该添加到column test2
上的样式column-2
会添加到column-container
的父容器上。patterns.js#475
经过对
markdown-it-container
和markdown-it-attrs
两个组件的Issue
查询,发现二者官方也没有对这个问题进行有效的解决。# 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]
可能因为这个原因导致的问题:
# 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.]
对于这个问题的临时解决方法, 由于我目前是使用的
NPM
本地安装的Nodeppt
,可以修改container.js#147中的代码,将token = state.push('container_' + name + '_close', 'div', -1);
修改为token = state.push('container_' + name + '_close', 'div', -2);
暂时使用,但是可能会对markdown-it-container
和nodeppt
产生未知无法预测的BUG,由于nodeppt
项目更新时间久远,不知道作者是否还在维护这个项目,这里提供了问题的原因以及临时解决方法,希望能有更专业的解决方案。临时解决方法:
修改container.js#147代码
The text was updated successfully, but these errors were encountered: