|
@@ -573,11 +573,11 @@ function buildAST(md, mdTags=syntax, offset=0, tree={tag: 'root'}, stack=[]){
|
|
|
let {indent, childName, title, recursive, regexp, endRegexp, content: {end: {offset: offsetEnd, point} }, forward } = mdTags[currentNode.tag]
|
|
|
|
|
|
if (indent){
|
|
|
- if (currentNode.parent.tag !== currentNode.tag){ //li
|
|
|
- let { parent: {children: siblings} } = currentNode
|
|
|
- if (siblings.length > 1 && siblings.last(-2).tag === currentNode.tag){
|
|
|
- siblings.pop()
|
|
|
- currentNode = siblings.last()
|
|
|
+ if (currentNode.parent.tag !== currentNode.tag){
|
|
|
+ let { parent: {children: siblings} } = currentNode //current node are ol/ul
|
|
|
+ if (siblings.length > 1 && siblings.last(-2).tag === currentNode.tag){ //two ol/ul one after another should be concated as li
|
|
|
+ siblings.pop() //so remove last ol/ul
|
|
|
+ currentNode = siblings.last() //make previous ol/ul currentNode
|
|
|
}
|
|
|
const { children } = currentNode
|
|
|
const indentLength = currentNode.startMatch[1].length
|
|
@@ -590,7 +590,7 @@ function buildAST(md, mdTags=syntax, offset=0, tree={tag: 'root'}, stack=[]){
|
|
|
let listMD = md.slice(offset, endMatch.index + offset).cutIndent(currentNode.startMatch[0].length -2)
|
|
|
|
|
|
const newNode = {tag: childName, startOffset: offset, parent: currentNode, startMatch: currentNode.startMatch}
|
|
|
- children.push(newNode)
|
|
|
+ children.push(newNode) //create LI and add it into children of ol/ul
|
|
|
|
|
|
newNode.children = buildAST(listMD, mdTags).children
|
|
|
newNode.children.forEach(item => ((typeof item === 'object') && (item.parent = currentNode)))
|