@peaceroad/markdown-it-numbering-ul-regarded-as-ol 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/phase2-convert.js +9 -4
package/package.json
CHANGED
package/src/phase2-convert.js
CHANGED
|
@@ -259,7 +259,6 @@ function simplifyNestedBulletLists(tokens, listInfos, opt, listInfoMap = null) {
|
|
|
259
259
|
|
|
260
260
|
// Check if outer ul is convertible (has markers)
|
|
261
261
|
const outerListInfo = listInfos?.find(info => info.startIndex === i && info.shouldConvert)
|
|
262
|
-
const outerListHasMarkers = outerListInfo?.shouldConvert && outerListInfo.markerInfo
|
|
263
262
|
|
|
264
263
|
if (outerListInfo?.shouldConvert) {
|
|
265
264
|
for (const flattenedItem of itemIndices) {
|
|
@@ -283,14 +282,20 @@ function simplifyNestedBulletLists(tokens, listInfos, opt, listInfoMap = null) {
|
|
|
283
282
|
}
|
|
284
283
|
|
|
285
284
|
// Simplification conditions:
|
|
286
|
-
// 1.
|
|
287
|
-
// 2.
|
|
285
|
+
// 1. Every list_item has a nested list (the classic `- 1.` pattern)
|
|
286
|
+
// 2. That nested list appears as the very first child (no preceding paragraph text)
|
|
287
|
+
// This prevents flattening normal `* Parent` lists that intentionally nest an ordered list.
|
|
288
288
|
const allItemsHaveInnerList = itemIndices.length > 0 && itemIndices.length === totalItems
|
|
289
|
-
const
|
|
289
|
+
const innerListIsFirstChild = allItemsHaveInnerList &&
|
|
290
|
+
itemIndices.every(item => item.innerListOpen === item.outerItemOpen + 1)
|
|
291
|
+
const shouldSimplify = allItemsHaveInnerList && innerListIsFirstChild
|
|
290
292
|
|
|
291
293
|
if (shouldSimplify && itemIndices.length > 0) {
|
|
292
294
|
const allSameType = itemIndices.every(item => item.innerListType === itemIndices[0].innerListType)
|
|
293
295
|
const firstInnerType = itemIndices[0].innerListType
|
|
296
|
+
if (firstInnerType !== 'ordered_list_open') {
|
|
297
|
+
continue
|
|
298
|
+
}
|
|
294
299
|
const hasExtraContent = itemIndices.some(item => item.hasExtraContent)
|
|
295
300
|
|
|
296
301
|
// Don't simplify if inner lists are mixed types
|